X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=myocamlbuild.ml;h=dbc0a4549d4d3941d5ee536cd1dccb10c3e63d91;hb=refs%2Fheads%2Focamlbuild-port;hp=5d04a11a8aef4ba55a883c92a0da6141c00c0d2d;hpb=18482b8b36fbdc5b904cf44e106075af39eef912;p=tatoo.git diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 5d04a11..dbc0a45 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -1,14 +1,28 @@ -open Ocamlbuild_plugin ;; +open Ocamlbuild_plugin +let includes = + let open Pathname in + let d = Array.to_list (readdir "include") in + List.map (concat "include") d -let includes = [ "include/utils.ml"; "include/utils32.ml"; "include/utils64.ml"; "include/debug.ml" ] +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 + dispatch (function | After_rules -> dep ["ocaml";"compile";] includes; dep ["ocaml";"ocamldep"; ] includes; - pflag ["ocaml";"compile";] "ppopt" (fun s -> S [A"-ppopt"; A (s)]); + 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 () | _ -> () - -end;; + )