-
Notifications
You must be signed in to change notification settings - Fork 1.4k
command plugins: Inherit SwiftPM's --configuration flag in packageManager.build #7262
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
command plugins: Inherit SwiftPM's --configuration flag in packageManager.build #7262
Conversation
Please let me know if I missed an existing way to do this. |
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.
This is great, thanks!
@swift-ci test |
One of the tests is failing with this error:
|
63ea6a6
to
7b6e99f
Compare
Thanks, I missed these in a rebase. :( |
@swift-ci test |
@swift-ci test windows |
@swift-ci test linux |
@MaxDesiatov It looks like the Linux smoke test might have hit swiftlang/sourcekit-lsp#1025
Could you please trigger the test run again? I've rebased on |
…ager.build This commit makes it possible for a build run on behalf of a command plugin to inherit the build configuration (debug or release) set for the whole `swift package` run using the `--configuration` flag. ### Motivation: When a command plugin asks for a target to be built by calling packageManager.build, it must specify a release or debug build. If no configuration is given, debug is the default. This overrides any configuration specified by the user with `swift package -c <debug|release>`. A command plugin might often be used as an alterative entry point to Swift PM, responsible for building a target and then processing it in some way to generate the final product. The user might run `swift package -c release some-plugin --target some-target`, expecting a release build of target to be made, but currently the result will be a debug binary if the plugin uses the default options. ### Modifications: * Added a new `.inherit` option for packageManager.build's `configuration` argument.; .debug remains the default, as before. * Added a test to verify that plugin-initiated builds are of the correct type. ### Result: A command plugin can request a target build matching the configuration specified on the SwiftPM command line. The default is still to make a debug build, however in future we might change this to inherit the overall SwiftPM configuration. ### Alternatives: A command plugin does not currently seem to have access to SwiftPM's build configuration. We could pass this information to the plugin, allowing the plugin author to pass it back in the packageManager.build() call. This would be a less invasive change to SwiftPM, however the approach in this commit makes it easier to change the default to .inherit in the future.
7b6e99f
to
8656b7c
Compare
@swift-ci test |
@swift-ci test windows |
This commit makes it possible for a build run on behalf of a command plugin to inherit the build configuration (debug or release) set for the whole
swift package
run using the--configuration
flag.Motivation:
When a command plugin asks for a target to be built by calling
packageManager.build
, it must specify a release or debug build. If no configuration is given, debug is the default. This overrides any configuration specified by the user withswift package -c <debug|release>
.A command plugin might often be used as an alterative entry point to Swift PM, responsible for building a target and then processing it in some way to generate the final product. The user might run
swift package -c release some-plugin --target some-target
, expecting a release build of target to be made, but currently the result will be a debug binary if the plugin uses the default options.Modifications:
.inherit
option for packageManager.build'sconfiguration
argument.;.debug
remains the default, as before.Result:
A command plugin can request a target build matching the configuration specified on the SwiftPM command line. The default is still to make a debug build, however in future we might change this to inherit the overall SwiftPM configuration.
Alternatives:
A command plugin does not currently seem to have access to SwiftPM's build configuration. We could pass this information to the plugin, allowing the plugin author to pass it back in the
packageManager.build
call. This would be a less invasive change to SwiftPM, however the approach in this commit makes it easier to change the default to.inherit
in the future.