.
[tatoo.git] / myocamlbuild.ml
1 open Ocamlbuild_plugin ;;
2
3 let includes = [ "include/utils.ml"; "include/utils32.ml"; "include/utils64.ml"; "include/debug.ml" ]
4
5 let ml_str_rule () =
6    rule ".ml.str" ~dep:"%.ml.str" ~prod:"%.ml"
7     (fun env _ ->
8      let mlstr = env "%.ml.str" and ml = env "%.ml" in
9      let cmd = Printf.sprintf "echo -n 'let content = \"' > %s ;\ 
10                 sed -e 's/\\([\"\\\\]\\)/\\\\\\1/g' %s | sed -e 's/^\\(.*\\)$/\\1\\\\n\\\\/g' >> %s ;\
11                 echo '' >> %s ;\
12                 echo '\"' >> %s" ml mlstr ml ml ml
13      in
14      Cmd ( Sh cmd ))
15          
16 let () =
17   dispatch begin function
18              | After_rules ->
19                 dep ["ocaml";"compile";] includes;
20                 dep ["ocaml";"ocamldep"; ] includes;
21                 pflag ["ocaml";"compile";] "ppopt" (fun s -> S [A"-ppopt"; A (s)]);             
22                 pflag ["ocaml";"ocamldep";] "ppopt" (fun s -> S [A"-ppopt"; A (s)]);
23                 ml_str_rule ()
24              | _ -> ()
25
26 end;;