Skip to content

Commit

Permalink
Parse warning in META file (but don't process)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromemaloberti committed Apr 25, 2018
1 parent 8630ae2 commit 6d2eb3c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions obuild/meta.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ module Pkg = struct
browse_interface : string;
type_of_threads : string;
archives : (Predicate.t list * string) list;
warning : (Predicate.t list * string) list;
append_archives : (Predicate.t list * string) list;
version : string;
assignment : (string * string) list;
Expand All @@ -106,6 +107,7 @@ module Pkg = struct
exists_if = "";
archives = [];
append_archives = [];
warning = [];
version = "";
assignment = [];
subs = [];
Expand Down Expand Up @@ -354,6 +356,15 @@ module Token = struct
| ID "directory" :: EQ :: S dir :: xs -> parse pkg_name { acc with Pkg.directory = dir } xs
| ID "description" :: EQ :: S dir :: xs -> parse pkg_name { acc with Pkg.description = dir } xs
| ID "browse_interfaces" :: EQ :: S _ :: xs -> parse pkg_name acc xs
| ID "warning" :: xs -> (
let (preds, xs2) = parse_predicate_list pkg_name "archive" xs in
match xs2 with
| EQ :: S v :: xs3 ->
let nacc = { acc with Pkg.warning = acc.Pkg.warning @ [(preds, v)] } in
parse pkg_name nacc xs3
| _ -> raise (MetaParseError (pkg_name, "parsing warning failed"))
)

| ID "archive" :: xs -> (
let (preds, xs2) = parse_predicate_list pkg_name "archive" xs in
match xs2 with
Expand Down
36 changes: 36 additions & 0 deletions tests/test_find.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,42 @@ let () =
let num_answer = Meta.Pkg.get_archive_with_filter (None, num) (Libname.of_string "num.core")
[Meta.Predicate.Native; Meta.Predicate.Plugin] in
assumeEq "num plugin native" "archive(plugin,native) = [nums.cmxs]" (archives_to_string num_answer);
let meta_threads = "# Specifications for the \"threads\" library:\n\
version = \"[distributed with Ocaml]\"\n\
description = \"Multi-threading\"\n\
requires(mt,mt_vm) = \"threads.vm\"\n\
requires(mt,mt_posix) = \"threads.posix\"\n\
directory = \"^\"\n\
type_of_threads = \"posix\"\n\
\n\
browse_interfaces = \" Unit name: Condition Unit name: Event Unit name: Mutex Unit name: Thread Unit name: ThreadUnix \"\n\
\n\
warning(-mt) = \"Linking problems may arise because of the missing -thread or -vmthread switch\"\n\
warning(-mt_vm,-mt_posix) = \"Linking problems may arise because of the missing -thread or -vmthread switch\"\n\
\n\
package \"vm\" (\n\
\ # --- Bytecode-only threads:\n\
\ requires = \"unix\"\n\
\ directory = \"+vmthreads\"\n\
\ exists_if = \"threads.cma\"\n\
\ archive(byte,mt,mt_vm) = \"threads.cma\"\n\
\ version = \"[internal]\"\n\
)\n\
\n\
package \"posix\" (\n\
\ # --- POSIX-threads:\n\
\ requires = \"unix\"\n\
\ directory = \"+threads\"\n\
\ exists_if = \"threads.cma\"\n\
\ archive(byte,mt,mt_posix) = \"threads.cma\"\n\
\ archive(native,mt,mt_posix) = \"threads.cmxa\"\n\
\ version = \"[internal]\"\n\
)\n" in
let threads = Meta.parse (Filepath.fp "threads") meta_threads "threads" in
let threads_answer = Meta.Pkg.get_archive_with_filter (None, threads) (Libname.of_string "threads.posix")
[Meta.Predicate.Native; Meta.Predicate.Mt; Meta.Predicate.Mt_posix] in
assumeEq "threads native" "archive(native,mt,mt_posix) = [threads.cmxa]" (archives_to_string threads_answer);

let meta_ctypes =
"\
version = \"0.4\"\n\
Expand Down

0 comments on commit 6d2eb3c

Please sign in to comment.