test_caml
[sqlgg.git] / myocamlbuild.ml
blobd3a20547f1a1939cadc48e860a079ff38aa04ad9
1 open Ocamlbuild_plugin
2 open Command
4 let chomp s =
5 let is_nl ch = match ch with | '\n' | '\r' -> true | _ -> false in
6 let rec cut n =
7 if n = 0 then 0 else if is_nl s.[n-1] then cut (n-1) else n
8 in
9 let ls = String.length s in
10 let n = cut ls in
11 if n = ls then s else String.sub s 0 n
13 let ocamlfind lib =
14 let cin = Unix.open_process_in (Printf.sprintf "ocamlfind -query %s" lib) in
15 let s = chomp (input_line cin) in
16 (* let s = Filename.quote s in*)
17 ignore (Unix.close_process_in cin);
22 dispatch begin function
23 | After_rules ->
24 let extlib_dir = ocamlfind "extlib" in
25 let deriving_dir = Myocamlbuild_config.deriving_dir in
26 let ounit_dir = ocamlfind "oUnit" in
28 ocaml_lib ~extern:true ~dir:extlib_dir "extLib";
29 ocaml_lib ~extern:true ~dir:deriving_dir "deriving";
30 ocaml_lib ~extern:true ~dir:ounit_dir "oUnit";
32 flag ["ocaml"; "doc"; "use_extLib"] (S[A"-I"; A extlib_dir]);
34 | _ -> ()
35 end