rules_spm icon indicating copy to clipboard operation
rules_spm copied to clipboard

Handle project that uses rules_spm and one of its dependencies also uses rules_spm

Open cgrindel opened this issue 2 years ago • 0 comments

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:

  1. If spm_repositories for Project A and B have the same name, we will get a duplicate declaration.
  2. If spm_repositories for Project A and B have the same names, we will get duplicate symbol errors during compile/linking

Options:

  1. Require that Project A provides a Package.swift; Project B would use spm_repositories to use the dependency.
  2. 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.

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)

cgrindel avatar Oct 27 '21 22:10 cgrindel