fix
[camlunity.git] / myocamlbuild.ml
blob27163c54e4ca2d203e4d75d5a5217cbf2ae2dae9
1 open Ocamlbuild_plugin
2 open Command
4 module C = Myocamlbuild_config
6 ;;
8 let () =
9 let bracket res destroy k = let x = (try k res with e -> destroy res; raise e) in destroy res; x in
10 let get_line r d = bracket r d input_line in
12 bracket (open_out "version.ml") close_out (fun out ->
13 let revision =
14 try
15 get_line (Unix.open_process_in "git describe --always") (Unix.close_process_in)
16 with
17 _ -> (try get_line (open_in "version.id") close_in with _ -> "<unknown>")
19 Printf.fprintf out "let id=\"%s\"\n" (String.escaped revision)
24 dispatch begin function
25 | After_rules ->
27 C.extern ~cma:"extLib" "extlib";
28 C.extern "pcre";
29 C.extern "netsys";
30 C.extern "netstring";
31 C.extern "equeue";
32 C.extern "netclient";
33 C.extern "netcgi2" ~cma:"netcgi";
34 C.extern "oUnit";
35 C.extern "zip";
36 C.extern "json-wheel" ~cma:"jsonwheel";
37 C.extern "sqlite3";
38 C.extern "ocsigen.xhtml" ~cma:"xhtml";
40 flag ["ocaml"; "doc"; "use_extLib"] (S[A"-I"; A (C.lib "extlib")]);
42 let flag_bn l x =
43 flag ("byte"::l) x;
44 flag ("native"::l) x
47 flag_bn ["link"; "ocaml"; "use_netstring"; "thread"] (S[A"netstring_mt.cmo"]);
48 flag_bn ["link"; "ocaml"; "use_equeue"; "thread"] (S[A"unixqueue_mt.cmo"]);
50 | _ -> ()
51 end