-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Commands] Initial implementation of swift package add-setting
command
#8532
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
Conversation
|
||
switch setting { | ||
case .experimentalFeature: | ||
editResult = try AddSwiftSetting.experimentalFeature( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the user adds the same setting a second time? And if that setting has a different value than the already added setting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compiler would take the last value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some work in #8534 to make add-dependency idempotent if possible. Doing the same sort of thing here is less important here since adding the same setting twice wont result in a package that wont build, but could be worth looking at just to keep the resulting settings collections free of dupes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I looked into that while working on that and without some support from swift-syntax to match the nodes in general we won't be able to do match...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would we be able, at a minimum, to inform the user of the duplicate, and different settings? If this is the case, is there value in prompting the user which value they want to use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't do that because it would lead to false positive warnings since we cannot really figure out what is what so if they have the setting with different conditions we'll just keep warning about it for no reason.
093ac2f
to
5d2bdf2
Compare
@swift-ci please test |
5d2bdf2
to
2a109f8
Compare
Re-organized imports a bit to avoid imported what we don't need here. |
@swift-ci please test |
2a109f8
to
44ed477
Compare
@swift-ci please test |
Add a way to programmatically insert new settings into a package manifest. Currently only some Swift settings are supported, namely: `enable{Upcoming, Experimental}Feature`, `swiftLanguageMode` and `strictMemorySafety`; but the command could be expanded to support more Swift (C, C++, linker) settings in the future.
44ed477
to
eccff82
Compare
@swift-ci please test |
@swift-ci please test Windows platform |
…and (swiftlang#8532) ### Motivation: Adds a way to programmatically insert new settings into a package manifest. Currently only some Swift settings are supported, namely: `enable{Upcoming, Experimental}Feature`, `swiftLanguageMode` and `strictMemorySafety`; but the command could be expanded to support more Swift (C, C++, linker) settings in the future. ### Modifications: - Add a new "package" sub-command named "add-setting" that accepts a target and a list of `--swift Name[=Value]?` pairs for each new swift setting to add. Each setting would make sure that manifest is new enough to support it. - Add new manifest refactoring action - AddSwiftSetting that would add `swiftSettings:` to a target or modify the existing one. - Expands existing way to check whether manifest is too old to support custom versions. This is doe to make sure that users don't add settings that are not supported by the manifest tools version i.e. `swiftLanguageMode` was introduced in 6.0 tools. ### Result: A new `swift package add-setting --target <name> [--swift Name[=Value]?]+` command that allows users to programmatically add new settings to package manifests.
Motivation:
Adds a way to programmatically insert new settings into a package manifest.
Currently only some Swift settings are supported, namely:
enable{Upcoming, Experimental}Feature
,swiftLanguageMode
andstrictMemorySafety
; but the command could be expanded to support more Swift (C, C++, linker) settings in the future.Modifications:
--swift Name[=Value]?
pairs for each new swift setting to add. Each setting would make sure that manifest is new enough to support it.swiftSettings:
to a target or modify the existing one.swiftLanguageMode
was introduced in 6.0 tools.Result:
A new
swift package add-setting --target <name> [--swift Name[=Value]?]+
command that allows users to programmatically add new settings to package manifests.