diff --git a/Sources/SwiftBuildSupport/PIFBuilder.swift b/Sources/SwiftBuildSupport/PIFBuilder.swift index 6e304910499..5f3fec1a19e 100644 --- a/Sources/SwiftBuildSupport/PIFBuilder.swift +++ b/Sources/SwiftBuildSupport/PIFBuilder.swift @@ -389,6 +389,12 @@ public final class PIFBuilder { observabilityScope: observabilityScope ) + self.diagnoseUnhandledFiles( + package: package, + module: module, + buildToolPluginInvocationResults: buildToolPluginResults + ) + let result = PackagePIFBuilder.BuildToolPluginInvocationResult( prebuildCommandOutputPaths: runResults.flatMap( { $0.derivedFiles }), buildCommands: buildCommands @@ -530,6 +536,42 @@ public final class PIFBuilder { ) return try await builder.generatePIF(preservePIFModelStructure: preservePIFModelStructure, buildParameters: buildParameters) } + + private func diagnoseUnhandledFiles( + package: ResolvedPackage, + module: ResolvedModule, + buildToolPluginInvocationResults: [BuildToolPluginInvocationResult] + ) { + guard package.manifest.toolsVersion >= .v5_3 else { + return + } + + var unhandledFiles = Set(module.underlying.others) + if unhandledFiles.isEmpty { + return + } + + let handledFiles = buildToolPluginInvocationResults.flatMap { $0.buildCommands.flatMap(\.inputFiles) } + unhandledFiles.subtract(handledFiles) + + if unhandledFiles.isEmpty { + return + } + + let diagnosticsEmitter = self.observabilityScope.makeDiagnosticsEmitter { + var metadata = ObservabilityMetadata() + metadata.packageIdentity = package.identity + metadata.packageKind = package.manifest.packageKind + metadata.moduleName = module.name + return metadata + } + var warning = + "found \(unhandledFiles.count) file(s) which are unhandled; explicitly declare them as resources or exclude from the target\n" + for file in unhandledFiles { + warning += " " + file.pathString + "\n" + } + diagnosticsEmitter.emit(warning: warning) + } } fileprivate final class PackagePIFBuilderDelegate: PackagePIFBuilder.BuildDelegate { diff --git a/Tests/FunctionalTests/PluginTests.swift b/Tests/FunctionalTests/PluginTests.swift index e9a8162e650..3653ee36b62 100644 --- a/Tests/FunctionalTests/PluginTests.swift +++ b/Tests/FunctionalTests/PluginTests.swift @@ -73,7 +73,6 @@ struct PluginTests { @Test( .IssueWindowsRelativePathAssert, - .bug("https://github.com/swiftlang/swift-package-manager/issues/8786"), .requiresSwiftConcurrencySupport, .tags( .Feature.Command.Test, @@ -93,8 +92,7 @@ struct PluginTests { #expect(stderr.contains("file(s) which are unhandled; explicitly declare them as resources or exclude from the target"), "expected warning not emitted") } } when: { - (ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSelfHostedPipeline && buildSystem == .native) - || (buildSystem == .swiftbuild) + ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSelfHostedPipeline && buildSystem == .native } }