mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Clerk: split OCaml compiler & link rules
and fix call to `catala depends` for OCaml linking
This commit is contained in:
parent
3c03da4a50
commit
77ba1b8b38
@ -522,10 +522,14 @@ let[@ocamlformat "disable"] static_base_rules =
|
|||||||
!input; "-o"; !output]
|
!input; "-o"; !output]
|
||||||
~description:["<catala>"; "ocaml"; "⇒"; !output];
|
~description:["<catala>"; "ocaml"; "⇒"; !output];
|
||||||
|
|
||||||
|
Nj.rule "ocaml-object"
|
||||||
|
~command:[!ocamlc_exe; "-c"; !ocaml_flags; !input; "&&";
|
||||||
|
!ocamlopt_exe; "-c"; !ocaml_flags; !input]
|
||||||
|
~description:["<ocaml>"; "⇒"; !output];
|
||||||
|
|
||||||
Nj.rule "ocaml-module"
|
Nj.rule "ocaml-module"
|
||||||
~command:
|
~command:
|
||||||
[!ocamlc_exe; "-c"; !ocaml_flags; !input; "&&";
|
[!ocamlopt_exe; "-shared"; !ocaml_flags; !input; "-o"; !output]
|
||||||
!ocamlopt_exe; "-shared"; !ocaml_flags; !input; "-o"; !output]
|
|
||||||
~description:["<ocaml>"; "⇒"; !output];
|
~description:["<ocaml>"; "⇒"; !output];
|
||||||
|
|
||||||
Nj.rule "ocaml-exec"
|
Nj.rule "ocaml-exec"
|
||||||
@ -534,7 +538,6 @@ let[@ocamlformat "disable"] static_base_rules =
|
|||||||
shellout [!catala_exe; "depends";
|
shellout [!catala_exe; "depends";
|
||||||
"--prefix="^ !builddir; "--extension=cmx";
|
"--prefix="^ !builddir; "--extension=cmx";
|
||||||
!catala_flags; !orig_src];
|
!catala_flags; !orig_src];
|
||||||
!input;
|
|
||||||
"-o"; !output;
|
"-o"; !output;
|
||||||
]
|
]
|
||||||
~description:["<ocaml>"; "⇒"; !output];
|
~description:["<ocaml>"; "⇒"; !output];
|
||||||
@ -669,14 +672,16 @@ let gen_build_statements
|
|||||||
~implicit_in:[!Var.catala_exe] ~outputs:[py_file] )
|
~implicit_in:[!Var.catala_exe] ~outputs:[py_file] )
|
||||||
in
|
in
|
||||||
let ocamlopt =
|
let ocamlopt =
|
||||||
let implicit_out_exts = ["cmi"; "cmo"; "cmx"; "cmt"; "o"] in
|
let obj =
|
||||||
match item.module_def with
|
let m =
|
||||||
| Some m ->
|
match item.module_def with
|
||||||
|
| Some m -> m
|
||||||
|
| None -> Filename.(basename (remove_extension src))
|
||||||
|
in
|
||||||
let target ext = (!Var.builddir / src /../ m) ^ "." ^ ext in
|
let target ext = (!Var.builddir / src /../ m) ^ "." ^ ext in
|
||||||
Nj.build "ocaml-module" ~inputs:[ml_file]
|
Nj.build "ocaml-object" ~inputs:[ml_file]
|
||||||
~implicit_in:(!Var.catala_exe :: List.map modd modules)
|
~implicit_in:(!Var.catala_exe :: List.map modd modules)
|
||||||
~outputs:[target "cmxs"]
|
~outputs:(List.map target ["cmi"; "cmo"; "cmx"; "cmt"; "o"])
|
||||||
~implicit_out:(List.map target implicit_out_exts)
|
|
||||||
~vars:
|
~vars:
|
||||||
[
|
[
|
||||||
( Var.ocaml_flags,
|
( Var.ocaml_flags,
|
||||||
@ -691,20 +696,20 @@ let gen_build_statements
|
|||||||
])
|
])
|
||||||
include_dirs );
|
include_dirs );
|
||||||
]
|
]
|
||||||
| None ->
|
in
|
||||||
let target ext = (!Var.builddir / !Var.src) ^ "." ^ ext in
|
let modexec =
|
||||||
let implicit_in =
|
match item.module_def with
|
||||||
List.map
|
| Some _ ->
|
||||||
(fun m ->
|
Nj.build "ocaml-module"
|
||||||
if List.mem m same_dir_modules then
|
~inputs:[target_file "cmx"]
|
||||||
(!Var.builddir / src /../ m) ^ ".cmx"
|
~outputs:[target_file "cmxs"]
|
||||||
else m ^ "@module")
|
| None ->
|
||||||
modules
|
Nj.build "ocaml-exec"
|
||||||
in
|
~inputs:[target_file "cmx"]
|
||||||
Nj.build "ocaml-exec" ~inputs:[ml_file] ~implicit_in
|
~outputs:[target_file "exe"]
|
||||||
~outputs:[target "exe"]
|
~vars:[Var.orig_src, [inc srcv]]
|
||||||
~implicit_out:(List.map target implicit_out_exts)
|
in
|
||||||
~vars:[Var.orig_src, [!Var.src ^ Filename.extension src]]
|
[obj; modexec]
|
||||||
in
|
in
|
||||||
let expose_module =
|
let expose_module =
|
||||||
match item.module_def with
|
match item.module_def with
|
||||||
@ -810,7 +815,7 @@ let gen_build_statements
|
|||||||
Option.to_seq module_deps;
|
Option.to_seq module_deps;
|
||||||
Option.to_seq expose_module;
|
Option.to_seq expose_module;
|
||||||
Seq.return ocaml;
|
Seq.return ocaml;
|
||||||
Seq.return ocamlopt;
|
List.to_seq ocamlopt;
|
||||||
Seq.return python;
|
Seq.return python;
|
||||||
List.to_seq tests;
|
List.to_seq tests;
|
||||||
Seq.return interpret;
|
Seq.return interpret;
|
||||||
|
Loading…
Reference in New Issue
Block a user