From c964495c59b55313123512bb9c1786ec1da9bce7 Mon Sep 17 00:00:00 2001 From: Louis Gesbert Date: Mon, 1 Aug 2022 19:29:34 +0200 Subject: [PATCH] Generate website assets through dune --- Makefile | 31 ++++++++++++++++--------------- compiler/surface/dune | 5 +++++ dune | 14 ++++++++++++-- french_law/dune | 2 +- french_law/js/dune | 4 ++++ generate_website_assets.sh | 4 ++-- runtimes/dune | 2 -- 7 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 french_law/js/dune diff --git a/Makefile b/Makefile index 27da3401..a2cfe1bf 100644 --- a/Makefile +++ b/Makefile @@ -247,9 +247,8 @@ run_french_law_library_benchmark_js: build_french_law_library_js $(MAKE) -C $(FRENCH_LAW_JS_LIB_DIR) bench #> build_french_law_library_js : Builds the JS version of the OCaml French law library -build_french_law_library_js: generate_french_law_library_ocaml format - dune build $(FRENCH_LAW_OCAML_LIB_DIR)/api_web.bc.js - cp -f $(ROOT_DIR)/_build/default/$(FRENCH_LAW_OCAML_LIB_DIR)/api_web.bc.js $(FRENCH_LAW_JS_LIB_DIR)/french_law.js +build_french_law_library_js: + dune build $(FRENCH_LAW_JS_LIB_DIR)/french_law.js #> build_french_law_library_web_api : Builds the web API of the French law library build_french_law_library_web_api: build_french_law_library_js generate_french_law_json_schemas @@ -335,14 +334,14 @@ tests/%: .FORCE # Website assets ########################################## -grammar.html: $(COMPILER_DIR)/surface/parser.mly - obelisk html -o $@ $< +WEBSITE_ASSETS = grammar.html catala.html -catala.html: $(COMPILER_DIR)/utils/cli.ml - dune exec $(COMPILER_DIR)/catala.exe -- --help=groff | groff -P -l -P -r -mandoc -Thtml > $@ +$(addprefix _build/default/,$(WEBSITE_ASSETS)): + dune build $@ #> website-assets : Builds all the assets necessary for the Catala website -website-assets: js_build literate_examples grammar.html catala.html build_french_law_library_web_api doc +website-assets: js_build literate_examples build_french_law_library_web_api doc + dune build $(WEBSITE_ASSETS) ########################################## # Misceallenous @@ -387,10 +386,12 @@ help_catala: ########################################## # Special targets ########################################## -.PHONY: inspect clean all literate_examples english allocations_familiales \ - pygments install build_dev build doc format dependencies \ - dependencies-ocaml catala.html help parser-messages plugins \ - generate_french_law_json_schemas generate_french_law_library_python \ - generate_french_law_library_ocaml \ - run_french_law_library_benchmark_python \ - run_french_law_library_benchmark_js run_french_law_library_ocaml_tests +.PHONY: inspect clean all literate_examples english allocations_familiales \ + pygments install build_dev build doc format dependencies \ + dependencies-ocaml catala.html help parser-messages plugins \ + generate_french_law_json_schemas generate_french_law_library_python \ + generate_french_law_library_ocaml \ + run_french_law_library_benchmark_python \ + run_french_law_library_benchmark_js run_french_law_library_ocaml_tests \ + build_french_law_library_js build_french_law_library_web_api \ + build_french_law_library_ocaml diff --git a/compiler/surface/dune b/compiler/surface/dune index 9c5d3a5d..946f9298 100644 --- a/compiler/surface/dune +++ b/compiler/surface/dune @@ -38,6 +38,11 @@ (merge_into parser) (flags --external-tokens Tokens --table --explain)) +(rule + (target grammar.html) + (action + (run obelisk html -o %{target} %{dep:parser.mly}))) + (documentation (package catala) (mld_files surface)) diff --git a/dune b/dune index 138297b1..001e5356 100644 --- a/dune +++ b/dune @@ -2,13 +2,23 @@ (data_only_dirs tests syntax_highlighting) +(copy_files compiler/surface/grammar.html) + +(rule + (action + (with-stdout-to + catala.html + (pipe-stdout + (run catala --help=groff) + (run groff -P -l -P -r -mandoc -Thtml))))) + (alias (name exec) (deps compiler/catala.exe build_system/clerk.exe)) (rule (alias runtest) - (package clerk) + (package catala) (deps (source_tree tests)) (action @@ -16,7 +26,7 @@ (rule (alias runtest) - (package clerk) + (package catala) (deps (source_tree examples)) (action diff --git a/french_law/dune b/french_law/dune index e61b0a6c..7fe4a9dc 100644 --- a/french_law/dune +++ b/french_law/dune @@ -1 +1 @@ -(dirs ocaml) +(dirs js ocaml) diff --git a/french_law/js/dune b/french_law/js/dune new file mode 100644 index 00000000..68715f30 --- /dev/null +++ b/french_law/js/dune @@ -0,0 +1,4 @@ +(rule + (mode promote) + (action + (copy ../ocaml/api_web.bc.js french_law.js))) diff --git a/generate_website_assets.sh b/generate_website_assets.sh index 6b30aa8d..ab632a99 100755 --- a/generate_website_assets.sh +++ b/generate_website_assets.sh @@ -21,8 +21,8 @@ rsync $BUILD/examples/us_tax_code/us_tax_code.html $1/ rsync $BUILD/examples/tutorial_en/tutorial_en.html $1/ rsync $BUILD/examples/tutoriel_fr/tutoriel_fr.html $1/ -rsync grammar.html $1/ -rsync catala.html $1/ +rsync $BUILD/grammar.html $1/ +rsync $BUILD/catala.html $1/ rsync $BUILD/french_law/js/french_law.js $1/french_law.js rsync $BUILD/examples/allocations_familiales/allocations_familiales_schema.json $1/ diff --git a/runtimes/dune b/runtimes/dune index cf7745a1..4c37f5e7 100644 --- a/runtimes/dune +++ b/runtimes/dune @@ -1,4 +1,2 @@ -(dirs jsoo ocaml) - (documentation (package catala))