This repository has been archived by the owner on May 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
myocamlbuild.ml
54 lines (41 loc) · 2.02 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
open Ocamlbuild_plugin
let ctypes_lib = let ctypes = Findlib.query "ctypes" in ctypes.Findlib.location
let ocaml_stdlib = run_and_read "ocamlfind printconf stdlib"
let cc = "cc" (* C compiler *)
let c_headers tag dir =
flag [ "compile"; "c"; tag ] (S [ A "-I"; P dir ])
let libgccjit_dir =
try S [A "-L"; P (Sys.getenv "LIBGCCJIT_DIR")] with Not_found -> N
let ldopt =
try S [A "-ccopt"; A "-L"; A"-ccopt"; P (Sys.getenv "LIBGCCJIT_DIR")] with Not_found -> N
let () =
dispatch begin function
| Before_options ->
Options.use_ocamlfind := true
| After_rules ->
rule "gccjit c types generator"
~dep:"lib_gen/gen_types_generator.byte"
~prod:"lib_gen/gccjit_types_generator.c"
(fun _ _ -> Cmd (S [P "lib_gen/gen_types_generator.byte"; Sh ">"; A "lib_gen/gccjit_types_generator.c"]));
rule "gccjit bin types generator"
~dep:"lib_gen/gccjit_types_generator.o"
~prod:"lib_gen/gccjit_types_generator"
(fun _ _ ->
Cmd (S [P cc; A "-o"; P "lib_gen/gccjit_types_generator"; A "lib_gen/gccjit_types_generator.o"]));
rule "gccjit ml generated types"
~dep:"lib_gen/gccjit_types_generator"
~prod:"lib/gccjit_types_generated.ml"
(fun _ _ -> Cmd (S [P "lib_gen/gccjit_types_generator"; Sh ">"; A "lib/gccjit_types_generated.ml"]));
rule "gccjit c & ml generated stubs"
~deps:["lib/gccjit_types_generated.ml"; "lib_gen/gen_stubs.byte"]
~prods:["lib/gccjit_stubs_generated.ml"; "lib/gccjit_stubs.c"]
(fun _ _ -> Cmd (S [P "lib_gen/gen_stubs.byte"]));
c_headers "use_ctypes" ctypes_lib;
c_headers "use_ocaml" ocaml_stdlib;
flag [ "c"; "ocamlmklib"; "use_gccjit" ] (S [libgccjit_dir; A "-lgccjit"]);
flag [ "ocaml"; "link"; "use_gccjit"; "byte" ] (S [A"-dllib"; A"-lgccjit_stubs"]);
flag [ "ocaml"; "link"; "use_gccjit"; "library"; "native" ]
(S [ A "-cclib"; A "-lgccjit_stubs"; ldopt; A "-cclib"; A"-lgccjit"]);
| _ ->
()
end