Allow overriding the output path for compile and compile-impl#1462
Open
jonludlam wants to merge 8 commits into
Open
Allow overriding the output path for compile and compile-impl#1462jonludlam wants to merge 8 commits into
jonludlam wants to merge 8 commits into
Conversation
read_libraries_from_pkg_defs only looked up the archive under the [byte]/[native] predicates. ppx derivers such as ppxlib.traverse and ppxlib.metaquot declare their archive only under the ppx_driver predicate, so they were dropped here and later re-discovered by the no-META fallback, which names a library after its .cma file (e.g. ppxlib_traverse instead of ppxlib.traverse). Also try the [byte; ppx_driver] and [native; ppx_driver] predicates, mirroring Ocamlfind.archives which the non-voodoo driver already uses. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Previously the include set passed to `odoc compile`/`compile-impl` was derived from the compiled library's whole dependency set (every library it requires). That implies doing the transitive closure over all libraries' dependencies. In voodoo mode, we only have the META files for the package being documented, so this isn't possible. Instead, derive the include set from the unit's actual per-module dependencies. Each dependency carries the interface hash of the module it refers to; look that hash up among the units being compiled plus the partials of already-compiled dependencies, and take the directory of the providing unit. This is more precise (far fewer `-I` flags) and doesn't depend on META completeness. Applies to both interfaces and implementations; `impl_extra` now carries the implementation's dependency list. In the non-voodoo driver, where the library-level set was already complete, source-link output is byte-for-byte identical. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Compute the link phase's -I search path per library -- the union of its units' dependency cones, the same directories the compiler used -- rather than a package-wide set. -L and -P remain package-wide and unvarying (the reference scope). Because a library's -I holds only its own cone, alternative implementations of a virtual library never share a search path, so no sibling-exclusion special-case is needed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Document, in driver.mld and the author-facing odoc_for_authors.mld, the reference-scope convention for opam-installed packages: the per-package -P/-L reference scope, the per-unit -I include path, and the odoc-config.sexp stanzas. Also capture the broader driver guidance learned from building the odd driver -- the compile/link include model, virtual-library handling, and what a driver should compile.
Previously 'odoc compile' silently ignored -o when --parent-id was passed, and --output-dir was mandatory alongside --parent-id. Now -o takes precedence over the path computed from --parent-id and --output-dir, and --output-dir may be omitted when -o is given. The identifier is still derived from --parent-id and the output basename. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mirrors the same change to 'odoc compile': -o now takes precedence over the path computed from --parent-id and --output-dir (which becomes optional), so drivers can place impl .odoc files freely, e.g. next to the interface .odoc in an object directory. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Before this commit, we were very strict about where the output of
odoc compileandodoc compile-implwent, as it's very important to ensure that we can specify paths correctly for-L. However, with the idea of putting the odoc files into the switch, we can relax this somewhat, on the basis that if the output files go alongside the cmis, then we're inheriting exactly the same path-based resolution that the compiler has, and if it's good enough for the compiler, it should be good enough for us!This is on top of the driver changes commits.