-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyocamlbuild.ml
65 lines (55 loc) · 2.27 KB
/
myocamlbuild.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
open Printf
open Ocamlbuild_plugin;;
open Command;;
let () = dispatch (function
| Before_rules ->
()
| After_rules ->
ocaml_lib "src/MiniKanren";
(* miniKanren related stuff*)
(* flag ["ocamldep"; "use_mkshow"] (S [A"-ppopt";A"-I";A"-ppopt";A"plugin"; A"-ppopt";A"mkshow.cmo" ]); *)
flag ["compile"; "use_pa_minikanren"]
(S [ A"-ppopt";A"camlp5/pa_minikanren.cmo"]);
flag ["compile"; "use_time_log"]
(S [ A"-package"; A"logger.syntax"; A"-ppopt";A"-LOG"]);
flag ["hack_pr_o"; "compile"] (S[A"-ppopt"; A"pr_o.cmo"]);
(* flag ["compile"; "link_minikanren"] *)
(* (S [ A"-ppopt";A"camlp5/pa_minikanren.cmo" *)
(* ; A"-ppopt";A"-L";A"-ppopt";A"plugin" *)
(* ] *)
(* ); *)
flag ["ocaml";"compile";"native";"keep_asm"] (S[A"-S"]);
(* cppo-related stuff *)
let cppo_rules ext =
let dep = "%(name).cppo"-.-ext
and prod1 = "%(name: <*> and not <*.cppo>)"-.-ext
and prod2 = "%(name: <**/*> and not <**/*.cppo>)"-.-ext in
let cppo_rule prod env _build =
let dep = env dep in
let prod = env prod in
let tags = tags_of_pathname prod ++ "cppo" in
Cmd (S[A "cppo"; T tags; S [A "-o"; P prod]; P dep ])
in
rule ("cppo: *.cppo."-.-ext^" -> *."-.-ext) ~dep ~prod:prod1 (cppo_rule prod1);
rule ("cppo: **/*.cppo."-.-ext^" -> **/*."-.-ext) ~dep ~prod:prod2 (cppo_rule prod2);
in
List.iter cppo_rules ["ml"; "mli"];
pflag ["cppo"] "cppo_D" (fun s -> S [A "-D"; A s]) ;
pflag ["cppo"] "cppo_U" (fun s -> S [A "-U"; A s]) ;
pflag ["cppo"] "cppo_I" (fun s ->
if Pathname.is_directory s then S [A "-I"; P s]
else S [A "-I"; P (Pathname.dirname s)]
);
pdep ["cppo"] "cppo_I" (fun s ->
if Pathname.is_directory s then [] else [s]) ;
flag ["cppo"; "cppo_q"] (A "-q") ;
flag ["cppo"; "cppo_s"] (A "-s") ;
flag ["cppo"; "cppo_n"] (A "-n") ;
pflag ["cppo"] "cppo_x" (fun s -> S [A "-x"; A s]);
pflag ["cppo"] "cppo_V" (fun s -> S [A "-V"; A s]);
flag ["cppo"; "cppo_V_OCAML"] & S [A "-V"; A ("OCAML:" ^ Sys.ocaml_version)];
flag ["compile"; "short_paths"] & S [A "-short-paths"];
flag ["compile"; "backtrack"] & S [A "-backtrack"];
()
| _ -> ()
)