2 This ocamlbuild plugin will try to find libraries by name using (in order)
3 - local myocamlbuild.config file
6 Sample myocamlbuild.config :
8 extlib=C:/my/contrib/extlib-1.5.1
9 deriving=C:/my/contrib/deriving-0.1.1/lib
10 oUnit=C:/my/contrib/ounit-1.0.3
14 (** querying ocamlfind *)
17 let is_nl ch
= match ch
with | '
\n'
| '
\r'
-> true | _
-> false in
19 if n
= 0 then 0 else if is_nl s
.[n
-1] then cut (n
-1) else n
21 let ls = String.length s
in
23 if n = ls then s
else String.sub s
0 n
26 let cin = Unix.open_process_in
(Printf.sprintf
"ocamlfind -query %s" lib
) in
27 let s = chomp (input_line
cin) in
28 (* let s = Filename.quote s in*)
29 ignore
(Unix.close_process_in
cin);
32 (** querying config *)
37 let ch = open_in name
in
38 begin try while true do l := input_line
ch :: !l done with End_of_file
-> () end;
45 let read_config name
=
46 let l = file_lines name
in
48 let index = String.index s '
='
in
49 (String.sub
s 0 index, String.sub
s (index+1) ((String.length
s) - index - 1))
51 let split s = try split s with _
-> "","" in
56 let config = read_config "myocamlbuild.config"
59 | [] -> prerr_endline
"No config, will use ocamlfind"
60 | _
-> prerr_endline
"Using config : ";
61 List.iter
(fun (x
,y
) -> Printf.eprintf
"%s=%s\n%!" x y
) config
65 List.assoc name
config