Skip to content

Commit f529dae

Browse files
authored
[cxx-interop] Propagate interop flag to the test entry point target
### Motivation: Projects that use C++ interop for some of the Swift targets were failing to build in test mode (`swift test`) because the generated test entry point target wasn't being compiled with C++ interop enabled. ### Modifications: The logic that propagates the C++ interop compiler flag (`-cxx-interoperability-mode`) to the discovery target now also runs for the entry point target. rdar://125498997
1 parent c4a3af1 commit f529dae

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Sources/Build/BuildDescription/SwiftTargetBuildDescription.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,11 @@ package final class SwiftTargetBuildDescription {
555555
args += ["-color-diagnostics"]
556556
}
557557

558-
// If this is a generated test discovery target, it might import a test
558+
// If this is a generated test discovery target or a test entry point, it might import a test
559559
// target that is built with C++ interop enabled. In that case, the test
560560
// discovery target must enable C++ interop as well
561561
switch testTargetRole {
562-
case .discovery:
562+
case .discovery, .entryPoint:
563563
for dependency in try self.target.recursiveTargetDependencies() {
564564
let dependencyScope = self.buildParameters.createScope(for: dependency)
565565
let dependencySwiftFlags = dependencyScope.evaluate(.OTHER_SWIFT_FLAGS)

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4063,6 +4063,9 @@ final class BuildPlanTests: XCTestCase {
40634063

40644064
let testDiscovery = try result.target(for: "APackageDiscoveredTests").swiftTarget().compileArguments()
40654065
XCTAssertMatch(testDiscovery, [.anySequence, "-cxx-interoperability-mode=default", "-Xcc", "-std=c++17"])
4066+
4067+
let testEntryPoint = try result.target(for: "APackageTests").swiftTarget().compileArguments()
4068+
XCTAssertMatch(testEntryPoint, [.anySequence, "-cxx-interoperability-mode=default", "-Xcc", "-std=c++17"])
40664069
}
40674070

40684071
// omit frame pointers explicitly set to true

0 commit comments

Comments
 (0)