Skip to content

[PackageModel] SwiftTarget: Rename swiftVersion into toolsSwiftVersion #7544

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 2 commits into from
May 10, 2024

Conversation

xedin
Copy link
Contributor

@xedin xedin commented May 9, 2024

Motivation:

The value of this field is computed based on the tools version of the manifest and is intended to be used as a fallback if there is no swift language version specified in the build settings for a swift target.

Modifications:

Renamed SwiftTarget.swiftVersion field and PackageBuilder.swiftVersion() method to toolsSwiftVersion.

Result:

Code better reflects meaning and intended uses of the data.

@@ -129,14 +129,14 @@ public final class SwiftTarget: Target {

override public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.swiftVersion, forKey: .swiftVersion)
try container.encode(self.toolSwiftVersion, forKey: .swiftVersion)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaxDesiatov is it okay to rename case in CodingKeys here? I'm not sure how much do we care about backward compatibility here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still unsure where this Codable conformance is used, maybe @neonichu could clarify? I wonder if this could be used in workspace serialization, but also don't know how easily we can break that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember.

But removing the Encodable conformance from PackageModel.Package (which is the only thing broken by removing the conformance from Target) doesn't seem to break anything, it seems like this is potentially something that's no longer being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do this in a follow up!

@xedin
Copy link
Contributor Author

xedin commented May 9, 2024

I need to change this for SwiftTargetBuildDescription as well!

xedin added 2 commits May 9, 2024 11:41
…sion`

The value of this field is computed based on the tools version
of the manifest and is intended to be used as a fallback if there
is no swift language version specified in the build settings for
a swift target.
@xedin xedin force-pushed the rename-swift-target-swift-version branch from 0dd0d44 to e4f814b Compare May 9, 2024 18:42
@xedin
Copy link
Contributor Author

xedin commented May 9, 2024

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented May 9, 2024

@swift-ci please test Windows platform

@neonichu
Copy link
Contributor

I don't think a simple rename is sufficient to fix the model here.

It seems like #7439 moved the version into build settings, but only for certain declarations. That is fine, but to me implies SwiftTarget.swiftVersion shouldn't exist at all anymore and we would need to include however it is being computed into build settings. Alternatively, SwiftTarget.swiftVersion could reflect what is in build settings, but that doesn't seem easily possible because the per-target setting supports conditionals (aside: is that really intentional, e.g. does .swiftLanguageVersion(.v6, .when(configuration: .debug)) make sense?).

Either way, I don't think it is a good idea to carry forward the degrees of freedom of the package manifest into the resolved model and leave it up to clients to figure out which version to actually use.

(Another aside, #7504 is also broken because of this since I hadn't realized we changed the contract around SwiftTarget.swiftVersion).

@xedin
Copy link
Contributor Author

xedin commented May 10, 2024

I spoke to @neonichu offline and we concluded that it's okay to land this PR as a first step in removal of toolsSwiftVersion completely in favor of handling the fallback in BuildSettings instead which also depends on #7550

@xedin xedin merged commit 3bedafa into swiftlang:main May 10, 2024
5 checks passed
xedin added a commit that referenced this pull request May 16, 2024
- Explanation:

Implementation of SE-0435 proposal.

Add a new Swift target setting API, similar to `enable{Upcoming,
Experimental}Feature`,
to specify a Swift language version that should be used to build the
target, if such
version is not specified, fallback to the current language version
determination logic.

- Scope: TargetDescription API and build system.

- Main Branch PRs:
#7439,
#7544,
#7550,
#7557

- Radar: rdar://125732014

- Risk: Low

- Reviewed By: @MaxDesiatov @bnbarham 

- Testing: Added new test-cases to the test suite.
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