-
Notifications
You must be signed in to change notification settings - Fork 1.4k
SwiftPM does not build all dependency executables before invoking plugin build command #5636
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
SwiftPM does not build all dependency executables before invoking plugin build command #5636
Conversation
@swift-ci please smoke test |
Looks like there is at least one test to update (because it codified the previous dependency) in addition to adding the new one. |
b16a83a
to
c46337c
Compare
@swift-ci please smoke test |
c46337c
to
d653002
Compare
…gin build command Make the list of input dependencies of an llbuild command that runs a plugin-provided build tool also have dependencies on the paths of all the tools on which the plugin has declared a dependency, not just the one that appears as an executable in the build command. Also adds a mildly elaborate unit test to make sure this works. rdar://93679015
d653002
to
e26c128
Compare
@swift-ci please smoke test |
@@ -395,7 +400,7 @@ extension PackageGraph { | |||
arguments: arguments, | |||
environment: environment, | |||
workingDirectory: workingDirectory), | |||
inputFiles: inputFiles, | |||
inputFiles: toolPaths + inputFiles, |
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 the key change. Nothing particularly risky or anything that requires extra scrutiny, I think, but it seemed worth calling out amid all the more mundane changes.
…ng plugin build command (swiftlang#5636) Make the list of input dependencies of an llbuild command that runs a plugin-provided build tool also have dependencies on the paths of all the tools on which the plugin has declared a dependency, not just the one that appears as an executable in the build command. Also adds a mildly elaborate unit test to make sure this works. rdar://93679015 (cherry picked from commit a6ac80f)
…ng plugin build command (#5636) (#5642) Make the list of input dependencies of an llbuild command that runs a plugin-provided build tool also have dependencies on the paths of all the tools on which the plugin has declared a dependency, not just the one that appears as an executable in the build command. Also adds a mildly elaborate unit test to make sure this works. rdar://93679015 (cherry picked from commit a6ac80f)
Background & Motivation
Plugins can specify dependencies on executables. Currently, those executables get built before running build tool commands returned by the plugin if those dependencies were either:
This could potentially be more efficient than building all dependencies, since a plugin could depend on two separate executables and then return commands that only used one or the other of them. This would result in SwiftPM only building the executables that were actually mentioned by build commands.
However: This led to confusion and multiple bug reports of failures resulting from not building the executables before trying to use them. One common case is with SwiftProtobuf, which uses
protoc
as the executable and then a SwiftPM-built executable as one of the parameters toprotoc
. If the plugin didn't explicitly include the code generation executable in the list of input dependencies in the build tools command it returns, the build would fail and it wouldn't be clear why.Changes
Make the list of input dependencies of an llbuild command that runs a plugin-provided build tool include the paths of all the tools on which the plugin has declared a dependency, not just the one that appears as an executable in the build command.
This can cause more command line tools to be built but is less confusing overall since a dependency on an executable by a plugin understandably implies that the executable should be built no matter what.
Note that if the plugin doesn't return any build commands, none of the dependencies need to be built. That behavior is preserved.
Specific Modifications:
Results
The executables declared by a plugin are built before any build command returned by the plugin (though not if the plugin doesn't return any commands, which is a no-op).
Note also that this new behavior of building the executables up-front more closely matches the behavior in Xcode 14.
rdar://93679015