Repository navigation
Design: Support rules_swift_package_manager usage in non-root modules #1977
luispadron
started this conversation in
Ideas
Replies: 2 comments
Can you elaborate on this goal? I don't follow. |
0 replies
|
@luispadron Thank you for taking on this effort! |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
Depending on non-root bzlmod modules that use
rules_spm/rules_swift_package_managercurrently causes collisions when multiple modules declare the sameswiftpkg_*repositories. This blocks transitive composition and prevents SwiftPM-style single-version resolution across modules.Goals
swiftpkg_*collisions by generating each resolved package repo exactly once.extension_metadatafor resolution persistence; keepPackage.resolvedas an optional/debug fallback.Non-goals (initial)
Package.swiftlayout beyond what rules already require.Approach: merge by aggregating package roots (not dependency lists)
Instead of merging dependency requirements from each module, the extension merges package roots.
For each participating bzlmod module
M, the extension locates a SwiftPM package root directory:pkg_root(M)contains aPackage.swift.The extension then synthesizes a single "merged"
Package.swiftthat depends on each root via.package(path:). SwiftPM reads the dependency constraints from each local root’s manifest and computes a unified solution.Why this works
Inputs
Per module
Mparticipating in the extension:pkg_root(M): path to a directory containingPackage.swift.origin(M): metadata used for diagnostics (module name/version, repo label).Generated artifacts
The extension creates a single resolver repository (e.g.
@rules_spm_resolver) containing:Merged manifest:
Package.swift.package(path:).Resolution representation
extension_metadatastores the resolved mapping:identity -> {source_url, version|revision, checksum/digest (if applicable)}Package.resolved(configurable), primarily for troubleshooting.Merged
Package.swiftshapeDeterministic ordering and minimal structure:
Example of a "merged" package:
All reactions