[6.4] Emit warning for unhandled files in SwiftBuild; Avoid unnecessary network requests#10143
Open
bripeticca wants to merge 2 commits into
Open
[6.4] Emit warning for unhandled files in SwiftBuild; Avoid unnecessary network requests#10143bripeticca wants to merge 2 commits into
bripeticca wants to merge 2 commits into
Conversation
…when using `--force-resolved-versions` (swiftlang#10140) This change modifies the behaviour of attempting to resolve using the `Package.resolved` file as a lock file, wherein the user passes the `--force-resolved-versions` flag with the possibility of a fully populated `.build/checkouts` cache to avoid making any network requests. ### Motivation: For workspaces that have just been fully resolved with an updated checkouts cache and workspace state, it is unnecessary to make network requests; if a project has migrated environments (such as pushing a project to a container for CI) where network connection is either limited (perhaps there are private or enterprise repositories used) or disallowed, SwiftPM should first try to operate off of the local state entirely by verifying the existence of the package checkouts, and only if the state is stale should it attempt to make a network request. ### Modifications: In `tryResolveBasedOnResolvedVersionsFile`, first check the managed dependencies state against each pinned package version present in the `Package.resolved`. If package dependencies exist that don't align with the current workspace state, then it will be added to a list of packages to be fetched. ### Result: Unnecessary network requests will no longer be made, allowing for full local resolution if the .build directory is in a good state and a Package.resolved exists.
Original PR: swiftlang#9532 by @pepicrft Taken over so as to get through CI + address PR comments. Original PR comment: When building with the native build system, SwiftPM emits a warning if there are files in a target's source directory that aren't being handled - they're not Swift sources, not declared as resources, and not explicitly excluded. This is helpful for catching forgotten files or misconfigurations. However, when using SwiftBuild, this warning was silently skipped, which could lead to confusion when switching between build systems. I traced the issue to PIFBuilder.swift, which generates the PIF representation for SwiftBuild but was missing the diagnostic check that BuildOperation.swift performs for the native build system. The fix adds a diagnoseUnhandledFiles method to PIFBuilder that mirrors the native implementation - it runs after plugin invocation, checks for files in module.underlying.others that weren't handled by any build tool plugins, and emits the same warning with proper metadata. I also updated the existing test in PluginTests.swift that was marked as a known issue for SwiftBuild (referencing this exact issue swiftlang#8786) to remove that condition since the fix resolves it. Fixes swiftlang#8786 --------- Co-authored-by: Pedro Piñera <pedro@pepicrft.me> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
Author
|
@swift-ci test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picks of #10132, #10140