Commit 1c22e037 authored by Drew's avatar Drew

Add atbin support

atbin is a proposed binary interchange format for atbuild and the
broader AT ecosystem.

atbuild has a weakly standardized input format: `build.atpkg`.  But what
does atbuild, um, actually build?  What's the output format?

There is no weak standard here, or even a convention.  It may build an
executable, a static library, or a dynamic one, or even a framework; it
may emit swiftmodule and swiftdoc files, or not.  A modulemap may or may
not be part of the build products and clients may or may not need it in
their search paths.

The uncertainty here complicates interoperability.  atpm should download
binary libraries, but what actually lives in that tarball?  Some random
dylibs we found in `.atllbuild/products`?

How do we build libraries for "fat" archs (like iOS, with 4 sub-archs)?
How would we write an `atinstall` tool that installs/updates
atpm/atbuild (or makes homebrew packages out of them)?

atbin proposes to answer these questions, providing a simple, portable,
hackable binary interchange format for all platforms and all AT
projects.

An `atbin` is a folder that ends in `.atbin`.  It contains, at least, a
`built.atpkg` file.

`built.atpkg` is clojure syntax identical to the more familiar
`build.atpkg`.  You can include tasks or w/e in there, although why
would want to, I'm not totally sure (this is Anarchy Tools though,
knock yourself out.)  However, the important bit is this:

```clojure
(package
    :name "foo"
    :payload "libFoo.a"
    :platforms ["ios-x86_64" "ios-i386"]
    :type "static-library"
)
```

(Other fields could also be present, this is not a complete enumeration)

This `.atbin` folder will then contain:

* `libFoo.a`, a fat library for the indicated platforms
* (optional) a `ios-x86_64.swiftmodule` and `ios-i386.swiftmodule` file
* (optional) a `ios-x86_64.swiftdoc` and `ios-i386.swiftdoc` file
* (optional) a `module.modulemap` file

You can, of course, build an `.atbin` by hand from existing binaries you
found lying around your disk.  And we may eventually ship an `atbin`
packager for Xcode or SwiftPM projects.

However more practically, we introduce a new tool, `packageatbin`, which
packages an `atbin` payload from atllbuild.

```clojure
:package {
   :tool "packageatbin"

   ;; Generate a mypayload.atbin
   :name "mypayload"

   ;; When used with the new --platform ios, will build a fat binary for all iOS platforms.
   ;; Alternatively specific platforms can be listed here
   :platforms ["all"]

   ;; The atllbuild task to package.
   ;; Special logic will re-run this task for each platform and merge the resulting output.
   :atllbuild-task "myatllbuildtask"
}
```

The obvious application is as an interchange format for prebuilt
`atllbuild` dependencies.  Presently, `atllbuild` can link with the
output of any dependent atllbuild task, but if a library wasn't produced
by a dependent task as part of the current build (but was say produced
on a different computer a month ago) there's no "obvious" way to link to
it.  This PR does not actually include any of that tooling, but it would
be a straightforward extension of this work.

An second application is the building of fat files.  Currently, there is
no mechanism to build a "fat" library or binary in atbuild, or even to
specify that we want one.  Under this PR, we can do it.

A third application is a distribution format for executables.  If an
`.atbin` contains an `executable`, `atpm` (or hypothetical `atinstall`)
could install/update/administrate that executable similar to `homebrew`
or `apt`, and keep all your buildtools (or other random crap) up to
date.  We would need to extend this with version fields and whatnot, but
again, it's straightforward.

An fourth application, and my real motivation, is as an intermediate
binary representation.  An `atbin` can be "downcast" with another tool
to a platform-native format like `deb`, `bottle`, or `Framework`.  This
would allow us to cut debs, rpms, and framework releases with
appropriate AT tools.

One alternative is to adopt an existing "standard", like Framework, for
this purpose.  Indeed, `atbuild` currently produces frameworks on OSX.

There are some complexities of extending frameworks to this case.  For
one, the Framework implementation is warty and involves a lot of
symlinks and things like codesigning.  We don't currently maintain that
code for Linux hosts, nor is the standard especially sensible for Linux,
as it relies on plists and choices basically unpopular on that platform.

For another, frameworks are not really built to house static library or
executable payloads, which are important to atbuild.  There are air-
quote "obvious" ways to extend to nontraditional payloads, but IMO this
is more confusing than it is helpful.  An explicit step to "cast down"
your atbin to a framework lets us check that your framework will
actually make sense to the likes of Xcode.

For a third, it's unclear what platform some random Framework is built
for, and what architectures it supports.  You can find out by scripting
out to platform-specific tools, but it's not portable.

Another alternative is to support multiple payloads/libraries in a
single atbin, "one atbin to rule them all".  However I don't see what we
accomplish there that we don't accomplish with multiple atbins, except
specification complexity.  So let's not do that, at least not initially.

`packageatbin` is included in core primarily because it needs tight,
source-level integration with atllbuild.  In addition to peeking at the
atllbuild options it needs to run the atllbuild task several times in
order to produce fat binaries, which means it has to work around the
usual dependency pruning logic.  For that reason it can't be sensibly
implemented via the current custom tool API.
parent 148c576e
Pipeline #1785 passed with stage
......@@ -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 built.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("built.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/built.atpkg" ]; then
echo "Missing built.atpkg"
exit 1
fi
if [ ! -f "bin/dynamicatbin.atbin/built.atpkg" ]; then
echo "Missing built.atpkg"
exit 1
fi
if [ ! -f "bin/executableatbin.atbin/built.atpkg" ]; then
echo "Missing built.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