From: Kim Nguyễn Date: Thu, 7 Feb 2013 18:02:12 +0000 (+0100) Subject: Use ocamlbuild's built-in support for ocamlfind (requires ocaml 3.12.1) X-Git-Tag: v0.1~183 X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=commitdiff_plain;h=29afc3e757d710479de98f3077698a350f810cef Use ocamlbuild's built-in support for ocamlfind (requires ocaml 3.12.1) --- diff --git a/Makefile b/Makefile index ee29352..09c08ab 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ SOURCE_DIR=src,src/xpath,src/utils,src/tree,src/auto TARGET=main.otarget - +OCAMLFINDPKG=unix,ulex,expat,camlp4,camlp4.lib,camlp4.macro all: @echo [BUILD] - @ocamlbuild -Is $(SOURCE_DIR) $(TARGET) + ocamlbuild -pkgs $(OCAMLFINDPKG) -use-ocamlfind -Is $(SOURCE_DIR) $(TARGET) clean: @echo [Clean] diff --git a/_tags b/_tags index 11dbbef..8baa48a 100644 --- a/_tags +++ b/_tags @@ -2,3 +2,4 @@ : for-pack(Utils) : for-pack(Tree) : for-pack(Auto) +<**/*.ml>: syntax(camlp4o), macro_include(include) \ No newline at end of file diff --git a/include/utils64.ml b/include/utils64.ml index cfebeec..f655743 100644 --- a/include/utils64.ml +++ b/include/utils64.ml @@ -9,5 +9,5 @@ DEFINE UTILS64__ML__ DEFINE HPARAM = 65599 DEFINE HPARAM2 = 4303228801 DEFINE HPARAM3 = 282287506116799 - DEFINE HPARAM4 = 71034040046345985 + DEFINE HPARAM4 = 71034040046345985 END diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 2d9913e..a1fe8e9 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -1,28 +1,30 @@ open Ocamlbuild_plugin open Command -let ocamlfind_packages = "unix,ulex,expat,camlp4,camlp4.lib,camlp4.macro" +let includes = Hashtbl.create 17 +let register_include dir = + if not (Hashtbl.mem includes dir) then begin + Hashtbl.add includes dir (); + dep [ "extension:ml" ] + (List.map (fun s -> dir ^ "/" ^ s ) + (Array.to_list (Pathname.readdir dir))) + end -let ocamlfind x = S[ T (Tags.singleton "ocamlfind"); - A "ocamlfind"; x ; - A "-package"; - A ocamlfind_packages; - A "-syntax"; - A "camlp4o"; - A "-ppopt"; A "-I"; A"-ppopt"; A"include" - ] +let macro_flags = [ + "macro_include", + (fun s -> register_include s; S [A"-ppopt"; A "-I"; A"-ppopt"; A s]); + "macro_define", (fun s -> S [A"-ppopt"; A ("-D"^s)]); +] let () = dispatch begin function | Before_rules -> - Options.ocamlc := ocamlfind (A"ocamlc"); - Options.ocamlopt := ocamlfind (A"ocamlopt"); - Options.ocamldep := ocamlfind (A"ocamldep"); - Options.ocamldoc := ocamlfind (A"ocamldoc"); - Options.ocamlmktop := ocamlfind (A"ocamlmktop"); - dep [ "extension:ml" ] - (List.map (fun s -> "include/" ^ s ) - (Array.to_list (Pathname.readdir "include"))); - flag [ "ocaml"; "link" ] (A"-linkpkg") + List.iter (fun s -> + List.iter (fun (fl, fu) -> + pflag s fl fu) macro_flags + ) + [["ocaml";"compile"]; + ["ocaml";"ocamldep"] ] +; | _ -> () end