Open tishin opened 1 year ago
Probably same issue as https://github.com/apple/swift-package-manager/issues/6859
The prebuild command issue is odd, but probably also related to incorrect treatment of .exe
, so that
if builtToolNames.contains(executable.basename)
ends up not being true on Windows, bypassing the diagnostic. If you're not doing clean builds, prebuild commands will be able to use built products from previous iteration, so maybe that's why it was working.
Description
I have a trivial setup of a package at tishin/BuildCommandIssue -
Generator
target generates a source file -GeneratorPlugin
plugin emits abuildCommand
to executeGenerator
-Consumer
target uses the result of the code generationBuilding this package on Windows fails since Generator.exe doesn't get executed during the build:
What's weird is that I managed to work around this issue by using
prebuildCommand
instead ofbuildCommand
: tishin/BuildCommandIssue#1 Which I think I was not even supposed to use like that, since on macOS I get the following error trying to useprebuildCommand
-based setup:a prebuild command cannot use executables built from source, including executable target 'Generator'
But on WindowsprebuildCommand
works perfectly fine, and building succeeds.If I put a
fatalError
in the beginning ofGenerator
, I see the exception when usingprebuildCommand
on Windows. But withbuildCommand
it does not fail with the error I put, it just fails not being able to find the source file expected to be generated by the plugin. Which means that the executable is not being called at all.I've found a couple of similar issues here, but both #6859 and #6851 go deep into
Path
-related issues, and I don't think it has anything to do with paths in my case sinceprebuildCommand
works fine as is.Expected behavior
Generator.exe
gets executed during build as abuildCommand
buildCommand
andprebuildCommand
Actual behavior
Generator
is being ignored asbuildCommand
, wokrs fine asprebuildCommand
Steps to reproduce
swift build
Swift Package Manager version/commit hash
5.9 release
Swift & OS version (output of
swift --version ; uname -a
)compnerd.org Swift version 5.9 (swift-5.9-RELEASE) Target: x86_64-unknown-windows-msvc OS Version: 10.0.19045 N/A Build 19045