Skip to content

Commit

Permalink
refactor(french_law/ocaml): refactor the api_web.ml
Browse files Browse the repository at this point in the history
  • Loading branch information
EmileRolley committed Jul 22, 2022
1 parent 231f327 commit dba8938
Show file tree
Hide file tree
Showing 22 changed files with 11,873 additions and 3,624 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,18 @@ $(FRENCH_LAW_OCAML_LIB_DIR)/law_source/allocations_familiales.ml:
CATALA_OPTS="$(CATALA_OPTS) -t" $(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) allocations_familiales.ml
cp -f $(ALLOCATIONS_FAMILIALES_DIR)/allocations_familiales.ml $@

$(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 $@

$(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 $@

#> generate_french_law_library_ocaml : Generates the French law library OCaml sources from Catala
generate_french_law_library_ocaml:\
generate_french_law_library_ocaml: plugins \
$(FRENCH_LAW_OCAML_LIB_DIR)/law_source/allocations_familiales.ml \
$(FRENCH_LAW_OCAML_LIB_DIR)/law_source/allocations_familiales_api_web.ml \
$(FRENCH_LAW_OCAML_LIB_DIR)/law_source/unit_tests/tests_allocations_familiales.ml
$(MAKE) format

Expand Down
3 changes: 1 addition & 2 deletions compiler/driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ let driver source_file (options : Cli.options) : int =
Cli.debug_print "Compiling program into OCaml...";
Cli.debug_print "Writing to %s..."
(Option.value ~default:"stdout" output_file);
Lcalc.To_ocaml.format_program fmt prgm type_ordering;
File.ocamlformat_file_opt output_file
Lcalc.To_ocaml.format_program fmt prgm type_ordering
| `Plugin (Plugin.Lcalc p) ->
let output_file, _ = get_output ~ext:p.Plugin.extension () in
Cli.debug_print "Compiling program through backend \"%s\"..."
Expand Down
2 changes: 1 addition & 1 deletion compiler/plugins/dune
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(name jsoo)
(modes plugin)
(modules jsoo)
(libraries catala.driver catala.runtime))
(libraries catala.driver))

(documentation
(package catala)
Expand Down
10 changes: 10 additions & 0 deletions examples/Makefile.common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ CURR_DIR=examples/$(shell basename $(shell pwd))/
CATALA=cd ../../; _build/default/compiler/catala.exe \
$(CATALA_OPTS) --language=$(CATALA_LANG)

PLUGIN_DIR=_build/default/compiler/plugins

help : ../Makefile.common.mk
@sed -n 's/^#> //p' $<

Expand All @@ -31,6 +33,14 @@ help : ../Makefile.common.mk
OCaml \
$(CURR_DIR)$<

#> <target_file>_api_web.ml : Compiles the file to OCaml + genereates the API web
%_api_web.ml: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $(CURR_DIR)$<
$(CATALA) \
jsoo \
--plugin-dir=$(PLUGIN_DIR) \
$(CURR_DIR)$<

#> <target_file>.py : Compiles the file to Python
%.py: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $(CURR_DIR)$<
Expand Down
Loading

0 comments on commit dba8938

Please sign in to comment.