-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[cxx-interop] Make test discovery compatible with C++ interop #7165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -538,6 +538,25 @@ public final class SwiftTargetBuildDescription { | |
args += ["-color-diagnostics"] | ||
} | ||
|
||
// If this is a generated test discovery target, it might import a test | ||
// target that is built with C++ interop enabled. In that case, the test | ||
// discovery target must enable C++ interop as well | ||
switch testTargetRole { | ||
case .discovery: | ||
for dependency in try self.target.recursiveTargetDependencies() { | ||
let dependencyScope = self.buildParameters.createScope(for: dependency) | ||
let dependencySwiftFlags = dependencyScope.evaluate(.OTHER_SWIFT_FLAGS) | ||
if let interopModeFlag = dependencySwiftFlags.first(where: { $0.hasPrefix("-cxx-interoperability-mode=") }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we doing these kind of checks elsewhere in the code? should it be encapsulated behind something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 to this question There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't happening elsewhere in the code, no. We basically don't want to implicitly enable C++ interop unless is it really unavoidable, like it is in the case of a test discovery target, because parsing Objective-C headers in Objective-C++ language mode sometimes changes semantics/ABI. I only see one other usage of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generalizing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I just realized that the other usage of |
||
args += [interopModeFlag] | ||
break | ||
} | ||
} | ||
if let cxxStandard = self.package.manifest.cxxLanguageStandard { | ||
args += ["-Xcc", "-std=\(cxxStandard)"] | ||
} | ||
default: break | ||
} | ||
|
||
// Add arguments from declared build settings. | ||
args += try self.buildSettingsFlags() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is somewhat ugly, but it should go away once we have a better story for mixing C-interop and C++-interop in a single project.