X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=blobdiff_plain;f=myocamlbuild.ml;h=7f8652359801060ac51115a3f236a88df7dcab3d;hp=41730a62eeed8b16b1bc5c5a13e0728c0fed1eb0;hb=406c70f1fe88c94c66489604eb8337d1e54043b9;hpb=d89f59cf6220e605bfbb67fd3cb83f9165fde5a5 diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 41730a6..7f86523 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -1,40 +1,26 @@ -open Ocamlbuild_plugin -open Command +open Ocamlbuild_plugin ;; -let includes = ref StringSet.empty +let includes = [ "include/utils.ml"; "include/utils32.ml"; "include/utils64.ml"; "include/debug.ml" ] -let register_include dir = - if not (StringSet.mem dir !includes) then begin - includes := StringSet.add dir !includes; - dep [ "extension:ml" ] - (List.map (fun s -> dir ^ "/" ^ s ) - (Array.to_list (Pathname.readdir dir))) - end +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 set_flags tag_list action_list = - List.iter (fun s -> - List.iter (fun (fl, fu) -> - pflag s fl fu) - action_list - ) tag_list - -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 -> - set_flags [["ocaml";"compile"]; ["ocaml";"ocamldep"] ] macro_flags; - flag [ "ocaml"; "compile"; "debug" ] (S[ A"-g"; A"-ppopt"; A"-DDEBUG"]); - flag [ "ocaml"; "link"; "debug" ] (A"-g"); - flag [ "ocaml"; "compile"; "profile"] (S[A"-ppopt"; A"-DPROFILE"]); - flag [ "ocaml"; "compile"; "profile"; "native"] (A"-p"); - flag [ "ocaml"; "link"; "profile"; "native"] (A"-p"); - pflag [ "ocaml"; "compile"; "native" ] "inline" (fun i -> (S[ A"-inline"; A i ])); - pflag [ "ocaml"; "compile" ] "unsafe" (fun s -> (if s = "true" then S[A"-ppopt";A "-unsafe"] else N)); - - | _ -> () -end +end;;