Generate jsoo library archive rules on demand#13611
Conversation
|
@hhugo Can you have a look? |
2a3f09b to
3dc97cc
Compare
|
Looks promising, should we move all cm{a,o}.js artifacts under a Do you think we should change both rules generation logic AND the separate compilation granularity in the same PR ? Could we move the incremental generation of cma.js files to a smaller sub PR ? |
|
You should explain in the PR description where we're going with this, where we move config details out of dune into jsoo. |
a74caa3 to
98f3d34
Compare
Move js_of_ocaml library archive rule generation (*.cma.js) out of Lib_rules.setup_build_archives and into a new Jsoo_archive_rules module that generates rules lazily, only for the specific configuration actually requested. Previously, building a library eagerly generated archive rules for every jsoo configuration variant. Now, jsoo archive directories (`.foo.objs/jsoo/<config>`) are intercepted in gen_rules and the rules are produced on demand via dedicated memos. To support this, Lib_rules.compile_context is exposed so that Jsoo_archive_rules can obtain a Compilation_context.t without triggering full library rule generation. Internally, compile_context and rules share an intermediate helper (compile_context_data) that computes lib_id, compile_info, modes, source_modules, and parameters once, while keeping cctx creation inside with_lib_deps in rules to preserve the merlin prefix on generated rules. Signed-off-by: Jérôme Vouillon <jerome.vouillon@gmail.com>
98f3d34 to
2c7c47e
Compare
I guess we could but we don't really need that.
I'm going to split this PR in two. |
Dune had to know about all possible Jsoo config to create rules upfront. This is no longer necessary with ocaml#13611.
My hunch is that it could make the code a bit clearer by having a single place for compilation of cm* files and be less surprising when looking at the _build directory, but it's a weak preference |
Dune had to know about all possible Jsoo config to create rules upfront. This is no longer necessary with ocaml#13611. Signed-off-by: Jérôme Vouillon <jerome.vouillon@gmail.com>
I looked a this a bit more, I'm no longer sure it makes the code clearer. |
|
Maybe add a test that would exhibit the effect of the PR ? |
I'm not sure what I can do. |
Dune had to know about all possible Jsoo config to create rules upfront. This is no longer necessary with ocaml#13611. Signed-off-by: Jérôme Vouillon <jerome.vouillon@gmail.com>
Dune had to know about all possible Jsoo config to create rules upfront. This is no longer necessary with ocaml#13611. Signed-off-by: Jérôme Vouillon <jerome.vouillon@gmail.com>
Dune had to know about all possible Jsoo config to create rules upfront. This is no longer necessary with ocaml#13611. Signed-off-by: Jérôme Vouillon <jerome.vouillon@gmail.com>
Refactor jsoo archive generation to use a demand-driven approach. Previously, rules for all configuration variants were generated upfront whenever a library was built. This logic is now decoupled from general library rules; instead, the build system intercepts requests for specific configuration directories and generates the necessary rules dynamically.
This will enable the following improvements: