ocaml / ocamlbuild /

Diff from to


   pflag ["ocaml";"compile";] "warn"
     (fun param -> S [A "-w"; A param])
+let try_opt name =
+  let cmd = Command.string_of_command_spec (A name)in
+  try ignore(Command.search_in_path cmd); name ^ ".opt"
+  with Not_found -> name
 let camlp4_flags camlp4s =
   List.iter begin fun camlp4 ->
-    flag ["ocaml"; "pp"; camlp4] (A camlp4)
+    flag ["ocaml"; "pp"; camlp4] (A (try_opt camlp4))
   end camlp4s;;
 camlp4_flags ["camlp4o"; "camlp4r"; "camlp4of"; "camlp4rf"; "camlp4orf"; "camlp4oof"];;
 let camlp4_flags' camlp4s =
-  List.iter begin fun (camlp4, flags) ->
+  List.iter begin fun (camlp4, cmd, flags) ->
+    let flags = S (A (try_opt cmd) :: flags) in
     flag ["ocaml"; "pp"; camlp4] flags
   end camlp4s;;
-camlp4_flags' ["camlp4orr", S[A"camlp4of"; A"-parser"; A"reloaded"];
-               "camlp4rrr", S[A"camlp4rf"; A"-parser"; A"reloaded"]];;
+camlp4_flags' ["camlp4orr", "camlp4of", [A"-parser"; A"reloaded"];
+               "camlp4rrr", "camlp4rf", [A"-parser"; A"reloaded"]];;
 flag ["ocaml"; "pp"; "camlp4:no_quot"] (A"-no_quot");;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.