Adding a js backend using the ocaml backend with js_of_ocaml #994
Open
Arnaud-Bihan wants to merge 61 commits intoCatalaLang:masterfrom
Open
Adding a js backend using the ocaml backend with js_of_ocaml #994Arnaud-Bihan wants to merge 61 commits intoCatalaLang:masterfrom
Arnaud-Bihan wants to merge 61 commits intoCatalaLang:masterfrom
Conversation
2a549dc to
12b793f
Compare
The Tests backnds needs the OCaml backend (because it makes call to src@ocaml-module for example). Without the OCaml backends the Tests backends only generates rules that are not correct. It's not a big problem for the typecheck and exceptions command as those rules are never called.
It doesn't change anything as dir_test_rules was returning Seq.empty if the Tests backend was disabled
Move the OCaml-specific Ninja rules (catala-ocaml, ocaml-bytobject, ocaml-natobject, ocaml-module) out of clerk_rules.ml into a new build_system/backend/ocaml.ml module.
Consolidate OCaml compiler flags, executables, and include/link path resolution from clerk_rules.ml and clerk_poll.ml into Ocaml.Flags.
Extract runtime file copying (.ml, .mli, .cmi) and .cmx compilation from clerk_rules.ml into Ocaml.Backend.runtime_build_statements.
Move reusable helpers (target, extern_src, check_missing, modfile) from clerk_rules.ml into build_system/clerk_utils/ninja.ml so individual backends can use them.
Extract external .ml/.mli file handling and missing-file error reporting from clerk_rules.ml into Ocaml.Backend.external_copy.
Extract bytecode/native builds, module packaging, scope test compilation, and catala-ocaml invocation from clerk_rules.ml into Ocaml.Backend.catala and Ocaml.Backend.build_object.
Add build_system/backend/c.ml with C-specific flags, Ninja rules, runtime statements, external copy, catala invocation, and object compilation, following the OCaml backend pattern.
Replace all inline C-specific build code with calls to Clerk_backends.C.Backend.* and remove the now-unused include_flags helper.
Add build_system/backend/python.ml encapsulating Python-specific flags, Ninja rules, runtime statements, external copy, and catala invocation.
Move the remaining inline Python code from clerk_rules.ml (flags, external copy, runtime statements) into the Python backend module.
Propagate the Clerk config options to runtime_build_statements across all backends so they can resolve runtime directories from user-supplied variables.
Add build_system/backend/java.ml with Java-specific Ninja rules, classpath handling, default flags, runtime file discovery, and object build logic.
Extract the remaining inline Java build logic from clerk_rules.ml into Java.Backend.runtime_build_statements.
Create backend.ml with a common module signature and replace duplicated .mli definitions with module Backend : Backend.S across all four backends.
Nest the Flags sub-module under Backend and add it to the shared Backend.S type, making the flag interface uniform across all backends.
Replace per-backend if/else blocks for module aliases with a generic loop over enabled_backends using name and module_extension helpers.
Unify all if List.mem <backend> blocks in clerk_rules.ml into backend-agnostic List.map/List.concat_map calls that dispatch through the Backend.S interface.
This will be useful for jsoo backend as external files are quite particular for this backend
As jsoo is a special backend, it needs more tha just a rule to build sources and a rules to build object. So instead of doing a specific function for jsoo, we add a new function extra_rules. We give that function parameter that feels enough to do a lot of things the whold stdlib/project tree and the targeted modules
…ependency to js_of_ocaml
…eparetly Also remove the external list as we're dealing with the item list we don't need to have that list in this function. All those fix makes extra_rules more generic and less specialized for the jsoo backend
12b793f to
a121a7c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
If this PR adds a feature or has breaking changes
If this PR contains syntax changes
I confirm that have have checked and updated each of the following items if this PR impacts them:
doc/syntax/syntax_*.catala_*anddoc/syntax/catala_*.typ.syntax_highlighting/(all of them).tree-sittergrammar: