Skip to content

Commit 52a4766

Browse files
committed
WIP: Allow Clang executable targets to be linked into unit test targets as well. This implementation is currently a hack since it's not at all clear that we'll want to allow random types of products to link against executable targets.
1 parent 71dc485 commit 52a4766

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ public final class ClangTargetBuildDescription {
258258
self.derivedSources = Sources(paths: [], root: tempsPath.appending(component: "DerivedSources"))
259259

260260
// Try computing modulemap path for a C library. This also creates the file in the file system, if needed.
261-
if target.type == .library {
261+
// FIXME: Adding .executable here is probably not right, but is needed in order to test Clang executables.
262+
if target.type == .library || target.type == .executable {
262263
// If there's a custom module map, use it as given.
263264
if case .custom(let path) = clangTarget.moduleMapType {
264265
self.moduleMap = path
@@ -1690,7 +1691,8 @@ public class BuildPlan {
16901691
// depends on.
16911692
for case .target(let dependency, _) in swiftTarget.target.recursiveDependencies(satisfying: buildEnvironment) {
16921693
switch dependency.underlyingTarget {
1693-
case let underlyingTarget as ClangTarget where underlyingTarget.type == .library:
1694+
// FIXME: Adding .executable here is probably not right, but is needed in order to test Clang executables.
1695+
case let underlyingTarget as ClangTarget where underlyingTarget.type == .library || underlyingTarget.type == .executable:
16941696
guard case let .clang(target)? = targetMap[dependency] else {
16951697
fatalError("unexpected clang target \(underlyingTarget)")
16961698
}

0 commit comments

Comments
 (0)