Skip to content

Conversation

@anmonteiro
Copy link
Collaborator

depends on #12530

@anmonteiro anmonteiro added the melange Melange rules and generator label Oct 5, 2025
Copy link
Member

@rgrinberg rgrinberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bug fix is a bug fix.

Dep_rules.deps_of
~obj_dir
~modules
~sandbox:Sandbox_config.default
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit sucky to generate all these rules just to drop them. It would be better to factor out deps_of in a way so that we don't have to do that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you suggest doing here? I don't fully understand what rules are being generated.

Happy to do it in a follow-up PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually it sounds like we'll have to do it here anyway. my current plan is to thread the rules as a return value of build_js back to gen_rules

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you suggest doing here? I don't fully understand what rules are being generated.

Sure, I can clarify. I'm suggesting an almost mechanical transformation that is equivalent to what this PR is doing:

  1. Take deps_of and copy paste it to a new function
  2. In this new function, identify all the calls to add_rule and delete them
  3. For all the functions being called in your new deps_of, identify the ones with add_rule and repeat step 1.
  4. Once this process is done and you have deps_of that creates no rules, rename the original function to be gen_deps_of_rules
  5. Factor out all the copy pasting.

Hopefully the end result will give us two functions that share as much work as possible.

my current plan is to thread the rules as a return value of build_js back to gen_rules

That's possible as well, but there's a reason why we avoid doing this when possible. It leads to a massive amount of boilerplate managing this list of rules at every step.

@anmonteiro anmonteiro force-pushed the anmonteiro/melange-include-qualified-emit branch 2 times, most recently from 32f6b02 to 157af85 Compare October 13, 2025 06:21
@anmonteiro anmonteiro force-pushed the anmonteiro/melange-include-qualified-emit branch from 157af85 to ce1385b Compare October 13, 2025 06:47
@anmonteiro anmonteiro merged commit eb16a86 into ocaml:main Oct 13, 2025
25 of 26 checks passed
@anmonteiro anmonteiro deleted the anmonteiro/melange-include-qualified-emit branch October 13, 2025 07:10
Sudha247 pushed a commit to Sudha247/dune that referenced this pull request Oct 13, 2025
davesnx added a commit to davesnx/dune that referenced this pull request Oct 14, 2025
* 'main' of github.com:/ocaml/dune: (147 commits)
  cram test: test only parameter flags in merlin generation
  fix(oxcaml): import eta-expansion changes from opam-repo (ocaml#12563)
  address review comments
  Mask the path to the stdlib
  fix(oxcaml): generate merlin config for library parameters
  fix(melange + include_qualified): track correct `.cmj` dependencies in emit (ocaml#12531)
  refactor: remove some unused code in [Path] (ocaml#12558)
  dep_rules: don't run (transitive) `ocamldep` on single module buildables (ocaml#12555)
  fix(pkg): ignore project settings for building packages
  test(pkg): reproduce ocaml#12131
  melange: add a test for module cycle checks (ocaml#12554)
  chore: lint check for new changes entries (ocaml#12553)
  feature(cram): allow for conflict detection (ocaml#12538)
  ci: update for ocaml 5.4 release (ocaml#12552)
  chore(script): generate changelog from structure (ocaml#12516)
  Reuse dependencies between project and tools (ocaml#12526)
  Introduce Io.overwrite_file
  test: fix dune install requiring a mandir
  Enable package management for more tests
  Add a `dune tools env` command to add dev tools to PATH (ocaml#12521)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

melange Melange rules and generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants