Commit 4cc6af23 authored by Drew's avatar Drew

Support environment variables

The way we work around SR-1636 is we add a C language target with atbuild's new C project syntax.

This C target can access `environ` and the result follows.

I think this bootstraps OK, we'll see what CI says

See also: https://bugs.swift.org/browse/SR-1636, https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160523/019350.html
parent 9d51891d
Pipeline #2858 passed with stage
in 3 minutes and 17 seconds
// Copyright (c) 2016 Anarchy Tools Contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
extern char **environ;
char **_environment() {
return environ;
}
\ No newline at end of file
// Copyright (c) 2016 Anarchy Tools Contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
char **_environment();
\ No newline at end of file
// Copyright (c) 2016 Anarchy Tools Contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#if os(OSX)
import Darwin
#else
import Glibc
#endif
import atfoundation
public var environment: [String: String] {
var r: [String: String] = [:]
let e = _environment()!
var i = 0
while e[i] != nil {
let keyv = e[i]!
let keyvalue_ = String(validatingUTF8: keyv)!
let keyvalue = keyvalue_.split(string: "=", maxSplits: 1)
let key = keyvalue[0]
let value = keyvalue[1]
r[key] = value
i += 1
}
return r
}
...@@ -25,6 +25,6 @@ final class CustomTool: Tool { ...@@ -25,6 +25,6 @@ final class CustomTool: Tool {
cmd += "--\(key) \"\(evaluateSubstitutions(input: value, package: task.package))\" " cmd += "--\(key) \"\(evaluateSubstitutions(input: value, package: task.package))\" "
} }
let env = Shell.environment(task: task) let env = Shell.environment(task: task)
anarchySystem(cmd,environment: env) anarchySystem(cmd,additionalEnvironment: env)
} }
} }
...@@ -144,7 +144,7 @@ class PackageAtbin:Tool { ...@@ -144,7 +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) "
} }
anarchySystem(lipoCmd, environment: [:]) anarchySystem(lipoCmd)
} }
//generate compiled.atpkg //generate compiled.atpkg
...@@ -184,7 +184,7 @@ class PackageAtbin:Tool { ...@@ -184,7 +184,7 @@ class PackageAtbin:Tool {
default: default:
fatalError("Unsupported host platform \(Platform.hostPlatform)") fatalError("Unsupported host platform \(Platform.hostPlatform)")
} }
anarchySystem(cmd, environment: [:]) anarchySystem(cmd)
} }
} }
} }
...@@ -99,6 +99,6 @@ class PackageFramework: Tool { ...@@ -99,6 +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)
anarchySystem(cmd, environment: [:]) anarchySystem(cmd, additionalEnvironment: [:])
} }
} }
...@@ -106,7 +106,7 @@ public enum Platform { ...@@ -106,7 +106,7 @@ public enum Platform {
//assuming that failed, try xcode-select //assuming that failed, try xcode-select
#if os(OSX) #if os(OSX)
var xcode_select_path = "" var xcode_select_path = ""
anarchySystem("xcode-select -p", environment:[:], redirectOutput: &xcode_select_path) anarchySystem("xcode-select -p", redirectOutput: &xcode_select_path)
//lop off the newline //lop off the newline
var notEndIndex = xcode_select_path.characters.index(before: xcode_select_path.characters.endIndex) var notEndIndex = xcode_select_path.characters.index(before: xcode_select_path.characters.endIndex)
notEndIndex = xcode_select_path.characters.index(before: notEndIndex) notEndIndex = xcode_select_path.characters.index(before: notEndIndex)
......
...@@ -72,13 +72,12 @@ final class Shell : Tool { ...@@ -72,13 +72,12 @@ final class Shell : Tool {
environment["ATBUILD_BIN_PATH"] = binPath.description environment["ATBUILD_BIN_PATH"] = binPath.description
environment["PWD"]=String(validatingUTF8: realpath(task.importedPath.description,nil))! environment["PWD"]=String(validatingUTF8: realpath(task.importedPath.description,nil))!
print("pwd set to",environment["PWD"]!)
return environment return environment
} }
func run(task: Task) { 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)
let env = Shell.environment(task: task) let env = Shell.environment(task: task)
anarchySystem(script, environment: env) anarchySystem(script, additionalEnvironment: env)
} }
} }
...@@ -50,100 +50,3 @@ func toolByName(name: String) -> Tool { ...@@ -50,100 +50,3 @@ func toolByName(name: String) -> Tool {
guard let tool = tools[name] else { fatalError("Unknown build tool \(name)") } guard let tool = tools[name] else { fatalError("Unknown build tool \(name)") }
return tool return tool
} }
private var userPathCreated = false
/**Returns the "user" path. This is a path that the user may use to store artifacts or for any other purposes. This path is shared for all tasks built as part of the same `atbuild` invocation.
- postcondition: The path exists at this absolute locaton on disk.
- warning: This path is cleared between atbuild invocations. */
func userPath() -> Path {
do {
let userPath = try FS.getWorkingDirectory().appending("user")
if !userPathCreated {
if FS.isDirectory(path: userPath) {
try FS.removeItem(path: userPath, recursive: true)
}
try FS.createDirectory(path: userPath)
userPathCreated = true
}
return userPath
} catch {
fatalError("Could not create user dir: \(error)")
}
}
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.
///If return value is non-zero, we exit (not fatalError)
///See #72 for details.
///- note: This function call is appropriate for commands that are user-perceivable (such as compilation)
///Rather than calls that aren't
func anarchySystem(_ cmd: String, environment: [String: String]) {
var output = ""
anarchySystem(cmd, environment: environment, redirectOutput: &output, shouldRedirectOutput: false)
}
func anarchySystem(_ cmd: String, environment: [String: String],redirectOutput: inout String, shouldRedirectOutput: Bool = true) {
var pid : pid_t = 0
//copy a few well-known values
var environment = environment
for arg in ["PATH","HOME"] {
if let path = getenv(arg) {
environment[arg] = String(validatingUTF8: path)!
}
}
var cmd = cmd
if shouldRedirectOutput {
cmd += ">/tmp/anarchySystem.out"
}
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 directory = try! FS.getWorkingDirectory()
defer {try! FS.changeWorkingDirectory(path: directory)}
if let e = environment["PWD"] {
try! FS.changeWorkingDirectory(path: Path(e))
}
let status = posix_spawn(&pid, "/bin/sh",nil,nil,argv + [nil],env + [nil])
if status != 0 {
fatalError("spawn error \(status)")
}
let returnCode = waitpid(pid)
if shouldRedirectOutput {
redirectOutput = try! File(path: Path("/tmp/anarchySystem.out"), mode:.ReadOnly).readAll()!
}
if returnCode != 0 { exit(1) }
}
\ No newline at end of file
...@@ -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", environment: [:]) anarchySystem("xcrun xctest \(workingDirectory)/XCTestRun.xctest")
} catch { } catch {
fatalError("Could not run XCTest: \(error)") fatalError("Could not run XCTest: \(error)")
} }
case .Linux: case .Linux:
anarchySystem("\(testExecutable)", environment: [:]) anarchySystem("\(testExecutable)")
case .iOS, .iOSGeneric: case .iOS, .iOSGeneric:
fatalError("XCTestRun is not supported for iOS") fatalError("XCTestRun is not supported for iOS")
......
...@@ -639,10 +639,15 @@ final class ATllbuild : Tool { ...@@ -639,10 +639,15 @@ final class ATllbuild : Tool {
let targetTuple = ["-target",Platform.targetPlatform.nonDeploymentTargetTargetTriple + deploymentTarget] let targetTuple = ["-target",Platform.targetPlatform.nonDeploymentTargetTargetTriple + deploymentTarget]
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!]) 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:
//we require sysroot
cCompileOptions.append(contentsOf: ["-isysroot",Platform.targetPlatform.sdkPath!])
case .Linux:
break //not required break //not required
case .iOSGeneric: case .iOSGeneric:
fatalError("Generic platform iOS cannot be used with atllbuild; choose a specific platform or use atbin") fatalError("Generic platform iOS cannot be used with atllbuild; choose a specific platform or use atbin")
...@@ -775,7 +780,7 @@ final class ATllbuild : Tool { ...@@ -775,7 +780,7 @@ final class ATllbuild : Tool {
} }
let cmd = "\(findToolPath(toolName: "swift-build-tool")) -f \(llbuildyamlpath)" let cmd = "\(findToolPath(toolName: "swift-build-tool")) -f \(llbuildyamlpath)"
anarchySystem(cmd, environment: [:]) anarchySystem(cmd)
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")) {
......
// Copyright (c) 2016 Anarchy Tools Contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#if os(OSX)
import Darwin
#elseif os(Linux)
import Glibc
#endif
import atfoundation
private var userPathCreated = false
import atenvironment
/**Returns the "user" path. This is a path that the user may use to store artifacts or for any other purposes. This path is shared for all tasks built as part of the same `atbuild` invocation.
- postcondition: The path exists at this absolute locaton on disk.
- warning: This path is cleared between atbuild invocations. */
func userPath() -> Path {
do {
let userPath = try FS.getWorkingDirectory().appending("user")
if !userPathCreated {
if FS.isDirectory(path: userPath) {
try FS.removeItem(path: userPath, recursive: true)
}
try FS.createDirectory(path: userPath)
userPathCreated = true
}
return userPath
} catch {
fatalError("Could not create user dir: \(error)")
}
}
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.
///If return value is non-zero, we exit (not fatalError)
///See #72 for details.
///- note: This function call is appropriate for commands that are user-perceivable (such as compilation)
///Rather than calls that aren't
func anarchySystem(_ cmd: String, additionalEnvironment: [String: String] = [:]) {
var output = ""
anarchySystem(cmd, additionalEnvrionment: additionalEnvironment, redirectOutput: &output, shouldRedirectOutput: false)
}
func anarchySystem(_ cmd: String, additionalEnvrionment: [String: String] = [:],redirectOutput: inout String, shouldRedirectOutput: Bool = true) {
var e = environment
for (key, value) in additionalEnvrionment {
e[key] = value
}
_anarchySystem(cmd, environment: e, redirectOutput: &redirectOutput, shouldRedirectOutput: shouldRedirectOutput)
}
private func _anarchySystem(_ cmd: String, environment: [String: String],redirectOutput: inout String, shouldRedirectOutput: Bool = true) {
var pid : pid_t = 0
//copy a few well-known values
var environment = environment
for arg in ["PATH","HOME"] {
if let path = getenv(arg) {
environment[arg] = String(validatingUTF8: path)!
}
}
var cmd = cmd
if shouldRedirectOutput {
cmd += ">/tmp/anarchySystem.out"
}
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 directory = try! FS.getWorkingDirectory()
defer {try! FS.changeWorkingDirectory(path: directory)}
if let e = environment["PWD"] {
try! FS.changeWorkingDirectory(path: Path(e))
}
let status = posix_spawn(&pid, "/bin/sh",nil,nil,argv + [nil],env + [nil])
if status != 0 {
fatalError("spawn error \(status)")
}
let returnCode = waitpid(pid)
if shouldRedirectOutput {
redirectOutput = try! File(path: Path("/tmp/anarchySystem.out"), mode:.ReadOnly).readAll()!
}
if returnCode != 0 { exit(1) }
}
module atenvironment {
header "../../atenvironment/environment.h"
}
\ No newline at end of file
module atenvironment {
}
\ No newline at end of file
client:
name: swift-build
tools: {}
targets:
"": [<atllbuild>]
atllbuild: [<atllbuild>]
commands:
<atllbuild-swiftc>:
tool: swift-compiler
executable: "//usr/local/bin/swiftc"
inputs: ["atenvironment/environment.swift"]
sources: ["atenvironment/environment.swift"]
objects: [".atllbuild/objects/environment.swift.o"]
outputs: ["<atllbuild-swiftc>", ".atllbuild/objects/environment.swift.o"]
enable-whole-module-optimization: false
num-threads: 8
is-library: true
module-name: atenvironment
module-output-path: .atllbuild/products/atenvironment.swiftmodule
temps-path: .atllbuild/llbuildtmp
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-I", ".atllbuild/include/", "-import-underlying-module", "-g", "-DATBUILD_DEBUG"]
<atllbuild-environment>:
tool: shell
inputs: ["atenvironment/environment.c"]
outputs: [".atllbuild/objects/environment.c.o"]
args: ["clang", "-c", "atenvironment/environment.c", "-o", ".atllbuild/objects/environment.c.o", "-g", "-DATBUILD_DEBUG"]
<atllbuild>:
tool: shell
inputs: ["<atllbuild-swiftc>", "<atllbuild-environment>", ".atllbuild/objects/environment.swift.o", ".atllbuild/objects/environment.c.o"]
outputs: ["<atllbuild>", ".atllbuild/products/atenvironment.a"]
args: ["/bin/sh","-c",rm -rf .atllbuild/products/atenvironment.a; ar cr '.atllbuild/products/atenvironment.a' '.atllbuild/objects/environment.swift.o' '.atllbuild/objects/environment.c.o']
description: "Linking Library: .atllbuild/products/atenvironment.a"
\ No newline at end of file
...@@ -10,20 +10,20 @@ commands: ...@@ -10,20 +10,20 @@ commands:
<atllbuild-swiftc>: <atllbuild-swiftc>:
tool: swift-compiler tool: swift-compiler
executable: "//usr/local/bin/swiftc" executable: "//usr/local/bin/swiftc"
inputs: ["attools/src/atllbuild.swift", "attools/src/Configuration.swift", "attools/src/CustomTool.swift", "attools/src/Nop.swift", "attools/src/PackageAtbin.swift", "attools/src/PackageFramework.swift", "attools/src/PlatformPaths.swift", "attools/src/Shell.swift", "attools/src/TaskRunner.swift", "attools/src/Tools.swift", "attools/src/XCTestRun.swift"] inputs: ["attools/src/atllbuild.swift", "attools/src/Configuration.swift", "attools/src/CustomTool.swift", "attools/src/misc.swift", "attools/src/Nop.swift", "attools/src/PackageAtbin.swift", "attools/src/PackageFramework.swift", "attools/src/PlatformPaths.swift", "attools/src/Shell.swift", "attools/src/TaskRunner.swift", "attools/src/Tools.swift", "attools/src/XCTestRun.swift"]
sources: ["attools/src/atllbuild.swift", "attools/src/Configuration.swift", "attools/src/CustomTool.swift", "attools/src/Nop.swift", "attools/src/PackageAtbin.swift", "attools/src/PackageFramework.swift", "attools/src/PlatformPaths.swift", "attools/src/Shell.swift", "attools/src/TaskRunner.swift", "attools/src/Tools.swift", "attools/src/XCTestRun.swift"] sources: ["attools/src/atllbuild.swift", "attools/src/Configuration.swift", "attools/src/CustomTool.swift", "attools/src/misc.swift", "attools/src/Nop.swift", "attools/src/PackageAtbin.swift", "attools/src/PackageFramework.swift", "attools/src/PlatformPaths.swift", "attools/src/Shell.swift", "attools/src/TaskRunner.swift", "attools/src/Tools.swift", "attools/src/XCTestRun.swift"]
objects: [".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"] objects: [".atllbuild/objects/atllbuild.swift.o", ".atllbuild/objects/Configuration.swift.o", ".atllbuild/objects/CustomTool.swift.o", ".atllbuild/objects/misc.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"]
outputs: ["<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"] outputs: ["<atllbuild-swiftc>", ".atllbuild/objects/atllbuild.swift.o", ".atllbuild/objects/Configuration.swift.o", ".atllbuild/objects/CustomTool.swift.o", ".atllbuild/objects/misc.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"]
enable-whole-module-optimization: false enable-whole-module-optimization: false
num-threads: 8 num-threads: 8
is-library: true is-library: true
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/", "-g", "-DATBUILD_DEBUG"] other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-I", ".atllbuild/include/atenvironment", "-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/misc.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"]
outputs: ["<atllbuild>", ".atllbuild/products/attools.a"] outputs: ["<atllbuild>", ".atllbuild/products/attools.a"]
args: ["/bin/sh","-c",rm -rf .atllbuild/products/attools.a; ar cr '.atllbuild/products/attools.a' '.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'] args: ["/bin/sh","-c",rm -rf .atllbuild/products/attools.a; ar cr '.atllbuild/products/attools.a' '.atllbuild/objects/atllbuild.swift.o' '.atllbuild/objects/Configuration.swift.o' '.atllbuild/objects/CustomTool.swift.o' '.atllbuild/objects/misc.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']
description: "Linking Library: .atllbuild/products/attools.a" description: "Linking Library: .atllbuild/products/attools.a"
\ No newline at end of file
...@@ -19,10 +19,10 @@ commands: ...@@ -19,10 +19,10 @@ 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/", "-g", "-DATBUILD_DEBUG"] other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-I", ".atllbuild/include/attools", "-I", ".atllbuild/include/atenvironment", "-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", ".atllbuild/products/atenvironment.a"]
outputs: ["<atllbuild>", ".atllbuild/products/atbuild"] outputs: ["<atllbuild>", ".atllbuild/products/atbuild"]
args: ["//usr/local/bin/swiftc", "-o", ".atllbuild/products/atbuild", ".atllbuild/objects/main.swift.o", ".atllbuild/products/attools.a", ".atllbuild/products/atpkg.a", ".atllbuild/products/atfoundation.a"] args: ["//usr/local/bin/swiftc", "-o", ".atllbuild/products/atbuild", ".atllbuild/objects/main.swift.o", ".atllbuild/products/attools.a", ".atllbuild/products/atpkg.a", ".atllbuild/products/atfoundation.a", ".atllbuild/products/atenvironment.a"]
description: Linking executable .atllbuild/products/atbuild description: Linking executable .atllbuild/products/atbuild
client:
name: swift-build
tools: {}
targets:
"": [<atllbuild>]
atllbuild: [<atllbuild>]
commands:
<atllbuild-swiftc>:
tool: swift-compiler
executable: "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc"
inputs: ["atenvironment/environment.swift"]
sources: ["atenvironment/environment.swift"]
objects: [".atllbuild/objects/environment.swift.o"]
outputs: ["<atllbuild-swiftc>", ".atllbuild/objects/environment.swift.o"]
enable-whole-module-optimization: false
num-threads: 8
is-library: true
module-name: atenvironment
module-output-path: .atllbuild/products/atenvironment.swiftmodule
temps-path: .atllbuild/llbuildtmp
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk", "-I", ".atllbuild/include/", "-import-underlying-module", "-g", "-DATBUILD_DEBUG"]
<atllbuild-environment>:
tool: shell
inputs: ["atenvironment/environment.c"]
outputs: [".atllbuild/objects/environment.c.o"]
args: ["clang", "-c", "atenvironment/environment.c", "-o", ".atllbuild/objects/environment.c.o", "-g", "-DATBUILD_DEBUG"]
<atllbuild>:
tool: shell
inputs: ["<atllbuild-swiftc>", "<atllbuild-environment>", ".atllbuild/objects/environment.swift.o", ".atllbuild/objects/environment.c.o"]
outputs: ["<atllbuild>", ".atllbuild/products/atenvironment.a"]
args: ["/bin/sh","-c",rm -rf .atllbuild/products/atenvironment.a; ar cr '.atllbuild/products/atenvironment.a' '.atllbuild/objects/environment.swift.o' '.atllbuild/objects/environment.c.o']
description: "Linking Library: .atllbuild/products/atenvironment.a"
\ No newline at end of file
...@@ -10,20 +10,20 @@ commands: ...@@ -10,20 +10,20 @@ commands:
<atllbuild-swiftc>: <atllbuild-swiftc>:
tool: swift-compiler tool: swift-compiler
executable: "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc" executable: "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc"
inputs: ["attools/src/atllbuild.swift", "attools/src/Configuration.swift", "attools/src/CustomTool.swift", "attools/src/Nop.swift", "attools/src/PackageAtbin.swift", "attools/src/PackageFramework.swift", "attools/src/PlatformPaths.swift", "attools/src/Shell.swift", "attools/src/TaskRunner.swift", "attools/src/Tools.swift", "attools/src/XCTestRun.swift"] inputs: ["attools/src/atllbuild.swift", "attools/src/Configuration.swift", "attools/src/CustomTool.swift", "attools/src/misc.swift", "attools/src/Nop.swift", "attools/src/PackageAtbin.swift", "attools/src/PackageFramework.swift", "attools/src/PlatformPaths.swift", "attools/src/Shell.swift", "attools/src/TaskRunner.swift", "attools/src/Tools.swift", "attools/src/XCTestRun.swift"]
sources: ["attools/src/atllbuild.swift", "attools/src/Configuration.swift", "attools/src/CustomTool.swift", "attools/src/Nop.swift", "attools/src/PackageAtbin.swift", "attools/src/PackageFramework.swift", "attools/src/PlatformPaths.swift", "attools/src/Shell.swift", "attools/src/TaskRunner.swift", "attools/src/Tools.swift", "attools/src/XCTestRun.swift"] sources: ["attools/src/atllbuild.swift", "attools/src/Configuration.swift", "attools/src/CustomTool.swift", "attools/src/misc.swift", "attools/src/Nop.swift", "attools/src/PackageAtbin.swift", "attools/src/PackageFramework.swift", "attools/src/PlatformPaths.swift", "attools/src/Shell.swift", "attools/src/TaskRunner.swift", "attools/src/Tools.swift", "attools/src/XCTestRun.swift"]
objects: [".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"] objects: [".atllbuild/objects/atllbuild.swift.o", ".atllbuild/objects/Configuration.swift.o", ".atllbuild/objects/CustomTool.swift.o", ".atllbuild/objects/misc.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"]
outputs: ["<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"] outputs: ["<atllbuild-swiftc>", ".atllbuild/objects/atllbuild.swift.o", ".atllbuild/objects/Configuration.swift.o", ".atllbuild/objects/CustomTool.swift.o", ".atllbuild/objects/misc.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"]
enable-whole-module-optimization: false enable-whole-module-optimization: false
num-threads: 8 num-threads: 8
is-library: true is-library: true
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/MacOSX.sdk", "-g", "-DATBUILD_DEBUG"] other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk", "-I", ".atllbuild/include/atenvironment", "-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/misc.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"]
outputs: ["<atllbuild>", ".atllbuild/products/attools.a"] outputs: ["<atllbuild>", ".atllbuild/products/attools.a"]
args: ["/bin/sh","-c",rm -rf .atllbuild/products/attools.a; ar cr '.atllbuild/products/attools.a' '.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'] args: ["/bin/sh","-c",rm -rf .atllbuild/products/attools.a; ar cr '.atllbuild/products/attools.a' '.atllbuild/objects/atllbuild.swift.o' '.atllbuild/objects/Configuration.swift.o' '.atllbuild/objects/CustomTool.swift.o' '.atllbuild/objects/misc.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']
description: "Linking Library: .atllbuild/products/attools.a" description: "Linking Library: .atllbuild/products/attools.a"
\ No newline at end of file
...@@ -19,10 +19,10 @@ commands: ...@@ -19,10 +19,10 @@ 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/MacOSX.sdk", "-g", "-DATBUILD_DEBUG"] other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk", "-I", ".atllbuild/include/attools", "-I", ".atllbuild/include/atenvironment", "-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", ".atllbuild/products/atenvironment.a"]
outputs: ["<atllbuild>", ".atllbuild/products/atbuild"] outputs: ["<atllbuild>", ".atllbuild/products/atbuild"]
args: ["/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc", "-o", ".atllbuild/products/atbuild", ".atllbuild/objects/main.swift.o", ".atllbuild/products/attools.a", ".atllbuild/products/atpkg.a", ".atllbuild/products/atfoundation.a"] args: ["/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc", "-o", ".atllbuild/products/atbuild", ".atllbuild/objects/main.swift.o", ".atllbuild/products/attools.a", ".atllbuild/products/atpkg.a", ".atllbuild/products/atfoundation.a", ".atllbuild/products/atenvironment.a"]
description: Linking executable .atllbuild/products/atbuild description: Linking executable .atllbuild/products/atbuild
...@@ -18,6 +18,11 @@ mkdir -p .atllbuild/objects ...@@ -18,6 +18,11 @@ mkdir -p .atllbuild/objects
$SWIFT_BUILD_TOOL -f bootstrap/bootstrap-$PLATFORM-atfoundation.swift-build --no-db $SWIFT_BUILD_TOOL -f bootstrap/bootstrap-$PLATFORM-atfoundation.swift-build --no-db
$SWIFT_BUILD_TOOL -f bootstrap/bootstrap-$PLATFORM-atpkg.swift-build --no-db $SWIFT_BUILD_TOOL -f bootstrap/bootstrap-$PLATFORM-atpkg.swift-build --no-db
mkdir -p .atllbuild/include
cp bootstrap/atenvironment.modulemap .atllbuild/include/module.modulemap
$SWIFT_BUILD_TOOL -f bootstrap/bootstrap-$PLATFORM-atenvironment.swift-build --no-db
mkdir -p .atllbuild/include/atenvironment
cp bootstrap/atenvironment.public.modulemap .atllbuild/include/atenvironment/module.modulemap
$SWIFT_BUILD_TOOL -f bootstrap/bootstrap-$PLATFORM-attools.swift-build --no-db $SWIFT_BUILD_TOOL -f bootstrap/bootstrap-$PLATFORM-attools.swift-build --no-db
$SWIFT_BUILD_TOOL -f bootstrap/bootstrap-$PLATFORM.swift-build --no-db $SWIFT_BUILD_TOOL -f bootstrap/bootstrap-$PLATFORM.swift-build --no-db
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
:sources ["atbuild/src/**.swift"] :sources ["atbuild/src/**.swift"]
:name "atbuild" :name "atbuild"
:output-type "executable" :output-type "executable"
:link-with-product ["attools.a" "atpkg.a" "atfoundation.a"] :link-with-product ["attools.a" "atpkg.a" "atfoundation.a" "atenvironment.a"]
:dependencies ["attools" "atpkg.atpkg" "atfoundation.atfoundation"] :dependencies ["attools" "atpkg.atpkg" "atfoundation.atfoundation"]
:publish-product true :publish-product true
...@@ -49,8 +49,9 @@ ...@@ -49,8 +49,9 @@
:sources ["attools/src/**.swift"] :sources ["attools/src/**.swift"]
:name "attools" :name "attools"
:output-type "static-library" :output-type "static-library"
:dependencies ["atpkg.atpkg"] :dependencies ["atpkg.atpkg" "atenvironment"]
:link-with-product ["atpkg.a"] :link-with-product ["atpkg.a" "atenvironment.a"]
:module-map "synthesized"
:overlays { :overlays {
:bootstrap-osx { :bootstrap-osx {
:bootstrap-only true :bootstrap-only true
...@@ -64,6 +65,27 @@ ...@@ -64,6 +65,27 @@
} }
} }
:atenvironment {
:tool "atllbuild"
:sources ["atenvironment/environment.h" "atenvironment/environment.c" "atenvironment/environment.swift"]
:name "atenvironment"
:output-type "static-library"
:dependencies ["atfoundation.atfoundation"]
:module-map "synthesized"
:link-with-product ["atfoundation.a"]
:overlays {
:bootstrap-osx {
:bootstrap-only true
:llbuildyaml "bootstrap/bootstrap-macosx-atenvironment.swift-build"
}
:bootstrap-linux {
:bootstrap-only true
:link-sdk false