Skip to content

Commit 76e7523

Browse files
authored
🍒[cxx-interop] Propagate interop flag to the test entry point target
**Explanation**: 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. **Scope**: Flags that are being passed to the entry point test target. **Risk**: Low, this only affects projects that explicitly enable C++ interop in the package manifest on non-Darwin platforms only. **Testing**: Added a build plan test. **Issue**: rdar://125498997 **Reviewer**: @MaxDesiatov approved #7428. (cherry picked from commit f529dae)
1 parent 9ee1649 commit 76e7523

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)