Skip to content
Browse files

Re-add the ocamlbuild plugin lost in the reorganization.

  • Loading branch information...
1 parent f7537f4 commit 75ea49488707a7a2ebecfaaa9c3c174f6959fe42 @pgj pgj committed Aug 2, 2012
Showing with 29 additions and 0 deletions.
  1. +29 −0 packages/myocamlbuild.ml
View
29 packages/myocamlbuild.ml
@@ -0,0 +1,29 @@
+open Ocamlbuild_plugin;;
+open Command;;
+
+module Util = struct
+ let split s ch =
+ let x = ref [] in
+ let rec go s =
+ let pos = String.index s ch in
+ x := (String.before s pos)::!x;
+ go (String.after s (pos + 1))
+ in
+ try
+ go s
+ with Not_found -> !x
+
+ let split_nl s = split s '\n'
+ let run_and_read x = List.hd (split_nl (Ocamlbuild_pack.My_unix.run_and_read x))
+end
+
+let query dir = Util.run_and_read ("ocamlfind query " ^ dir);;
+
+dispatch begin function
+| After_rules ->
+ flag ["camlp4of"; "build_syntax"]
+ (S[A "-I"; A "+camlp4"]);
+ flag ["compile"; "use_custom_stdlib"]
+ (S[A "-nostdlib"; A "-I"; A (query "mirage-stdlib")]);
+| _ -> ()
+end;;

0 comments on commit 75ea494

Please sign in to comment.
Something went wrong with that request. Please try again.