Skip to content

Adding a js backend using the ocaml backend with js_of_ocaml #994

Open
Arnaud-Bihan wants to merge 61 commits intoCatalaLang:masterfrom
functori:arnaud@functori@functional-jsoo
Open

Adding a js backend using the ocaml backend with js_of_ocaml #994
Arnaud-Bihan wants to merge 61 commits intoCatalaLang:masterfrom
functori:arnaud@functori@functional-jsoo

Conversation

@Arnaud-Bihan
Copy link
Copy Markdown
Contributor

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:

@denismerigoux denismerigoux requested a review from AltGr March 27, 2026 13:14
@denismerigoux denismerigoux added ✨ enhancement New feature or request 🔧 compiler Issue concerns the compiler 🔚 backends Backend runtime or code generation labels Mar 27, 2026
@Arnaud-Bihan Arnaud-Bihan force-pushed the arnaud@functori@functional-jsoo branch 2 times, most recently from 2a549dc to 12b793f Compare April 21, 2026 14:54
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.
maxtori and others added 29 commits April 23, 2026 17:39
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
…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
@Arnaud-Bihan Arnaud-Bihan force-pushed the arnaud@functori@functional-jsoo branch from 12b793f to a121a7c Compare April 23, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔚 backends Backend runtime or code generation 🔧 compiler Issue concerns the compiler ✨ enhancement New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants