mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Generate french_law artifacts through dune
The files where manually generated through Makefile rules, and versionned (with an outdated version). The issue was that we had: - `dune` building Catala - Makefiles calling `catala` to build and copy the `french_law/ocaml/law_source` files - then `dune` again to build `french_law` The result was that `dune build` (without running `make` first) would return a weird error. The proposed solution adds ad-hoc dune rules to call the catala binary, so that it can handle the whole pipeline correctly. If OCaml is purely a backend, though, a simpler solution that makes us less dependent on dune would be to handle the compilation of `french_law` manually. The dune rules are set to 'promote' the files so that it preserves the fact that they are versionned (but with no confusion of the build system about where they should come from anymore)
This commit is contained in:
parent
3df99acb21
commit
0600501ec6
11
Makefile
11
Makefile
@ -199,18 +199,13 @@ literate_examples: literate_allocations_familiales literate_code_general_impots
|
||||
FRENCH_LAW_OCAML_LIB_DIR=french_law/ocaml
|
||||
|
||||
$(FRENCH_LAW_OCAML_LIB_DIR)/law_source/allocations_familiales_api_web.ml:
|
||||
CATALA_OPTS="$(CATALA_OPTS) -t" $(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) allocations_familiales_api_web.ml
|
||||
cp -f $(ALLOCATIONS_FAMILIALES_DIR)/allocations_familiales_api_web.ml $@
|
||||
cp -f $(ALLOCATIONS_FAMILIALES_DIR)/allocations_familiales.ml $(FRENCH_LAW_OCAML_LIB_DIR)/law_source/allocations_familiales.ml
|
||||
dune build $@
|
||||
|
||||
$(FRENCH_LAW_OCAML_LIB_DIR)/law_source/aides_logement_api_web.ml:
|
||||
CATALA_OPTS="$(CATALA_OPTS) -t" $(MAKE) -C $(AIDES_LOGEMENT_DIR) aides_logement_api_web.ml
|
||||
cp -f $(AIDES_LOGEMENT_DIR)/aides_logement_api_web.ml $@
|
||||
cp -f $(AIDES_LOGEMENT_DIR)/aides_logement.ml $(FRENCH_LAW_OCAML_LIB_DIR)/law_source/aides_logement.ml
|
||||
dune build $@
|
||||
|
||||
$(FRENCH_LAW_OCAML_LIB_DIR)/law_source/unit_tests/tests_allocations_familiales.ml:
|
||||
CATALA_OPTS="$(CATALA_OPTS) -t" $(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) tests/tests_allocations_familiales.ml
|
||||
cp -f $(ALLOCATIONS_FAMILIALES_DIR)/tests/tests_allocations_familiales.ml $@
|
||||
dune build $@
|
||||
|
||||
#> generate_french_law_library_ocaml : Generates the French law library OCaml sources from Catala
|
||||
generate_french_law_library_ocaml: plugins \
|
||||
|
4
dune
4
dune
@ -1,6 +1,6 @@
|
||||
(dirs runtimes compiler french_law build_system)
|
||||
(dirs runtimes compiler french_law build_system examples)
|
||||
|
||||
(data_only_dirs tests examples syntax_highlighting)
|
||||
(data_only_dirs tests syntax_highlighting)
|
||||
|
||||
(alias
|
||||
(name exec)
|
||||
|
12
examples/aides_logement/dune
Normal file
12
examples/aides_logement/dune
Normal file
@ -0,0 +1,12 @@
|
||||
(rule
|
||||
(targets aides_logement.ml aides_logement_api_web.ml)
|
||||
(deps
|
||||
(source_tree ..)
|
||||
../../compiler/plugins/api_web%{ext_plugin})
|
||||
(action
|
||||
(run
|
||||
catala
|
||||
api_web
|
||||
-t
|
||||
--plugin-dir=../../compiler/plugins
|
||||
aides_logement.catala_fr)))
|
12
examples/allocations_familiales/dune
Normal file
12
examples/allocations_familiales/dune
Normal file
@ -0,0 +1,12 @@
|
||||
(rule
|
||||
(targets allocations_familiales.ml allocations_familiales_api_web.ml)
|
||||
(deps
|
||||
(source_tree ..)
|
||||
../../compiler/plugins/api_web%{ext_plugin})
|
||||
(action
|
||||
(run
|
||||
catala
|
||||
api_web
|
||||
-t
|
||||
--plugin-dir=../../compiler/plugins
|
||||
allocations_familiales.catala_fr)))
|
6
examples/allocations_familiales/tests/dune
Normal file
6
examples/allocations_familiales/tests/dune
Normal file
@ -0,0 +1,6 @@
|
||||
(rule
|
||||
(targets tests_allocations_familiales.ml)
|
||||
(deps
|
||||
(source_tree .))
|
||||
(action
|
||||
(run catala OCaml -t tests_allocations_familiales.catala_fr)))
|
9282
french_law/js/french_law.js
generated
9282
french_law/js/french_law.js
generated
File diff suppressed because one or more lines are too long
1
french_law/ocaml/law_source/.ocamlformat_ignore
Normal file
1
french_law/ocaml/law_source/.ocamlformat_ignore
Normal file
@ -0,0 +1 @@
|
||||
*
|
3816
french_law/ocaml/law_source/aides_logement.ml
generated
3816
french_law/ocaml/law_source/aides_logement.ml
generated
File diff suppressed because it is too large
Load Diff
1077
french_law/ocaml/law_source/allocations_familiales.ml
generated
1077
french_law/ocaml/law_source/allocations_familiales.ml
generated
File diff suppressed because it is too large
Load Diff
@ -4,3 +4,27 @@
|
||||
(preprocess
|
||||
(pps js_of_ocaml-ppx))
|
||||
(libraries catala.runtime_ocaml catala.runtime_jsoo js_of_ocaml))
|
||||
|
||||
(rule
|
||||
(target allocations_familiales.ml)
|
||||
(mode promote)
|
||||
(action
|
||||
(copy ../../../examples/allocations_familiales/%{target} %{target})))
|
||||
|
||||
(rule
|
||||
(target allocations_familiales_api_web.ml)
|
||||
(mode promote)
|
||||
(action
|
||||
(copy ../../../examples/allocations_familiales/%{target} %{target})))
|
||||
|
||||
(rule
|
||||
(target aides_logement.ml)
|
||||
(mode promote)
|
||||
(action
|
||||
(copy ../../../examples/aides_logement/%{target} %{target})))
|
||||
|
||||
(rule
|
||||
(target aides_logement_api_web.ml)
|
||||
(mode promote)
|
||||
(action
|
||||
(copy ../../../examples/aides_logement/%{target} %{target})))
|
||||
|
@ -2,3 +2,6 @@
|
||||
(name run_tests)
|
||||
(modes native)
|
||||
(libraries catala.runtime_ocaml ANSITerminal))
|
||||
|
||||
(copy_files#
|
||||
../../../../examples/allocations_familiales/tests/tests_allocations_familiales.ml)
|
||||
|
Loading…
Reference in New Issue
Block a user