You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
command plugins: Inherit SwiftPM's --configuration flag in packageManager.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.
0 commit comments