Merge branch 'ocamlbuild-port' of ssh://git.nguyen.vg/tatoo into ocamlbuild-port
[tatoo.git] / myocamlbuild.ml
1 open Ocamlbuild_plugin
2 let includes =
3   let open Pathname in
4   let d = Array.to_list (readdir "include") in
5   List.map (concat "include") d
6
7
8 let ml_str_rule () =
9    rule ".ml.str" ~dep:"%.ml.str" ~prod:"%.ml"
10     (fun env _ ->
11      let mlstr = env "%.ml.str" and ml = env "%.ml" in
12      let cmd = Printf.sprintf "echo -n 'let content = \"' > %s ;\ 
13                 sed -e 's/\\([\"\\\\]\\)/\\\\\\1/g' %s | sed -e 's/^\\(.*\\)$/\\1\\\\n\\\\/g' >> %s ;\
14                 echo '' >> %s ;\
15                 echo '\"' >> %s" ml mlstr ml ml ml
16      in
17      Cmd ( Sh cmd ))
18          
19 let () =
20   dispatch (function
21              | After_rules ->
22                 dep ["ocaml";"compile";] includes;
23                 dep ["ocaml";"ocamldep"; ] includes;
24                 pflag ["ocaml";"compile";] "ppopt" (fun s -> S [A"-ppopt"; A (s)]);             
25                 pflag ["ocaml";"ocamldep";] "ppopt" (fun s -> S [A"-ppopt"; A (s)]);
26                 ml_str_rule ()
27              | _ -> ()
28            )