Commit e4524c67 authored by Drew's avatar Drew

Update to swift preview 3

* We can't use system anymore in preview 3.  This introduces a lot of issues around envrionment variables, which can't be listed in swift :-(.  So we no longer inherit environment variables, we only set the ones we set.
    * We do pass on PWD and PATH, because otherwise that would be terrible
* Toolchain is now a part of platform config instead of something we pass around by hand.
* We now detect xcode 7 / 8 depending on whether we're using a toolchain installed to Xcode.app or Xcode-beta.app.  That's still not right, but fuck it.
parent eff308e9
...@@ -129,7 +129,7 @@ if Process.arguments.contains("--help") { ...@@ -129,7 +129,7 @@ if Process.arguments.contains("--help") {
func runTask(taskName: String, package: Package) { func runTask(taskName: String, package: Package) {
guard let task = package.tasks[taskName] else { fatalError("No \(taskName) task in build configuration.") } guard let task = package.tasks[taskName] else { fatalError("No \(taskName) task in build configuration.") }
TaskRunner.runTask(task: task, package: package, toolchain: toolchain) TaskRunner.runTask(task: task, package: package)
} }
...@@ -152,6 +152,8 @@ if focusOnTask == nil { ...@@ -152,6 +152,8 @@ if focusOnTask == nil {
focusOnTask = "default" focusOnTask = "default"
} }
Platform.toolchain = toolchain
print("Building package \(package.name)...") print("Building package \(package.name)...")
runTask(taskName: focusOnTask!, package: package) runTask(taskName: focusOnTask!, package: package)
......
...@@ -15,7 +15,7 @@ final class CustomTool: Tool { ...@@ -15,7 +15,7 @@ final class CustomTool: Tool {
init(name: String) { init(name: String) {
self.name = String(name.characters[name.characters.startIndex..<name.characters.index(name.characters.startIndex, offsetBy: name.characters.count - 7)]) self.name = String(name.characters[name.characters.startIndex..<name.characters.index(name.characters.startIndex, offsetBy: name.characters.count - 7)])
} }
func run(task: Task, toolchain: String) { func run(task: Task) {
var cmd = "\(self.name) " var cmd = "\(self.name) "
for key in task.allKeys.sorted() { for key in task.allKeys.sorted() {
if Task.Option.allOptions.map({$0.rawValue}).contains(key) { continue } if Task.Option.allOptions.map({$0.rawValue}).contains(key) { continue }
...@@ -24,8 +24,7 @@ final class CustomTool: Tool { ...@@ -24,8 +24,7 @@ final class CustomTool: Tool {
} }
cmd += "--\(key) \"\(evaluateSubstitutions(input: value, package: task.package))\" " cmd += "--\(key) \"\(evaluateSubstitutions(input: value, package: task.package))\" "
} }
Shell.environvironment(task: task) { let env = Shell.environment(task: task)
anarchySystem(cmd) anarchySystem(cmd,environment: env)
}
} }
} }
\ No newline at end of file
...@@ -19,5 +19,5 @@ import atpkg ...@@ -19,5 +19,5 @@ import atpkg
* dependencies together. * dependencies together.
*/ */
final class Nop: Tool { final class Nop: Tool {
func run(task: Task, toolchain: String) {} func run(task: Task) {}
} }
...@@ -22,7 +22,7 @@ class PackageAtbin:Tool { ...@@ -22,7 +22,7 @@ class PackageAtbin:Tool {
case Compress = "compress" case Compress = "compress"
} }
func run(task: Task, toolchain: String) { func run(task: Task) {
guard let n_ = task[Options.Name.rawValue] else { guard let n_ = task[Options.Name.rawValue] else {
fatalError("No \(Options.Name.rawValue) for \(task)") fatalError("No \(Options.Name.rawValue) for \(task)")
...@@ -112,7 +112,7 @@ class PackageAtbin:Tool { ...@@ -112,7 +112,7 @@ class PackageAtbin:Tool {
for platform in targetPlatforms { for platform in targetPlatforms {
Platform.targetPlatform = platform Platform.targetPlatform = platform
//run the underlying atbuild task //run the underlying atbuild task
TaskRunner.runTask(task: atllbuildTask, package: task.package, toolchain: toolchain, force: true) TaskRunner.runTask(task: atllbuildTask, package: task.package, force: true)
//copy payload to lipo location //copy payload to lipo location
try! FS.copyItem(from: Path(".atllbuild/products/\(payloadFileName)"), to: workDir.join(Path("\(payloadFileName).\(Platform.targetPlatform)"))) try! FS.copyItem(from: Path(".atllbuild/products/\(payloadFileName)"), to: workDir.join(Path("\(payloadFileName).\(Platform.targetPlatform)")))
...@@ -144,9 +144,7 @@ class PackageAtbin:Tool { ...@@ -144,9 +144,7 @@ class PackageAtbin:Tool {
for platform in targetPlatforms { for platform in targetPlatforms {
lipoCmd += "-arch \(platform.architecture) .atllbuild/lipo/\(payloadFileName).\(platform) " lipoCmd += "-arch \(platform.architecture) .atllbuild/lipo/\(payloadFileName).\(platform) "
} }
if system(lipoCmd) != 0 { anarchySystem(lipoCmd, environment: [:])
fatalError()
}
} }
//generate compiled.atpkg //generate compiled.atpkg
...@@ -186,9 +184,7 @@ class PackageAtbin:Tool { ...@@ -186,9 +184,7 @@ class PackageAtbin:Tool {
default: default:
fatalError("Unsupported host platform \(Platform.hostPlatform)") fatalError("Unsupported host platform \(Platform.hostPlatform)")
} }
if system(cmd) != 0 { anarchySystem(cmd, environment: [:])
fatalError("Failed to compress archive")
}
} }
} }
} }
\ No newline at end of file
...@@ -38,7 +38,7 @@ class PackageFramework: Tool { ...@@ -38,7 +38,7 @@ class PackageFramework: Tool {
fatalError("packageframework is unsupported on this platform") fatalError("packageframework is unsupported on this platform")
#endif #endif
} }
func run(task: Task, toolchain: String) { func run(task: Task) {
print("Warning: package-framework is deprecated and will be removed. Use the plugin instead.") print("Warning: package-framework is deprecated and will be removed. Use the plugin instead.")
sleep(5) sleep(5)
compiler_crash() //work around a compiler crash compiler_crash() //work around a compiler crash
...@@ -99,8 +99,6 @@ class PackageFramework: Tool { ...@@ -99,8 +99,6 @@ class PackageFramework: Tool {
//codesign //codesign
let cmd = "codesign --force --deep --sign - --timestamp=none '\(AVersionPath)'" let cmd = "codesign --force --deep --sign - --timestamp=none '\(AVersionPath)'"
print(cmd) print(cmd)
if system(cmd) != 0 { anarchySystem(cmd, environment: [:])
fatalError("Codesign failed.")
}
} }
} }
\ No newline at end of file
...@@ -54,6 +54,10 @@ public enum Platform { ...@@ -54,6 +54,10 @@ public enum Platform {
case Linux case Linux
case iOS(Architecture) case iOS(Architecture)
public static var toolchain: String? = nil
static var isXcode7: Bool { return Platform.toolchain!.contains(string: "Xcode.app") }
//generic platforms //generic platforms
case iOSGeneric case iOSGeneric
...@@ -113,13 +117,22 @@ public enum Platform { ...@@ -113,13 +117,22 @@ public enum Platform {
var sdkPath: String? { var sdkPath: String? {
switch(self) { switch(self) {
case .OSX: case .OSX:
return "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk" if Platform.isXcode7 {
return "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk"
}
return "/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
case .Linux: case .Linux:
return nil return nil
case .iOS(.x86_64), .iOS(.i386): case .iOS(.x86_64), .iOS(.i386):
return "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk" if Platform.isXcode7 {
return "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk"
}
return "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
case .iOS(.armv7), .iOS(.arm64): case .iOS(.armv7), .iOS(.arm64):
return "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk" if Platform.isXcode7 {
return "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk"
}
return "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
case .iOSGeneric: case .iOSGeneric:
fatalError("No SDK for generic iOS platform; choose a specific platform or use atbin") fatalError("No SDK for generic iOS platform; choose a specific platform or use atbin")
} }
...@@ -174,6 +187,34 @@ public enum Platform { ...@@ -174,6 +187,34 @@ public enum Platform {
return [Platform.iOS(Architecture.x86_64), Platform.iOS(Architecture.i386), Platform.iOS(Architecture.armv7), Platform.iOS(Architecture.arm64)] return [Platform.iOS(Architecture.x86_64), Platform.iOS(Architecture.i386), Platform.iOS(Architecture.armv7), Platform.iOS(Architecture.arm64)]
} }
} }
var targetTriple: String {
switch(self) {
case .OSX, .Linux, .iOSGeneric:
fatalError("Not implemented")
case .iOS(let arch):
switch(arch) {
case .x86_64:
if Platform.isXcode7 {return "x86_64-apple-ios9.3"}
return "x86_64-apple-ios10.0"
case .i386:
if Platform.isXcode7 {return "i386-apple-ios9.3"}
return "i386-apple-ios10.0"
case .arm64:
if Platform.isXcode7 {return "arm64-apple-ios9.3"}
return "arm64-apple-ios10.0"
case .armv7:
if Platform.isXcode7 {return "armv7-apple-ios9.3"}
return "armv7-apple-ios10.0"
}
}
}
} }
extension Platform: CustomStringConvertible { extension Platform: CustomStringConvertible {
...@@ -191,15 +232,15 @@ extension Platform: CustomStringConvertible { ...@@ -191,15 +232,15 @@ extension Platform: CustomStringConvertible {
} }
} }
func findToolPath(toolName: String, toolchain: String) -> Path { func findToolPath(toolName: String) -> Path {
if Platform.buildPlatform == Platform.hostPlatform { if Platform.buildPlatform == Platform.hostPlatform {
//poke around on the filesystem //poke around on the filesystem
//look in /usr/bin //look in /usr/bin
let usrBin = Path("\(toolchain)/usr/bin/\(toolName)") let usrBin = Path("\(Platform.toolchain!)/usr/bin/\(toolName)")
if FS.fileExists(path: usrBin) { return usrBin } if FS.fileExists(path: usrBin) { return usrBin }
//look in /usr/local/bin //look in /usr/local/bin
let usrLocalBin = Path("\(toolchain)/usr/local/bin/\(toolName)") let usrLocalBin = Path("\(Platform.toolchain!)/usr/local/bin/\(toolName)")
if FS.fileExists(path: usrLocalBin) { return usrLocalBin } if FS.fileExists(path: usrLocalBin) { return usrLocalBin }
//swift-build-tool isn't available in 2.2. //swift-build-tool isn't available in 2.2.
......
...@@ -28,30 +28,27 @@ import atpkg ...@@ -28,30 +28,27 @@ import atpkg
*/ */
final class Shell : Tool { final class Shell : Tool {
static private func mysetEnv(_ key: String, _ val: String) { ///Builds the environment for the specified task.
setenv(key,val,1) static func environment(task: Task) -> [String:String] {
} var environment: [String:String] = [:]
environment["ATBUILD_PLATFORM"] = Platform.targetPlatform.description
///Sets the environment for the specified task. environment["ATBUILD_USER_PATH"] = userPath().description
static func environvironment(task: Task, block: () -> ()) {
setenv("ATBUILD_PLATFORM", "\(Platform.targetPlatform)", 1)
setenv("ATBUILD_USER_PATH", userPath().description, 1)
if let version = task.package.version { if let version = task.package.version {
setenv("ATBUILD_PACKAGE_VERSION", version, 1) environment["ATBUILD_PACKAGE_VERSION"] = version
} }
setenv("ATBUILD_CONFIGURATION", "\(currentConfiguration)",1) environment["ATBUILD_CONFIGURATION"] = "\(currentConfiguration)"
if let o = currentConfiguration.optimize { if let o = currentConfiguration.optimize {
mysetEnv("ATBUILD_CONFIGURATION_OPTIMIZE", o ? "1":"0") environment["ATBUILD_CONFIGURATION_OPTIMIZE"] = o ? "1":"0"
} }
if let o = currentConfiguration.fastCompile { if let o = currentConfiguration.fastCompile {
mysetEnv("ATBUILD_CONFIGURATION_FAST_COMPILE", o ? "1":"0") environment["ATBUILD_CONFIGURATION_FAST_COMPILE"] = o ? "1":"0"
} }
if let o = currentConfiguration.testingEnabled { if let o = currentConfiguration.testingEnabled {
mysetEnv("ATBUILD_CONFIGURATION_TESTING_ENABLED", o ? "1":"0") environment["ATBUILD_CONFIGURATION_TESTING_ENABLED"] = o ? "1":"0"
} }
if let o = currentConfiguration.noMagic { if let o = currentConfiguration.noMagic {
mysetEnv("ATBUILD_CONFIGURATION_NO_MAGIC", o ? "1":"0") environment["ATBUILD_CONFIGURATION_NO_MAGIC"] = o ? "1":"0"
} }
//expose debug configuration info //expose debug configuration info
...@@ -64,8 +61,7 @@ final class Shell : Tool { ...@@ -64,8 +61,7 @@ final class Shell : Tool {
case .Stripped: case .Stripped:
conf = "stripped" conf = "stripped"
} }
mysetEnv("ATBUILD_CONFIGURATION_DEBUG_INSTRUMENTATION", conf) environment["ATBUILD_CONFIGURATION_DEBUG_INSTRUMENTATION"] = conf
//does bin path not exist? //does bin path not exist?
//let's create it! //let's create it!
...@@ -73,31 +69,16 @@ final class Shell : Tool { ...@@ -73,31 +69,16 @@ final class Shell : Tool {
if !FS.fileExists(path: binPath) { if !FS.fileExists(path: binPath) {
try! FS.createDirectory(path: binPath) try! FS.createDirectory(path: binPath)
} }
setenv("ATBUILD_BIN_PATH",binPath.description,1) environment["ATBUILD_BIN_PATH"] = binPath.description
//deal with directory nonsense environment["PWD"]=String(validatingUTF8: realpath(task.importedPath.description,nil))!
let oldPath = try! FS.getWorkingDirectory() print("pwd set to",environment["PWD"])
defer { return environment
do {
try FS.changeWorkingDirectory(path: oldPath)
} catch {
print("Can not revert to previous working directory '\(oldPath)': \(error)")
exit(42)
}
}
do {
try FS.changeWorkingDirectory(path: task.importedPath)
}
catch {
print("Cannot change working directory to \(task.importedPath)")
}
block()
} }
func run(task: Task, toolchain: String) { func run(task: Task) {
guard var script = task["script"]?.string else { fatalError("Invalid 'script' argument to shell tool.") } guard var script = task["script"]?.string else { fatalError("Invalid 'script' argument to shell tool.") }
script = evaluateSubstitutions(input: script, package: task.package) script = evaluateSubstitutions(input: script, package: task.package)
Shell.environvironment(task: task) { let env = Shell.environment(task: task)
anarchySystem(script) anarchySystem(script, environment: env)
}
} }
} }
\ No newline at end of file
...@@ -28,16 +28,16 @@ final public class TaskRunner { ...@@ -28,16 +28,16 @@ final public class TaskRunner {
///Run the task. Process all dependencies. Deduplicates dependencies. ///Run the task. Process all dependencies. Deduplicates dependencies.
///- parameter force: Force running the task and all its dependencies, even if we've run it before. This is used for e.g. forcibly reconfiguring the platform of a task and its dependency tree. ///- parameter force: Force running the task and all its dependencies, even if we've run it before. This is used for e.g. forcibly reconfiguring the platform of a task and its dependency tree.
/// ///
static public func runTask(task: Task, package: Package, toolchain: String, force: Bool = false) { static public func runTask(task: Task, package: Package, force: Bool = false) {
for t in package.prunedDependencyGraph(task: task) { for t in package.prunedDependencyGraph(task: task) {
if (!ranTasks.contains(t.qualifiedName)) || force { if (!ranTasks.contains(t.qualifiedName)) || force {
TaskRunner.runTaskWithoutDependencies(task: t, package: package, toolchain: toolchain) TaskRunner.runTaskWithoutDependencies(task: t, package: package)
ranTasks.append(t.qualifiedName) ranTasks.append(t.qualifiedName)
} }
} }
} }
static private func runTaskWithoutDependencies(task: Task, package: Package, toolchain: String) { static private func runTaskWithoutDependencies(task: Task, package: Package) {
if task.onlyPlatforms.count > 0 { if task.onlyPlatforms.count > 0 {
if !task.onlyPlatforms.contains(Platform.targetPlatform.description) { if !task.onlyPlatforms.contains(Platform.targetPlatform.description) {
print("Skipping task \(task) on platform \(Platform.targetPlatform)") print("Skipping task \(task) on platform \(Platform.targetPlatform)")
...@@ -51,7 +51,7 @@ final public class TaskRunner { ...@@ -51,7 +51,7 @@ final public class TaskRunner {
fatalError("Not all required overlays present: \(error)") fatalError("Not all required overlays present: \(error)")
} }
let tool = toolByName(name: task.tool) let tool = toolByName(name: task.tool)
tool.run(task: task, toolchain: toolchain) tool.run(task: task)
print("Completed task \(task.qualifiedName).") print("Completed task \(task.qualifiedName).")
} }
} }
\ No newline at end of file
...@@ -37,7 +37,7 @@ let tools: [String:Tool] = [ ...@@ -37,7 +37,7 @@ let tools: [String:Tool] = [
* can build new ones out of the existing ones. * can build new ones out of the existing ones.
*/ */
public protocol Tool { public protocol Tool {
func run(task: Task, toolchain: String) func run(task: Task)
} }
/** /**
...@@ -71,15 +71,61 @@ func userPath() -> Path { ...@@ -71,15 +71,61 @@ func userPath() -> Path {
} }
} }
private func _WSTATUS(_ status: CInt) -> CInt {
return status & 0x7f
}
private func WIFEXITED(_ status: CInt) -> Bool {
return _WSTATUS(status) == 0
}
private func WEXITSTATUS(_ status: CInt) -> CInt {
return (status >> 8) & 0xff
}
/// convenience wrapper for waitpid
func waitpid(_ pid: pid_t) -> Int32 {
while true {
var exitStatus: Int32 = 0
let rv = waitpid(pid, &exitStatus, 0)
if rv != -1 {
if WIFEXITED(exitStatus) {
return WEXITSTATUS(exitStatus)
} else {
fatalError("Exit signal")
}
} else if errno == EINTR {
continue // see: man waitpid
} else {
fatalError("waitpid: \(errno)")
}
}
}
///A wrapper for POSIX "system" call. ///A wrapper for POSIX "system" call.
///If return value is non-zero, we exit (not fatalError) ///If return value is non-zero, we exit (not fatalError)
///See #72 for details. ///See #72 for details.
///- note: This function call is appropriate for commands that are user-perceivable (such as compilation) ///- note: This function call is appropriate for commands that are user-perceivable (such as compilation)
///Rather than calls that aren't ///Rather than calls that aren't
func anarchySystem(_ cmd: String) { func anarchySystem(_ cmd: String, environment: [String: String]) {
let returnCode = system(cmd) var pid : pid_t = 0
//copy PATH
let path = getenv("PATH")!
var environment = environment
environment["PATH"] = String(validatingUTF8: path)!
let args: [String] = ["sh","-c",cmd]
let argv = args.map{ $0.withCString(strdup) }
let env: [UnsafeMutablePointer<CChar>?] = environment.map{ "\($0.0)=\($0.1)".withCString(strdup) }
let status = posix_spawn(&pid, "/bin/sh",nil,nil,argv + [nil],env + [nil])
if status != 0 {
fatalError("spawn error \(status)")
}
let returnCode = try! waitpid(pid)
if returnCode != 0 { if returnCode != 0 {
print("\(cmd) exited with return code \(returnCode)") fatalError("process \(cmd) error \(returnCode)")
exit(42)
} }
} }
\ No newline at end of file
...@@ -20,7 +20,7 @@ class XCTestRun : Tool { ...@@ -20,7 +20,7 @@ class XCTestRun : Tool {
case TestExecutable = "test-executable" case TestExecutable = "test-executable"
} }
func run(task: Task, toolchain: String) { func run(task: Task) {
guard let testExecutable = task[Option.TestExecutable.rawValue]?.string else { guard let testExecutable = task[Option.TestExecutable.rawValue]?.string else {
fatalError("No \(Option.TestExecutable.rawValue) for XCTestRun task \(task.qualifiedName)") fatalError("No \(Option.TestExecutable.rawValue) for XCTestRun task \(task.qualifiedName)")
} }
...@@ -62,12 +62,12 @@ class XCTestRun : Tool { ...@@ -62,12 +62,12 @@ class XCTestRun : Tool {
s += "</dict>\n" s += "</dict>\n"
s += "</plist>\n" s += "</plist>\n"
try s.write(to: workingDirectory + "XCTestRun.xctest/Contents/Info.plist") try s.write(to: workingDirectory + "XCTestRun.xctest/Contents/Info.plist")
anarchySystem("xcrun xctest \(workingDirectory)/XCTestRun.xctest") anarchySystem("xcrun xctest \(workingDirectory)/XCTestRun.xctest", environment: [:])
} catch { } catch {
fatalError("Could not run XCTest: \(error)") fatalError("Could not run XCTest: \(error)")
} }
case .Linux: case .Linux:
anarchySystem("\(testExecutable)") anarchySystem("\(testExecutable)", environment: [:])
case .iOS, .iOSGeneric: case .iOS, .iOSGeneric:
fatalError("XCTestRun is not supported for iOS") fatalError("XCTestRun is not supported for iOS")
......
...@@ -181,9 +181,9 @@ final class ATllbuild : Tool { ...@@ -181,9 +181,9 @@ final class ATllbuild : Tool {
if linkSDK { if linkSDK {
if let sdkPath = Platform.targetPlatform.sdkPath { if let sdkPath = Platform.targetPlatform.sdkPath {
if swiftCPath.description.contains(string: "Xcode-beta") { if swiftCPath.description.contains(string: "Xcode.app") {
//evil evil hack //evil evil hack
args += ["-sdk","/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/"] args += ["-sdk","/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk"]
} }
else { args += ["-sdk", sdkPath] } else { args += ["-sdk", sdkPath] }
...@@ -330,7 +330,7 @@ final class ATllbuild : Tool { ...@@ -330,7 +330,7 @@ final class ATllbuild : Tool {
} }
} }
func run(task: Task, toolchain: String) { func run(task: Task) {
//warn if we don't understand an option //warn if we don't understand an option
var knownOptions = Options.allOptions.map({$0.rawValue}) var knownOptions = Options.allOptions.map({$0.rawValue})
...@@ -625,24 +625,11 @@ final class ATllbuild : Tool { ...@@ -625,24 +625,11 @@ final class ATllbuild : Tool {
switch(Platform.targetPlatform) { switch(Platform.targetPlatform) {
case .iOS(let arch): case .iOS(let arch):
let targetTuple: [String] let targetTuple = ["-target",Platform.targetPlatform.targetTriple]
switch(arch) {
case .x86_64:
targetTuple = ["-target","x86_64-apple-ios9.3"]
case .i386:
targetTuple = ["-target","i386-apple-ios9.3"]
case .arm64:
targetTuple = ["-target","arm64-apple-ios9.3"]
case .armv7:
targetTuple = ["-target","armv7-apple-ios9.3"]
}
compileOptions.append(contentsOf: targetTuple) compileOptions.append(contentsOf: targetTuple)
linkOptions.append(contentsOf: targetTuple) linkOptions.append(contentsOf: targetTuple)
cCompileOptions.append(contentsOf: targetTuple) cCompileOptions.append(contentsOf: targetTuple)
cCompileOptions.append(contentsOf: ["-isysroot",Platform.targetPlatform.sdkPath!])
linkOptions.append(contentsOf: ["-Xlinker", "-syslibroot","-Xlinker",Platform.targetPlatform.sdkPath!]) linkOptions.append(contentsOf: ["-Xlinker", "-syslibroot","-Xlinker",Platform.targetPlatform.sdkPath!])
case .OSX, .Linux: case .OSX, .Linux:
break //not required break //not required
...@@ -678,7 +665,7 @@ final class ATllbuild : Tool { ...@@ -678,7 +665,7 @@ final class ATllbuild : Tool {
else { else {
llbuildyamlpath = workDirectory.appending("llbuild.yaml") llbuildyamlpath = workDirectory.appending("llbuild.yaml")
} }
let swiftCPath = findToolPath(toolName: "swiftc", toolchain: toolchain) let swiftCPath = findToolPath(toolName: "swiftc")
var enableWMO: Bool var enableWMO: Bool
if let wmo = task[Options.WholeModuleOptimization.rawValue]?.bool { if let wmo = task[Options.WholeModuleOptimization.rawValue]?.bool {
...@@ -776,8 +763,8 @@ final class ATllbuild : Tool { ...@@ -776,8 +763,8 @@ final class ATllbuild : Tool {
} }
} }
let cmd = "\(findToolPath(toolName: "swift-build-tool",toolchain: toolchain)) -f \(llbuildyamlpath)" let cmd = "\(findToolPath(toolName: "swift-build-tool")) -f \(llbuildyamlpath)"
anarchySystem(cmd) anarchySystem(cmd, environment: [:])
if task[Options.PublishProduct.rawValue]?.bool == true { if task[Options.PublishProduct.rawValue]?.bool == true {
do { do {
if !FS.isDirectory(path: Path("bin")) { if !FS.isDirectory(path: Path("bin")) {
......
...@@ -20,7 +20,7 @@ commands: ...@@ -20,7 +20,7 @@ commands:
module-name: atfoundation module-name: atfoundation
module-output-path: .atllbuild/products/atfoundation.swiftmodule module-output-path: .atllbuild/products/atfoundation.swiftmodule
temps-path: .atllbuild/llbuildtmp temps-path: .atllbuild/llbuildtmp
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk", "-enable-testing", "-g", "-Xcc", "-D_GNU_SOURCE", "-g", "-DATBUILD_DEBUG"] other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/", "-enable-testing", "-g", "-Xcc", "-D_GNU_SOURCE", "-g", "-DATBUILD_DEBUG"]
<atllbuild>: <atllbuild>:
tool: shell tool: shell
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/charset.swift.o", ".atllbuild/objects/date.swift.o", ".atllbuild/objects/timeinterval.swift.o", ".atllbuild/objects/file.swift.o", ".atllbuild/objects/fileinfo.swift.o", ".atllbuild/objects/fs.swift.o", ".atllbuild/objects/path.swift.o", ".atllbuild/objects/logger.swift.o", ".atllbuild/objects/replace.swift.o", ".atllbuild/objects/search.swift.o", ".atllbuild/objects/split.swift.o", ".atllbuild/objects/substring.swift.o", ".atllbuild/objects/whitespace.swift.o", ".atllbuild/objects/string.swift.o", ".atllbuild/objects/syserror.swift.o", ".atllbuild/objects/tools.swift.o", ".atllbuild/objects/url.swift.o"] inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/charset.swift.o", ".atllbuild/objects/date.swift.o", ".atllbuild/objects/timeinterval.swift.o", ".atllbuild/objects/file.swift.o", ".atllbuild/objects/fileinfo.swift.o", ".atllbuild/objects/fs.swift.o", ".atllbuild/objects/path.swift.o", ".atllbuild/objects/logger.swift.o", ".atllbuild/objects/replace.swift.o", ".atllbuild/objects/search.swift.o", ".atllbuild/objects/split.swift.o", ".atllbuild/objects/substring.swift.o", ".atllbuild/objects/whitespace.swift.o", ".atllbuild/objects/string.swift.o", ".atllbuild/objects/syserror.swift.o", ".atllbuild/objects/tools.swift.o", ".atllbuild/objects/url.swift.o"]
......
...@@ -20,7 +20,7 @@ commands: ...@@ -20,7 +20,7 @@ commands:
module-name: atpkg module-name: atpkg
module-output-path: .atllbuild/products/atpkg.swiftmodule module-output-path: .atllbuild/products/atpkg.swiftmodule
temps-path: .atllbuild/llbuildtmp temps-path: .atllbuild/llbuildtmp
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk", "-g", "-DATBUILD_DEBUG"] other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/", "-g", "-DATBUILD_DEBUG"]
<atllbuild>: <atllbuild>:
tool: shell tool: shell
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/Binary.swift.o", ".atllbuild/objects/CollectSources.swift.o", ".atllbuild/objects/ExternalDependency.swift.o", ".atllbuild/objects/Package.swift.o", ".atllbuild/objects/Parser.swift.o", ".atllbuild/objects/Scanner.swift.o", ".atllbuild/objects/Tokenization.swift.o", ".atllbuild/objects/Substitutions.swift.o", ".atllbuild/objects/Task.swift.o"] inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/Binary.swift.o", ".atllbuild/objects/CollectSources.swift.o", ".atllbuild/objects/ExternalDependency.swift.o", ".atllbuild/objects/Package.swift.o", ".atllbuild/objects/Parser.swift.o", ".atllbuild/objects/Scanner.swift.o", ".atllbuild/objects/Tokenization.swift.o", ".atllbuild/objects/Substitutions.swift.o", ".atllbuild/objects/Task.swift.o"]
......
...@@ -20,7 +20,7 @@ commands: ...@@ -20,7 +20,7 @@ commands:
module-name: attools module-name: attools
module-output-path: .atllbuild/products/attools.swiftmodule module-output-path: .atllbuild/products/attools.swiftmodule
temps-path: .atllbuild/llbuildtmp temps-path: .atllbuild/llbuildtmp
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk", "-g", "-DATBUILD_DEBUG"] other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/", "-g", "-DATBUILD_DEBUG"]
<atllbuild>: <atllbuild>:
tool: shell tool: shell
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/atllbuild.swift.o", ".atllbuild/objects/Configuration.swift.o", ".atllbuild/objects/CustomTool.swift.o", ".atllbuild/objects/Nop.swift.o", ".atllbuild/objects/PackageAtbin.swift.o", ".atllbuild/objects/PackageFramework.swift.o", ".atllbuild/objects/PlatformPaths.swift.o", ".atllbuild/objects/Shell.swift.o", ".atllbuild/objects/TaskRunner.swift.o", ".atllbuild/objects/Tools.swift.o", ".atllbuild/objects/XCTestRun.swift.o"] inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/atllbuild.swift.o", ".atllbuild/objects/Configuration.swift.o", ".atllbuild/objects/CustomTool.swift.o", ".atllbuild/objects/Nop.swift.o", ".atllbuild/objects/PackageAtbin.swift.o", ".atllbuild/objects/PackageFramework.swift.o", ".atllbuild/objects/PlatformPaths.swift.o", ".atllbuild/objects/Shell.swift.o", ".atllbuild/objects/TaskRunner.swift.o", ".atllbuild/objects/Tools.swift.o", ".atllbuild/objects/XCTestRun.swift.o"]
......
...@@ -19,7 +19,7 @@ commands: ...@@ -19,7 +19,7 @@ commands:
module-name: atbuild module-name: atbuild
module-output-path: .atllbuild/products/atbuild.swiftmodule module-output-path: .atllbuild/products/atbuild.swiftmodule
temps-path: .atllbuild/llbuildtmp temps-path: .atllbuild/llbuildtmp
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk", "-g", "-DATBUILD_DEBUG"] other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/", "-g", "-DATBUILD_DEBUG"]
<atllbuild>: <atllbuild>:
tool: shell tool: shell
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/main.swift.o", ".atllbuild/products/attools.a", ".atllbuild/products/atpkg.a", ".atllbuild/products/atfoundation.a"] inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/main.swift.o", ".atllbuild/products/attools.a", ".atllbuild/products/atpkg.a", ".atllbuild/products/atfoundation.a"]
......
#include <stdio.h>
#include "baz.h" #include "baz.h"
void bar() { void bar() {
printf("hello from C"); printf("hello from C");
......