-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmyocamlbuild.ml
52 lines (43 loc) · 1.66 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
(* OASIS_START *)
(* OASIS_STOP *)
let dispatch = function
| After_rules ->
let stubgen = "stubgen/ffi_stubgen.byte" in
let stubgen_types = "stubgen/ffi_types_stubgen.byte" in
let stubgen_ml_types = "stubgen/ffi_ml_types_subgen" in
rule "generated ml"
~dep:stubgen
~prod:"lib/ffi_generated.ml"
(fun _ _ ->
Cmd(S[P stubgen; A"-ml"; Sh">"; A"lib/ffi_generated.ml"]));
rule "generated-types c"
~dep:stubgen_types
~prod:"stubgen/ffi_ml_types_stubgen.c"
(fun _ _ ->
Cmd (S [P stubgen_types; Sh">"; A"stubgen/ffi_ml_types_stubgen.c"]));
rule "generated-types exe"
~dep:"stubgen/ffi_ml_types_stubgen.c"
~prod:stubgen_ml_types
(fun _ _ ->
let env = BaseEnvLight.load () in
let cc = BaseEnvLight.var_get "bytecomp_c_compiler" env in
let stdlib = BaseEnvLight.var_get "standard_library" env in
let ctypes = BaseEnvLight.var_get "pkg_ctypes_stubs" env in
Cmd (S [Sh cc; A"stubgen/ffi_ml_types_stubgen.c";
A"-I"; P ctypes; A"-I"; P stdlib;
A"-o"; A stubgen_ml_types])
);
rule "generated-types ml"
~dep:stubgen_ml_types
~prod:"lib/ffi_generated_types.ml"
(fun _ _ ->
Cmd (S [P stubgen_ml_types; Sh">>"; A"lib/ffi_generated_types.ml"]));
rule "generated c"
~dep:stubgen
~prod:"lib/ffi_generated_stubs.c"
(fun _ _ ->
Cmd(S[P stubgen; A"-c"; Sh">"; A"lib/ffi_generated_stubs.c"]));
flag ["c"; "compile"] & S[A"-I"; A"lib"; A"-package"; A"ctypes"]
| _ ->
()
let () = Ocamlbuild_plugin.dispatch (fun hook -> dispatch hook; dispatch_default hook)