swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.73k stars 1.34k forks source link

Target with plugin but no Swift source files is never built, has spurious warning #8061

Open DougGregor opened 9 hours ago

DougGregor commented 9 hours ago

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

Description

I have a SwiftPM target that applies a build tool plugin to generate some Swift sources. It correctly lists the .swift files that it generates in its output list. If there are no ".swift" files in the target before the plugin runs, I get a warning like this:

warning: 'swift-java-deps': Source files for target JavaMath should be located under 'Sources/JavaMath', 'Sources', or a custom sources path can be set with the 'path' property in Package.swift

and the target itself is never built.

Expected behavior

The fact that the build tool plugin is attached to the target and promises to produce ".swift" files should be sufficient to (1) suppress the warning, and (2) cause the target to get built.

Actual behavior

The warning I've mentioned. Additionally, the build tool plugin never runs, and nothing is built for this target. It is completely skipped.

Steps to reproduce

  1. git clone https://github.com/DougGregor/swift-java-deps/tree/no-source-files
  2. git checkout no-source-files
  3. swift build

Swift Package Manager version/commit hash

6.0

Swift & OS version (output of swift --version ; uname -a)

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx15.0
rauhul commented 7 hours ago

I also hit this with the svd2swift plugin, my workaround is an empty.swift file: https://github.com/apple/swift-embedded-examples/blob/main/pico2-neopixel/Sources/RP2350/Empty.swift