rules_spm
rules_spm copied to clipboard
Handle project that uses rules_spm and one of its dependencies also uses rules_spm
Project A - Has dep on a package (e.g. swift-nio). Project B - Has dep on Project A and a package that Project A uses as a dep (e.g. swift-nio)
Problem:
- If
spm_repositories
for Project A and B have the same name, we will get a duplicate declaration. - If
spm_repositories
for Project A and B have the same names, we will get duplicate symbol errors during compile/linking
Options:
- Require that Project A provides a
Package.swift
; Project B would usespm_repositories
to use the dependency. - Rework
rules_spm
deps logic;
- Each project that uses
rules_spm
would provide their package info (i.e., deps and platforms) via function. - The root project would collect all of the package info for all of the deps (and deps of deps) and pass it to
spm_repositories
.
Option 1 Thoughts
- Biggest benefit: SPM figures it all out; it already handles all of the dep merging mechanics
- We could provide a build rule to generate a
Package.swift
; it could be copied to source using rules_updatesrc. - Non-Bazel projects can consume the project
- Biggest downside: Can't treat the dep repository as a Bazel repo (i.e., can't use
local_repository
)- Note:
spm_pkg
does support local packages. So, this may not be a big deal.
- Note:
Option 2 Thoughts:
- Biggest benefit: Can treat dep repository as a Bazel repo
- Biggest downside: Need to rework package declarations
- Each project that uses
rules_spm
would implement a function that returns their package info (deps and platforms)
- Each project that uses