Commit 7f624456 authored by Drew's avatar Drew

Support for importing remote tasks from another file

We have to be careful about how these paths work; because when you
import a new file it is as if your working directory changes.  To
support this, we add a new `importedPath` property to Task that contains
the path where the task is imported (whether local or remote).  This
property is documented to include a trailing slash to avoid various
problems involving relative paths.

We also fix #20 by moving to `collectSources` implemented in atpkg
instead of atllbuild.
parent 47a15793
Pipeline #706 passed with stage
Subproject commit f7817f776e73178ed0c657573b13867acba86e1e
Subproject commit d0dfc60f5edfc625905a760202b5df10c9d6fef4
......@@ -22,7 +22,7 @@ import atpkg
final public class TaskRunner {
private init() {}
static public func runTask(task: Task, package: Package) {
static public func runTask(task: Task, package: Package) {
print("Running task \(task.key)...")
let tool = toolByName(task.tool)
tool.run(task)
......
......@@ -24,31 +24,6 @@ final class ATllbuild : Tool {
case StaticLibrary
}
/**
* This function resolves wildcards in source descriptions to complete values
* - parameter sourceDescriptions: a descriptions of sources such as ["src/**.swift"] */
* - returns: A list of resolved sources such as ["src/a.swift", "src/b.swift"]
*/
func collectSources(sourceDescriptions: [String]) -> [String] {
var sources : [String] = []
for description in sourceDescriptions {
if description.hasSuffix("**.swift") {
let basepath = String(Array(description.characters)[0..<description.characters.count - 9])
let manager = NSFileManager.defaultManager()
let enumerator = manager.enumeratorAtPath(basepath)!
while let source = enumerator.nextObject() as? String {
if source.hasSuffix("swift") {
sources.append(basepath + "/" + source)
}
}
}
else {
sources.append(description)
}
}
return sources
}
/**
* Calculates the llbuild.yaml contents for the given configuration options
* - parameter sources: A resolved list of swift sources
......@@ -193,7 +168,7 @@ final class ATllbuild : Tool {
}
}
guard let sourceDescriptions = task["source"]?.vector?.flatMap({$0.string}) else { fatalError("Can't find sources for atllbuild.") }
let sources = collectSources(sourceDescriptions)
let sources = collectSources(sourceDescriptions, task: task)
guard let name = task["name"]?.string else { fatalError("No name for atllbuild task") }
......
......@@ -10,10 +10,10 @@ commands:
<atllbuild-swiftc>:
tool: swift-compiler
executable: "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc"
inputs: ["atpkg/src/Package.swift", "atpkg/src/parsing/Parser.swift", "atpkg/src/parsing/Scanner.swift", "atpkg/src/parsing/Tokenization.swift"]
sources: ["atpkg/src/Package.swift", "atpkg/src/parsing/Parser.swift", "atpkg/src/parsing/Scanner.swift", "atpkg/src/parsing/Tokenization.swift"]
objects: [".atllbuild/objects/Package.swift.o", ".atllbuild/objects/Parser.swift.o", ".atllbuild/objects/Scanner.swift.o", ".atllbuild/objects/Tokenization.swift.o"]
outputs: ["<atllbuild-swiftc>", ".atllbuild/objects/Package.swift.o", ".atllbuild/objects/Parser.swift.o", ".atllbuild/objects/Scanner.swift.o", ".atllbuild/objects/Tokenization.swift.o"]
inputs: ["atpkg/src/CollectSources.swift", "atpkg/src/Package.swift", "atpkg/src/parsing/Parser.swift", "atpkg/src/parsing/Scanner.swift", "atpkg/src/parsing/Tokenization.swift", "atpkg/src/PathWithTrailingSlash.swift"]
sources: ["atpkg/src/CollectSources.swift", "atpkg/src/Package.swift", "atpkg/src/parsing/Parser.swift", "atpkg/src/parsing/Scanner.swift", "atpkg/src/parsing/Tokenization.swift", "atpkg/src/PathWithTrailingSlash.swift"]
objects: [".atllbuild/objects/CollectSources.swift.o", ".atllbuild/objects/Package.swift.o", ".atllbuild/objects/Parser.swift.o", ".atllbuild/objects/Scanner.swift.o", ".atllbuild/objects/Tokenization.swift.o", ".atllbuild/objects/PathWithTrailingSlash.swift.o"]
outputs: ["<atllbuild-swiftc>", ".atllbuild/objects/CollectSources.swift.o", ".atllbuild/objects/Package.swift.o", ".atllbuild/objects/Parser.swift.o", ".atllbuild/objects/Scanner.swift.o", ".atllbuild/objects/Tokenization.swift.o", ".atllbuild/objects/PathWithTrailingSlash.swift.o"]
is-library: true
module-name: atpkg
module-output-path: .atllbuild/products/atpkg.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/Package.swift.o", ".atllbuild/objects/Parser.swift.o", ".atllbuild/objects/Scanner.swift.o", ".atllbuild/objects/Tokenization.swift.o"]
inputs: ["<atllbuild-swiftc>", ".atllbuild/objects/CollectSources.swift.o", ".atllbuild/objects/Package.swift.o", ".atllbuild/objects/Parser.swift.o", ".atllbuild/objects/Scanner.swift.o", ".atllbuild/objects/Tokenization.swift.o", ".atllbuild/objects/PathWithTrailingSlash.swift.o"]
outputs: ["<atllbuild>", ".atllbuild/products/atpkg.a"]
args: ["/bin/sh","-c",rm -rf .atllbuild/products/atpkg.a; ar cr '.atllbuild/products/atpkg.a' '.atllbuild/objects/Package.swift.o' '.atllbuild/objects/Parser.swift.o' '.atllbuild/objects/Scanner.swift.o' '.atllbuild/objects/Tokenization.swift.o']
args: ["/bin/sh","-c",rm -rf .atllbuild/products/atpkg.a; ar cr '.atllbuild/products/atpkg.a' '.atllbuild/objects/CollectSources.swift.o' '.atllbuild/objects/Package.swift.o' '.atllbuild/objects/Parser.swift.o' '.atllbuild/objects/Scanner.swift.o' '.atllbuild/objects/Tokenization.swift.o' '.atllbuild/objects/PathWithTrailingSlash.swift.o']
description: "Linking Library: .atllbuild/products/atpkg.a"
\ No newline at end of file
......@@ -16,14 +16,11 @@
(package
:name "atbuild"
:import ["atpkg/build.atpkg"]
:configurations {
:bootstrap {
:yes {
:atpkg {
:bootstrapOnly true
:llbuildyaml "bootstrap/bootstrap-macosx-atpkg.swift-build"
}
:attools {
:bootstrapOnly true
:llbuildyaml "bootstrap/bootstrap-macosx-attools.swift-build"
......@@ -43,14 +40,7 @@
:name "atbuild"
:outputType "executable"
:linkWithProduct ["attools.a" "atpkg.a"]
:dependencies ["attools" "atpkg"]
}
:atpkg {
:tool "atllbuild"
:source ["atpkg/src/**.swift"]
:name "atpkg"
:outputType "static-library"
:dependencies ["attools" "atpkg.atpkg"]
}
:attools {
......@@ -58,27 +48,9 @@
:source ["attools/src/**.swift"]
:name "attools"
:outputType "static-library"
:dependencies ["atpkg"]
:dependencies ["atpkg.atpkg"]
:linkWithProduct ["atpkg.a"]
}
}
:atpkg-tests {
:tool "atllbuild"
:dependencies ["atpkg"]
:source ["atpkg/tests/**.swift"]
:name "atpkgtests"
:outputType "executable"
:linkWithProduct ["atpkg.a"]
}
:run-atpkg-tests {
:tool "shell"
:dependencies ["atpkg-tests"]
:script "./.atllbuild/products/atpkgtests"
}
:run-tests {
:dependencies ["run-atpkg-tests"]
:tool "nop" }
}
)
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