X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=blobdiff_plain;f=myocamlbuild.ml;h=7f8652359801060ac51115a3f236a88df7dcab3d;hp=2d9913ed76fd456be656e45551f5cbb4da6c495b;hb=406c70f1fe88c94c66489604eb8337d1e54043b9;hpb=30bc0bb1291426e5e26eb2dee1ffc41e4c246349 diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 2d9913e..7f86523 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -1,28 +1,26 @@ -open Ocamlbuild_plugin -open Command +open Ocamlbuild_plugin ;; -let ocamlfind_packages = "unix,ulex,expat,camlp4,camlp4.lib,camlp4.macro" +let includes = [ "include/utils.ml"; "include/utils32.ml"; "include/utils64.ml"; "include/debug.ml" ] -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 ml_str_rule () = + rule ".ml.str" ~dep:"%.ml.str" ~prod:"%.ml" + (fun env _ -> + let mlstr = env "%.ml.str" and ml = env "%.ml" in + let cmd = Printf.sprintf "echo -n 'let content = \"' > %s ;\ + sed -e 's/\\([\"\\\\]\\)/\\\\\\1/g' %s | sed -e 's/^\\(.*\\)$/\\1\\\\n\\\\/g' >> %s ;\ + echo '' >> %s ;\ + echo '\"' >> %s" ml mlstr ml ml ml + in + Cmd ( Sh cmd )) + +let () = + dispatch begin function + | After_rules -> + dep ["ocaml";"compile";] includes; + dep ["ocaml";"ocamldep"; ] includes; + pflag ["ocaml";"compile";] "ppopt" (fun s -> S [A"-ppopt"; A (s)]); + pflag ["ocaml";"ocamldep";] "ppopt" (fun s -> S [A"-ppopt"; A (s)]); + ml_str_rule () + | _ -> () -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") - | _ -> () -end +end;;