Merge branch 'ocamlbuild-port' of ssh://git.nguyen.vg/tatoo into ocamlbuild-port
[tatoo.git] / myocamlbuild.ml
index 3b3e516..dbc0a45 100644 (file)
@@ -5,12 +5,24 @@ let includes =
   List.map (concat "include") d
 
 
+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 (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 ()
              | _ -> ()
            )