Skip to content

Commit 1cabbde

Browse files
committed
[Build] Link XCTest with Foundation
In order to implement asynchronous tests, swift-corelibs-xctest will take on a dependency upon swift-corelibs-foundation. To properly link the two: - Allow the package manager to take a path to a Foundation build. - Add the Foundation and CoreFoundation directories to the swiftc include paths. - While we're at it, remove the SWIFTPM_EXTRA_IMPORTS hack in favor of -Xswiftc.
1 parent df79e38 commit 1cabbde

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

Sources/Build/describe().swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module],
2222
throw Error.NoModules
2323
}
2424

25-
let Xcc = Xcc.flatMap{ ["-Xcc", $0] } + extraImports()
25+
let Xcc = Xcc.flatMap{ ["-Xcc", $0] }
2626
let Xld = Xld.flatMap{ ["-Xlinker", $0] }
2727
let prefix = try mkdir(prefix, conf.dirname)
2828
let yaml = try YAML(path: "\(prefix).yaml")
@@ -192,12 +192,3 @@ extension Product {
192192
return recursiveDependencies(modules.map{$0}).flatMap{ $0 as? SwiftModule }
193193
}
194194
}
195-
196-
private func extraImports() -> [String] {
197-
//FIXME HACK
198-
if let I = getenv("SWIFTPM_EXTRA_IMPORT") {
199-
return ["-I", I]
200-
} else {
201-
return []
202-
}
203-
}

Utilities/bootstrap

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,18 @@ def main():
542542
cmd.extend(["-Xlinker", "-rpath", "-Xlinker", embed_rpath])
543543

544544
cmd = [os.path.join(sandbox_path, "bin", "swift-build")]
545-
if args.xctest_path:
546-
env_cmd.append("SWIFTPM_EXTRA_IMPORT=" + args.xctest_path)
545+
if args.foundation_path and args.xctest_path:
546+
core_foundation_path = os.path.join(
547+
args.foundation_path, "usr", "lib", "swift")
547548
# Tell the linker where to look for XCTest, but autolinking
548549
# knows to pass -lXCTest.
549550
cmd.extend(["-Xlinker", "-L", "-Xlinker", args.xctest_path])
550551
# Add an RPATH, so that the tests can be run directly.
551552
cmd.extend(["-Xlinker", "-rpath", "-Xlinker", args.xctest_path])
553+
cmd.extend(["-Xlinker", "-rpath", "-Xlinker", args.foundation_path])
554+
cmd.extend(["-Xswiftc", "-I{}".format(args.xctest_path)])
555+
cmd.extend(["-Xswiftc", "-I{}".format(args.foundation_path)])
556+
cmd.extend(["-Xswiftc", "-I{}".format(core_foundation_path)])
552557

553558
cmd = env_cmd + cmd
554559

0 commit comments

Comments
 (0)