Skip to content

[6.2] Fixes a few issues with swift package {migrate, add-setting} commands #8812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 12, 2025

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jun 12, 2025

Cherry-pick of #8800, #8806

Motivation:

Fixes for the following problems:

  • Sometimes if the previous build was unsuccessful subsequent swift package migrate invocation fails with error: did not compute a build plan yet.
  • Implicitly generated targets (currently only test targets) are included in migration which results in extraneous warnings and failures (i.e. to update the manifest).

The inconsistency in argument formatting came up as part of SE-0486 review. This is the first step in a direction to make command formatting more consistent.

  • swift package migrate:

    • Rename --targets to --target
    • Change --target and --to-feature to accept space separated argument lists
  • swift package -add-setting:

    • Switch to .upToNextOption formatting. Instead of --swift A=B --swift C=D switch to --swift A=B C=D.

Modifications:

  • Update Migrate command's createBuildSystem API to avoid build manifest caching. That ensures that features in migration mode are never persistent and requires a fresh build plan which avoid issues with previous builds.
  • Make it possible to mark a Module as implicit i.e. when it's a synthesized/discovered test target or a system module.
  • Update Migrate command to filter implicit modules when no targets are specified by the user.
  • Update MigrateOptions to use .upToNextOption for targets and features.
  • Update SwiftPackageCommand's _swiftSettings option to use .upToNextOption

Result:

swift package migrate is made more stable with fewer unactionable warnings and errors and the command line is now shorter and has consistent formatting.

Resolves: rdar://152687586
Resolves: rdar://152689053
Resolves: rdar://152687084

xedin added 5 commits June 12, 2025 08:46
- Rename `--targets` to `--target`
- Change `--target` and `--to-feature` to accept space separated argument lists
Instead of `--swift A=B --swift C=D` switch to `--swift A=B C=D`
to make the command shorter and consistent with `migrate` and
in the future other commands.
…ature flags

The build system requested by the `swift package migrate` command is
transitory and shouldn't be persisted. This would also make sure that
the build plan is always available regardless of what builds happened
before `swift package migrate` invocation.

Resolves: rdar://152687084
It's currently impossible to distringuish between modules that
are created from the declarations in a manifest and the ones
synthesized as part of module graph building and/or build plan
creation. This was only a problem for `SystemLibraryModule` before,
but with the introduction of `swift package migrate` command the
situation changed because the command can only operate on modules
that appear in the manifest file because it won't be possible to
update code or settings of the synthesized modules.
Fixes and setting updates to such modules cannot be applied.

Resolves: rdar://152689053
@xedin
Copy link
Contributor Author

xedin commented Jun 12, 2025

@swift-ci please test

@xedin xedin merged commit 9bbf042 into swiftlang:release/6.2 Jun 12, 2025
6 checks passed
dschaefer2 pushed a commit that referenced this pull request Jun 14, 2025
…aries (#8825)

Cherry-pick of
#8824

---

- Explanation:

The original check was about system libraries only, the new one filters
all of the implicit modules (including snippets) which is incorrect. The
is a follow-up to
#8812

- Main Branch PR:
#8824

- Risk: Low

- Reviewed By: @bnbarham 

- Testing: No testing was added, speculative fix.

(cherry picked from commit 68d07f2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants