Commit 7fef48b1 authored by Drew's avatar Drew

Merge pull request #89 from AnarchyTools/atbin

Add atbin support
parents 148c576e 1de8d69a
Pipeline #1812 failed with stage
......@@ -108,7 +108,7 @@ That's all you need to get started! `atbuild` supports many more usecases than
* `--help`, which displays a usage message
* `--clean`, which forces a clean build
* `--toolchain` which specifies a nonstandard toolchain (swift installation). By default we try to guess, but you can override our guess here. The special string `xcode` uses "xcode swift" for building. (Swift 2.2 does not contain all the tools we use, so you need to have a 3.x snapshot installed as well. However, this is a "mostly" xcode-flavored buildchain.)
* `--platform` which specifies the target platform. By default, this is the current platform. Pass a different value (`osx`, `linux`, `ios-x86_64`, `ios-i386`, `ios-arm64`, or `ios-armv7`) to cross-compile, only if your compiler supports it.
* `--platform` which specifies the target platform. By default, this is the current platform. Pass a different value to cross-compile, see [platforms](http://anarchytools.org/docs/platforms.html) for details.
# Building
......
......@@ -118,9 +118,7 @@ if Process.arguments.contains("--help") {
func runTask(taskName: String, package: Package) {
guard let task = package.tasks[taskName] else { fatalError("No \(taskName) task in build configuration.") }
for task in package.prunedDependencyGraph(task: task) {
TaskRunner.runTask(task: task, package: package, toolchain: toolchain)
}
TaskRunner.runTask(task: task, package: package, toolchain: toolchain)
}
......
// 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.
import atpkg
import atfoundation
class PackageAtbin:Tool {
private enum Options: String {
case Name = "name"
case Platforms = "platforms"
case AtllbuildTask = "atllbuild-task"
}
func run(task: Task, toolchain: String) {
guard let n_ = task[Options.Name.rawValue] else {
fatalError("No \(Options.Name.rawValue) for \(task)")
}
guard case .StringLiteral(let name) = n_ else {
fatalError("Non-string \(Options.Name.rawValue) for \(task)")
}
guard let t_ = task[Options.AtllbuildTask.rawValue] else {
fatalError("No \(Options.AtllbuildTask.rawValue) for \(task)")
}
guard case .StringLiteral(let atllbuildTaskName) = t_ else {
fatalError("Non-string \(Options.AtllbuildTask.rawValue) for \(task)")
}
guard let atllbuildTask = task.package.tasks[atllbuildTaskName] else {
fatalError("Unknown atllbuild task \(atllbuildTaskName) for \(task)")
}
//rm atbin if exists
let atbinPath = Path("bin/\(name).atbin")
let _ = try? FS.removeItem(path: atbinPath, recursive: true)
try! FS.createDirectory(path: atbinPath, intermediate: true)
//create working directory for lipo
let workDir = Path(".atllbuild/lipo/")
try! FS.createDirectory(path: workDir, intermediate: true)
//restore old platform before leaving
let oldPlatform = Platform.targetPlatform
defer { Platform.targetPlatform = oldPlatform }
guard case .some(.StringLiteral(let outputTypeString)) = atllbuildTask[ATllbuild.Options.OutputType.rawValue] else {
fatalError("No \(ATllbuild.Options.OutputType.rawValue) for \(atllbuildTask) ")
}
guard let outputType = ATllbuild.OutputType(rawValue: outputTypeString) else {
fatalError("Unknown \(ATllbuild.Options.OutputType.rawValue) \(outputTypeString)")
}
guard case .some(.StringLiteral(let outputName)) = atllbuildTask[ATllbuild.Options.Name.rawValue] else {
fatalError("No \(ATllbuild.Options.Name.rawValue) for \(atllbuildTask)")
}
let payloadFileName: String
switch(outputType) {
case .DynamicLibrary:
payloadFileName = "\(outputName)\(Platform.targetPlatform.dynamicLibraryExtension)"
case .StaticLibrary:
payloadFileName = "\(outputName).a"
case .Executable:
payloadFileName = outputName
}
guard case .some(.Vector(let platformArray)) = task[Options.Platforms.rawValue] else {
fatalError("No \(Options.Platforms.rawValue) for \(task)")
}
var requestedBuildPlatforms : [String] = []
for requestedPlatform in platformArray {
guard case .StringLiteral(let p) = requestedPlatform else {
fatalError("Non-string platform \(requestedPlatform)")
}
requestedBuildPlatforms.append(p)
}
let targetPlatforms: [Platform]
if requestedBuildPlatforms == ["all"] {
targetPlatforms = Platform.targetPlatform.allPlatforms
}else {
targetPlatforms = Platform.targetPlatform.allPlatforms.filter({requestedBuildPlatforms.contains($0.description)})
}
if targetPlatforms.count == 0 {
print("Warning: The intersection of \(requestedBuildPlatforms) and \(Platform.targetPlatform.allPlatforms) is the empty set; won't build atbin")
return
}
//iterate through supported platforms
for platform in targetPlatforms {
Platform.targetPlatform = platform
//run the underlying atbuild task
TaskRunner.runTask(task: atllbuildTask, package: task.package, toolchain: toolchain, force: true)
//copy payload to lipo location
try! FS.copyItem(from: Path(".atllbuild/products/\(payloadFileName)"), to: workDir.join(Path("\(payloadFileName).\(Platform.targetPlatform)")))
let modulePath = Path(".atllbuild/products/\(outputName).swiftmodule")
if FS.fileExists(path: modulePath) {
try! FS.copyItem(from: modulePath, to: atbinPath.join(Path("\(platform).swiftmodule")))
}
let docPath = Path(".atllbuild/products/\(outputName).swiftdoc")
if FS.fileExists(path: docPath) {
try! FS.copyItem(from: docPath, to: atbinPath.join(Path("\(platform).swiftdoc")))
}
let moduleMapPath = Path(".atllbuild/products/\(outputName).modulemap")
if FS.fileExists(path: moduleMapPath) {
try! FS.copyItem(from: moduleMapPath, to: atbinPath.join(Path("module.modulemap")))
}
}
//lipo outputs
switch(oldPlatform) {
case .Linux:
//no lipo, only one arch anyway
try! FS.copyItem(from: workDir.join(Path("\(payloadFileName).\(Platform.targetPlatform)")), to: atbinPath.join(Path(payloadFileName)))
case .OSX, .iOS, .iOSGeneric:
var lipoCmd = "lipo -output bin/\(name).atbin/\(payloadFileName) -create "
for platform in targetPlatforms {
lipoCmd += "-arch \(platform.architecture) .atllbuild/lipo/\(payloadFileName).\(platform) "
}
if system(lipoCmd) != 0 {
fatalError()
}
}
//generate compiled.atpkg
var s = ""
s += "(package\n"
s += ":name \"\(name)\"\n"
s += ":payload \"\(payloadFileName)\"\n"
s += ":platforms ["
for platform in targetPlatforms {
s += "\"\(platform)\" "
}
s += "]\n"
s += ":type \"\(outputType.rawValue)\"\n"
s += ")\n"
try! s.write(to: atbinPath.join(Path("compiled.atpkg")))
}
}
\ No newline at end of file
......@@ -49,10 +49,14 @@ func ==(a: Platform, b: Platform) -> Bool {
}
public enum Platform {
//specific platforms
case OSX
case Linux
case iOS(Architecture)
//generic platforms
case iOSGeneric
public init(string: String) {
switch(string) {
case "osx", "mac":
......@@ -67,6 +71,8 @@ public enum Platform {
self = Platform.iOS(Architecture.armv7)
case "ios-arm64":
self = Platform.iOS(Architecture.arm64)
case "ios":
self = Platform.iOSGeneric
default:
fatalError("Unknown platform \(string)")
......@@ -80,7 +86,7 @@ public enum Platform {
return ["atbuild.platform.osx", "atbuild.platform.mac"]
case .Linux:
return ["atbuild.platform.linux"]
case .iOS:
case .iOS, .iOSGeneric:
return ["atbuild.platform.ios"]
}
}
......@@ -88,7 +94,7 @@ public enum Platform {
///The typical path to a toolchain binary of the platform
var defaultToolchainBinaryPath: String {
switch(self) {
case .OSX, .iOS:
case .OSX, .iOS, .iOSGeneric:
return "\(defaultToolchainPath)/usr/bin/"
case .Linux:
return "\(defaultToolchainPath)/usr/local/bin/"
......@@ -97,7 +103,7 @@ public enum Platform {
public var defaultToolchainPath: String {
switch(self) {
case .OSX, .iOS:
case .OSX, .iOS, .iOSGeneric:
return "/Library/Developer/Toolchains/swift-latest.xctoolchain"
case .Linux:
return "/"
......@@ -114,6 +120,8 @@ public enum Platform {
return "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk"
case .iOS(.armv7), .iOS(.arm64):
return "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk"
case .iOSGeneric:
fatalError("No SDK for generic iOS platform; choose a specific platform or use atbin")
}
}
......@@ -123,12 +131,14 @@ public enum Platform {
return Architecture.x86_64
case .iOS(let arch):
return arch
case .iOSGeneric:
fatalError("No architecture for generic iOS platform; choose a specific platform or use atbin")
}
}
var dynamicLibraryExtension: String {
switch(self) {
case .OSX, .iOS:
case .OSX, .iOS, .iOSGeneric:
return ".dylib"
case .Linux:
return ".so"
......@@ -153,6 +163,17 @@ public enum Platform {
///we may be only emitting a yaml, which the actual build occuring
/// on some other platform than either the host or the target.
public static var buildPlatform: Platform = Platform.hostPlatform
///If the platform is "virtual" (such as iOS), this returns all the sub-platforms.
///Otherwise, it returns the receiver
public var allPlatforms: [Platform] {
switch(self) {
case .OSX, .Linux, .iOS:
return [self]
case .iOSGeneric:
return [Platform.iOS(Architecture.x86_64), Platform.iOS(Architecture.i386), Platform.iOS(Architecture.armv7), Platform.iOS(Architecture.arm64)]
}
}
}
extension Platform: CustomStringConvertible {
......@@ -164,6 +185,8 @@ extension Platform: CustomStringConvertible {
return "linux"
case .iOS(let architecture):
return "ios-\(architecture)"
case .iOSGeneric:
return "ios"
}
}
}
......
......@@ -22,8 +22,23 @@ import atpkg
final public class TaskRunner {
private init() {}
static public func runTask(task: Task, package: Package, toolchain: String) {
print("Running task \(task.qualifiedName) with overlays \(task.appliedOverlays)")
///Holds all tasks run. This is used to avoid duplicates
private static var ranTasks : [String] = []
///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.
///
static public func runTask(task: Task, package: Package, toolchain: String, force: Bool = false) {
for t in package.prunedDependencyGraph(task: task) {
if (!ranTasks.contains(t.qualifiedName)) || force {
TaskRunner.runTaskWithoutDependencies(task: t, package: package, toolchain: toolchain)
ranTasks.append(t.qualifiedName)
}
}
}
static private func runTaskWithoutDependencies(task: Task, package: Package, toolchain: String) {
print("Running task \(task.qualifiedName) with overlays \(task.appliedOverlays) for platform \(Platform.targetPlatform)")
do {
try task.checkRequiredOverlays()
} catch {
......
......@@ -27,7 +27,8 @@ let tools: [String:Tool] = [
"atllbuild": ATllbuild(),
"nop": Nop(),
"xctestrun":XCTestRun(),
"packageframework":PackageFramework()
"packageframework":PackageFramework(),
"packageatbin":PackageAtbin()
]
/**
......
......@@ -69,7 +69,7 @@ class XCTestRun : Tool {
case .Linux:
anarchySystem("\(testExecutable)")
case .iOS:
case .iOS, .iOSGeneric:
fatalError("XCTestRun is not supported for iOS")
}
}
......
......@@ -54,10 +54,10 @@ final class ATllbuild : Tool {
return s
}()
enum OutputType {
case Executable
case StaticLibrary
case DynamicLibrary
enum OutputType: String {
case Executable = "executable"
case StaticLibrary = "static-library"
case DynamicLibrary = "dynamic-library"
}
enum ModuleMapType {
......@@ -188,7 +188,7 @@ final class ATllbuild : Tool {
}
}
private enum Options: String {
enum Options: String {
case Tool = "tool"
case Name = "name"
case Dependencies = "dependencies"
......@@ -286,19 +286,11 @@ final class ATllbuild : Tool {
linkWithProduct.append(p)
}
}
let outputType: OutputType
if task[Options.OutputType.rawValue]?.string == "static-library" {
outputType = .StaticLibrary
}
else if task[Options.OutputType.rawValue]?.string == "executable" {
outputType = .Executable
guard case .some(.StringLiteral(let outputTypeString)) = task[Options.OutputType.rawValue] else {
fatalError("No \(Options.OutputType.rawValue) for task \(task)")
}
else if task[Options.OutputType.rawValue]?.string == "dynamic-library" {
outputType = .DynamicLibrary
}
else {
fatalError("Unknown \(Options.OutputType.rawValue) \(task["outputType"])")
guard let outputType = OutputType(rawValue: outputTypeString) else {
fatalError("Unknown \(Options.OutputType.rawValue) \(outputTypeString)")
}
var compileOptions: [String] = []
......@@ -363,7 +355,7 @@ final class ATllbuild : Tool {
case .Linux:
break
case .iOS:
case .iOS, .iOSGeneric:
fatalError("\(Options.XCTestify.rawValue) is not supported for iOS")
}
}
......@@ -388,7 +380,7 @@ final class ATllbuild : Tool {
case .Linux:
break
case .iOS:
case .iOS, .iOSGeneric:
fatalError("\(Options.XCTestStrict.rawValue) is not supported for iOS")
}
}
......@@ -450,6 +442,8 @@ final class ATllbuild : Tool {
linkOptions.append(contentsOf: ["-Xlinker", "-syslibroot","-Xlinker",Platform.targetPlatform.sdkPath!])
case .OSX, .Linux:
break //not required
case .iOSGeneric:
fatalError("Generic platform iOS cannot be used with atllbuild; choose a specific platform or use atbin")
}
let bootstrapOnly: Bool
......
......@@ -10,10 +10,10 @@ commands:
<atllbuild-swiftc>:
tool: swift-compiler
executable: "/usr/local/bin/swiftc"
inputs: ["attools/src/atllbuild.swift", "attools/src/CustomTool.swift", "attools/src/Nop.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/CustomTool.swift", "attools/src/Nop.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/CustomTool.swift.o", ".atllbuild/objects/Nop.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/CustomTool.swift.o", ".atllbuild/objects/Nop.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: ["attools/src/atllbuild.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/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"]
objects: [".atllbuild/objects/atllbuild.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/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"]
is-library: true
module-name: attools
module-output-path: .atllbuild/products/attools.swiftmodule
......@@ -21,7 +21,7 @@ commands:
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/"]
<atllbuild>:
tool: shell
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/atllbuild.swift.o", ".atllbuild/objects/CustomTool.swift.o", ".atllbuild/objects/Nop.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/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>", ".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/CustomTool.swift.o' '.atllbuild/objects/Nop.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/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']
description: "Linking Library: .atllbuild/products/attools.a"
\ No newline at end of file
......@@ -10,10 +10,10 @@ commands:
<atllbuild-swiftc>:
tool: swift-compiler
executable: "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc"
inputs: ["attools/src/atllbuild.swift", "attools/src/CustomTool.swift", "attools/src/Nop.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/CustomTool.swift", "attools/src/Nop.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/CustomTool.swift.o", ".atllbuild/objects/Nop.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/CustomTool.swift.o", ".atllbuild/objects/Nop.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: ["attools/src/atllbuild.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/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"]
objects: [".atllbuild/objects/atllbuild.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/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"]
is-library: true
module-name: attools
module-output-path: .atllbuild/products/attools.swiftmodule
......@@ -21,7 +21,7 @@ commands:
other-args: ["-j8", "-D", "ATBUILD", "-I", ".atllbuild/products/", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk"]
<atllbuild>:
tool: shell
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/atllbuild.swift.o", ".atllbuild/objects/CustomTool.swift.o", ".atllbuild/objects/Nop.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/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>", ".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/CustomTool.swift.o' '.atllbuild/objects/Nop.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/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']
description: "Linking Library: .atllbuild/products/attools.a"
\ 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.
(package
:name "atbin"
:tasks {
:slib {
:tool "atllbuild"
:name "slib"
:output-type "static-library"
:sources ["lib/**.swift"]
:umbrella-header "lib/lib.h"
:module-map "synthesized"
}
:dlib {
:tool "atllbuild"
:name "dlib"
:output-type "dynamic-library"
:sources ["lib/**.swift"]
:umbrella-header "lib/lib.h"
:module-map "synthesized"
;;installing a dependency here allows us to check
;; a corner case of the platform logic; we want to match
;; the dependencies platforms
:dependencies ["slib"]
:link-with ["slib.a"]
}
:exec {
:tool "atllbuild"
:name "exec"
:output-type "executable"
:sources ["exec/**.swift"]
}
:datbin {
:tool "packageatbin"
:name "dynamicatbin"
:atllbuild-task "dlib"
:platforms ["all"]
}
:ebin {
:tool "packageatbin"
:name "executableatbin"
:atllbuild-task "exec"
:platforms ["all"]
}
:satbin {
:tool "packageatbin"
:name "staticatbin"
:atllbuild-task "slib"
:platforms ["all"]
}
:simatbin {
:tool "packageatbin"
:name "sim"
:atllbuild-task "slib"
:platforms ["ios-x86_64" "ios-i386"]
}
:default {
:tool "nop"
:dependencies ["datbin" "satbin" "ebin" "simatbin"]
}
}
)
print("hello world")
\ No newline at end of file
//arbitrary umbrella header
public class Foo { }
\ No newline at end of file
......@@ -16,6 +16,126 @@ if ! $ATBUILD atbuild --use-overlay static; then
$ATBUILD atbuild
fi
echo "****************ATBIN TEST**************"
cd $DIR/tests/fixtures/atbin
$ATBUILD
#did we build all the things we were supposed to?
if [ "$UNAME" == "Darwin" ]; then
if [ ! -f "bin/dynamicatbin.atbin/osx.swiftmodule" ]; then
echo "Missing swiftmodule"
exit 1
fi
if [ ! -f "bin/dynamicatbin.atbin/osx.swiftdoc" ]; then
echo "Missing swiftdoc"
exit 1
fi
if [ ! -f "bin/dynamicatbin.atbin/dlib.dylib" ]; then
echo "Missing dylib"
exit 1
fi
if [ ! -f "bin/staticatbin.atbin/osx.swiftmodule" ]; then
echo "Missing swiftmodule"
exit 1
fi
if [ ! -f "bin/staticatbin.atbin/osx.swiftdoc" ]; then
echo "Missing swiftdoc"
exit 1
fi
else
if [ ! -f "bin/dynamicatbin.atbin/linux.swiftmodule" ]; then
echo "Missing swiftmodule"
exit 1
fi
if [ ! -f "bin/dynamicatbin.atbin/linux.swiftdoc" ]; then
echo "Missing swiftdoc"
exit 1
fi
if [ ! -f "bin/dynamicatbin.atbin/dlib.so" ]; then
echo "Missing dylib"
exit 1
fi
if [ ! -f "bin/staticatbin.atbin/linux.swiftmodule" ]; then
echo "Missing swiftmodule"
exit 1
fi
if [ ! -f "bin/staticatbin.atbin/linux.swiftdoc" ]; then
echo "Missing swiftdoc"
exit 1
fi
fi
# check non-platform-specific-things
if [ ! -f "bin/staticatbin.atbin/module.modulemap" ]; then
echo "Missing modulemap"
exit 1
fi
if [ ! -f "bin/dynamicatbin.atbin/module.modulemap" ]; then
echo "Missing modulemap"
exit 1
fi
if [ ! -f "bin/staticatbin.atbin/compiled.atpkg" ]; then
echo "Missing compiled.atpkg"
exit 1
fi
if [ ! -f "bin/dynamicatbin.atbin/compiled.atpkg" ]; then
echo "Missing compiled.atpkg"
exit 1
fi
if [ ! -f "bin/executableatbin.atbin/compiled.atpkg" ]; then
echo "Missing compiled.atpkg"
exit 1
fi
if [ ! -f "bin/executableatbin.atbin/exec" ]; then
echo "Missing payload"
exit 1
fi
if [ ! -f "bin/staticatbin.atbin/slib.a" ]; then
echo "Missing payload"
exit 1
fi
if [ "$UNAME" == "Darwin" ]; then
$ATBUILD --platform ios
#check archs
FILE=`file bin/staticatbin.atbin/slib.a | wc -l | bc`
if [ "$FILE" != "5" ]; then
echo "Architecture mismatch (static iOS) $FILE"
exit 1
fi
FILE=`file bin/executableatbin.atbin/exec | wc -l | bc`
if [ "$FILE" != "5" ]; then
echo "Architecture mismatch (executable iOS) $FILE"
exit 1
fi
FILE=`file bin/dynamicatbin.atbin/dlib.dylib | wc -l | bc`
if [ "$FILE" != "5" ]; then
echo "Architecture mismatch (dynamic library iOS) $FILE"
exit 1
fi
FILE=`file bin/sim.atbin/slib.a | wc -l | bc`
if [ "$FILE" != "3" ]; then
echo "Architecture mismatch (sim iOS) $FILE"
exit 1
fi
fi
echo "****************USAGE TEST**************"
cd $DIR/tests/fixtures/nonstandard_package_file
$ATBUILD --help > /tmp/usage.txt || true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment