Skip to content

[Commands] Fixes a few issues with swift package migrate command #8806

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 3 commits into from
Jun 12, 2025

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jun 11, 2025

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).

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.

Result:

swift package migrate is made more stable with fewer unactionable warnings and errors.

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

…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
@xedin
Copy link
Contributor Author

xedin commented Jun 11, 2025

@swift-ci please test

xedin added 2 commits June 11, 2025 16:30
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 11, 2025

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Jun 11, 2025

@swift-ci please test Windows platform

1 similar comment
@xedin
Copy link
Contributor Author

xedin commented Jun 12, 2025

@swift-ci please test Windows platform

@xedin
Copy link
Contributor Author

xedin commented Jun 12, 2025

@swift-ci please test macOS platform

@xedin xedin merged commit ff7ea75 into swiftlang:main Jun 12, 2025
6 checks passed
xedin added a commit that referenced this pull request Jun 12, 2025
…commands (#8812)

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
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