feat(describe): include melange targets in describe workspace - #16300
Open
NatKarmios wants to merge 9 commits into
Open
NatKarmios wants to merge 9 commits into
NatKarmios wants to merge 9 commits into
Conversation
dune describe workspace only describes the OCaml compilation of a workspace: melange.emit stanzas are not described at all, and every library is described once in OCaml mode even when it is only ever built for Melange. Add a cram test recording that behaviour ahead of the fix. It lives under test-cases/melange/ rather than test-cases/describe/ because it needs melc on PATH to resolve Melange libraries. Signed-off-by: Nat Karmios <nat@karmios.com>
Melange.Emit.t is a resolved emit target (where an emit's artifacts live), which is a different type from Melange_stanzas.Emit.t, the parsed melange.emit stanza. Rename the former to remove the ambiguity. Also drop the dead "module Melange = Melange" alias from bin/import.ml; nothing in bin/ referenced it. Signed-off-by: Nat Karmios <nat@karmios.com>
Crawl hardcoded a module-level "let for_ = Compilation_mode.Ocaml" and used it for every library resolution. Make it a parameter of Crawl.executables, Crawl.library and Crawl.workspace so that a later change can crawl in Melange mode. No behaviour change: the sole caller passes Compilation_mode.Ocaml. Signed-off-by: Nat Karmios <nat@karmios.com>
dune describe workspace now emits a "melange.emit" item for each melange.emit stanza, carrying its target, alias, module systems, target directory, library dependencies, modules and include directories. The item is crawled in Melange compilation mode, so its modules and include directories point at the Melange object directories rather than the OCaml ones. Libraries are still described only in OCaml mode; a follow-up adds melange.library items. Signed-off-by: Nat Karmios <nat@karmios.com>
dune describe workspace now crawls libraries in both compilation modes. A library reachable in Melange mode is described by a "melange.library" item, and its uid is salted with the mode so that it does not collide with the OCaml item for the same library. A referrer's requires names the uid of its own mode. Both crawls filter their project libraries by Lib_info.effective_modes, so a Melange-only library is no longer described as an ordinary library item, and an OCaml-only library gains no melange.library item. Signed-off-by: Nat Karmios <nat@karmios.com>
melange.emit and melange.library items reported the OCaml object directories, which are never built for a Melange target: .mobjs/byte and .objs/byte rather than .mobjs/melange and .objs/melange. Obj_dir.all_cmis now takes the compilation mode, resolving the TODO that asked for it, and describe passes the mode down to the cmt and cmti paths of each module. The OCaml output is unchanged. Signed-off-by: Nat Karmios <nat@karmios.com>
NatKarmios
force-pushed
the
describe-workspace-melange
branch
from
September 2, 2026 13:03
ddacc03 to
13aa4c8
Compare
Add changelog fragments for the new melange.emit and melange.library items and for the Melange-only library behaviour change, and note both in the dune describe workspace CLI reference. Signed-off-by: Nat Karmios <nat@karmios.com>
Melange compiles a copy of each source file, made under .melange_src by an internal rule. Describe attributed the copy to that rule, so every module of a melange.emit or melange.library item was reported as generated by the stanza's dune file rather than as the source file the user wrote. Add a copy_of_source origin naming the file a module was copied from, and resolve a module's origin against that file, so a copy of a generated file still reports how it was generated. Signed-off-by: Nat Karmios <nat@karmios.com>
Melange copies every module it compiles, including ones that were themselves generated. Cover a module produced by a rule, whose origin reports that rule rather than copy_of_source, and one produced by ocamllex, whose origin names the .mll file in the source tree rather than the .melange_src copy of the generated .ml. Signed-off-by: Nat Karmios <nat@karmios.com>
NatKarmios
force-pushed
the
describe-workspace-melange
branch
from
September 2, 2026 13:04
13aa4c8 to
5b92f08
Compare
This branch has not been deployed
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.
Description
Include
melange.emititems indune describe workspace.Also report libraries compiled in Melange mode as
melange.libraryitems, in the same form as the existinglibraryitems; if a library is used by both an OCaml and Melange target, then both alibraryandmelange.libraryitem is reported for it.The origin of plain
.mlmodules are reported asCopy_of_source, to associate the true source file with the build-time copy under.melange_src.As a drive-by, resolves a TODO comment in
Obj_dir.all_cmisabout passingmode.Related Issue and Motivation
Fixes #16299
Checklist