Clerk: add python targets

This commit is contained in:
Louis Gesbert 2024-02-13 13:53:00 +01:00
parent 4ee4992b54
commit 98ad084062

View File

@ -493,6 +493,10 @@ let[@ocamlformat "disable"] static_base_rules =
] ]
~description:["<ocaml>"; ""; !output]; ~description:["<ocaml>"; ""; !output];
Nj.rule "python"
~command:[!catala_exe; "python"; !catala_flags; !input; "-o"; !output]
~description:["<catala>"; "python"; ""; !output];
Nj.rule "out-test" Nj.rule "out-test"
~command: [ ~command: [
!catala_exe; !test_command; "--plugin-dir="; "-o -"; !catala_flags; !input; !catala_exe; !test_command; "--plugin-dir="; "-o -"; !catala_flags; !input;
@ -591,21 +595,30 @@ let gen_build_statements
~outputs:[modd m]) ~outputs:[modd m])
item.module_def item.module_def
in in
let ml_file = let target_file ext =
match item.module_def with match item.module_def with
| Some m -> (!Var.builddir / src /../ m) ^ ".ml" | Some m -> (!Var.builddir / src /../ m) ^ "." ^ ext
| None -> (!Var.builddir / !Var.src) ^ ".ml" | None -> (!Var.builddir / !Var.src) ^ "." ^ ext
in in
let ocaml = let ml_file = target_file "ml" in
let py_file = target_file "py" in
let ocaml, python =
if item.extrnal then if item.extrnal then
Nj.build "copy" ( Nj.build "copy"
~implicit_in:[inc srcv] ~implicit_in:[inc srcv]
~inputs:[src -.- "ml"] ~inputs:[src -.- "ml"]
~outputs:[ml_file] ~outputs:[ml_file],
Nj.build "copy"
~implicit_in:[inc srcv]
~inputs:[src -.- "py"]
~outputs:[py_file] )
else else
Nj.build "catala-ocaml" ( Nj.build "catala-ocaml"
~inputs:[inc srcv] ~inputs:[inc srcv]
~implicit_in:[!Var.catala_exe] ~outputs:[ml_file] ~implicit_in:[!Var.catala_exe] ~outputs:[ml_file],
Nj.build "python"
~inputs:[inc srcv]
~implicit_in:[!Var.catala_exe] ~outputs:[py_file] )
in in
let ocamlopt = let ocamlopt =
let implicit_out_exts = ["cmi"; "cmx"; "cmt"; "o"] in let implicit_out_exts = ["cmi"; "cmx"; "cmt"; "o"] in
@ -774,6 +787,7 @@ let gen_build_statements
Option.to_seq expose_module; Option.to_seq expose_module;
Seq.return ocaml; Seq.return ocaml;
Seq.return ocamlopt; Seq.return ocamlopt;
Seq.return python;
List.to_seq tests; List.to_seq tests;
Seq.return interpret; Seq.return interpret;
] ]