Commit a1b02337 authored by Drew's avatar Drew

Support for dependencies.

It's a little naive, but it works in simple cases.

Close #5
parent a07f3660
Pipeline #655 passed with stage
......@@ -24,4 +24,8 @@ tasks:
name: "atbuild"
bootstrapOnly: true
llbuildyaml: "llbuild-linux.yaml"
linkSDK: false
\ No newline at end of file
linkSDK: false
bootstrap:
tool: "nop"
dependency: ["bootstrap-osx", "bootstrap-linux"]
\ No newline at end of file
......@@ -10,19 +10,44 @@
final class Task {
let tool: String ///The tool that implements this task. See Tools.swift
let name: String ///The name of this task as it appears in the configuration file
let dependencies: [String:[Yaml:Yaml]]
let yaml: [Yaml: Yaml] ///The full YAML description of the task
let entireConfig: [Yaml: Yaml] ///The entire configuration of the package
init(yaml: [Yaml:Yaml], name: String) throws {
init(yaml: [Yaml:Yaml], name: String, entireConfig: [Yaml: Yaml]) throws {
self.entireConfig = entireConfig
self.yaml = yaml
self.name = name
guard let tool = yaml["tool"]?.string else {
self.tool = "undefined"
dependencies = [:]
throw AnarchyBuildError.CantParseYaml("Missing task tool")
}
self.tool = tool
if let d = yaml["dependency"]?.array {
var newdeps : [String: [Yaml:Yaml]] = [:]
for dep in d {
guard let depname = dep.string else {
dependencies = [:]
throw AnarchyBuildError.CantParseYaml("\(dep) is not a string")
}
guard let depden = entireConfig["tasks"]?.dictionary?[Yaml(stringLiteral: depname)]?.dictionary else {
dependencies = [:]
throw AnarchyBuildError.CantParseYaml("Trouble loading dependent task \(depname)")
}
newdeps[depname] = depden
}
dependencies = newdeps
}
else { dependencies = [:] }
}
func run() throws {
for dependency in dependencies.keys {
let t = try Task(yaml: dependencies[dependency]!, name: dependency, entireConfig: entireConfig)
try t.run()
}
print("Running task \(name)...")
let tool = try toolByName(self.tool)
try tool.run(yaml)
......
......@@ -36,7 +36,7 @@ print("Building package \(name)...")
func runtask(taskName: String) {
guard let task = yaml["tasks"]?.dictionary else { fatalError("No tasks in YAML") }
guard let defaultTask = task[Yaml(stringLiteral: taskName)]?.dictionary else { fatalError("No \(taskName) task in YAML") }
let t = try! Task(yaml: defaultTask, name: taskName)
let t = try! Task(yaml: defaultTask, name: taskName, entireConfig: yaml)
try! t.run()
}
......
......@@ -10,17 +10,17 @@ commands:
<atllbuild-swiftc>:
tool: swift-compiler
executable: "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc"
inputs: ["cli/src/atllbuild.swift", "cli/src/config.swift", "cli/src/errors.swift", "cli/src/main.swift", "cli/src/PlatformPaths.swift", "cli/src/Shell.swift", "cli/src/Task.swift", "cli/src/Tools.swift", "parsers/yaml/src/Operators.swift", "parsers/yaml/src/Parser.swift", "parsers/yaml/src/Regex.swift", "parsers/yaml/src/Result.swift", "parsers/yaml/src/Tokenizer.swift", "parsers/yaml/src/Yaml.swift"]
sources: ["cli/src/atllbuild.swift", "cli/src/config.swift", "cli/src/errors.swift", "cli/src/main.swift", "cli/src/PlatformPaths.swift", "cli/src/Shell.swift", "cli/src/Task.swift", "cli/src/Tools.swift", "parsers/yaml/src/Operators.swift", "parsers/yaml/src/Parser.swift", "parsers/yaml/src/Regex.swift", "parsers/yaml/src/Result.swift", "parsers/yaml/src/Tokenizer.swift", "parsers/yaml/src/Yaml.swift"]
objects: [".atllbuild/atllbuild.swift.o", ".atllbuild/config.swift.o", ".atllbuild/errors.swift.o", ".atllbuild/main.swift.o", ".atllbuild/PlatformPaths.swift.o", ".atllbuild/Shell.swift.o", ".atllbuild/Task.swift.o", ".atllbuild/Tools.swift.o", ".atllbuild/Operators.swift.o", ".atllbuild/Parser.swift.o", ".atllbuild/Regex.swift.o", ".atllbuild/Result.swift.o", ".atllbuild/Tokenizer.swift.o", ".atllbuild/Yaml.swift.o"]
outputs: ["<atllbuild-swiftc>", ".atllbuild/atllbuild.swift.o", ".atllbuild/config.swift.o", ".atllbuild/errors.swift.o", ".atllbuild/main.swift.o", ".atllbuild/PlatformPaths.swift.o", ".atllbuild/Shell.swift.o", ".atllbuild/Task.swift.o", ".atllbuild/Tools.swift.o", ".atllbuild/Operators.swift.o", ".atllbuild/Parser.swift.o", ".atllbuild/Regex.swift.o", ".atllbuild/Result.swift.o", ".atllbuild/Tokenizer.swift.o", ".atllbuild/Yaml.swift.o"]
inputs: ["cli/src/atllbuild.swift", "cli/src/config.swift", "cli/src/errors.swift", "cli/src/main.swift", "cli/src/Nop.swift", "cli/src/PlatformPaths.swift", "cli/src/Shell.swift", "cli/src/Task.swift", "cli/src/Tools.swift", "parsers/yaml/src/Operators.swift", "parsers/yaml/src/Parser.swift", "parsers/yaml/src/Regex.swift", "parsers/yaml/src/Result.swift", "parsers/yaml/src/Tokenizer.swift", "parsers/yaml/src/Yaml.swift"]
sources: ["cli/src/atllbuild.swift", "cli/src/config.swift", "cli/src/errors.swift", "cli/src/main.swift", "cli/src/Nop.swift", "cli/src/PlatformPaths.swift", "cli/src/Shell.swift", "cli/src/Task.swift", "cli/src/Tools.swift", "parsers/yaml/src/Operators.swift", "parsers/yaml/src/Parser.swift", "parsers/yaml/src/Regex.swift", "parsers/yaml/src/Result.swift", "parsers/yaml/src/Tokenizer.swift", "parsers/yaml/src/Yaml.swift"]
objects: [".atllbuild/atllbuild.swift.o", ".atllbuild/config.swift.o", ".atllbuild/errors.swift.o", ".atllbuild/main.swift.o", ".atllbuild/Nop.swift.o", ".atllbuild/PlatformPaths.swift.o", ".atllbuild/Shell.swift.o", ".atllbuild/Task.swift.o", ".atllbuild/Tools.swift.o", ".atllbuild/Operators.swift.o", ".atllbuild/Parser.swift.o", ".atllbuild/Regex.swift.o", ".atllbuild/Result.swift.o", ".atllbuild/Tokenizer.swift.o", ".atllbuild/Yaml.swift.o"]
outputs: ["<atllbuild-swiftc>", ".atllbuild/atllbuild.swift.o", ".atllbuild/config.swift.o", ".atllbuild/errors.swift.o", ".atllbuild/main.swift.o", ".atllbuild/Nop.swift.o", ".atllbuild/PlatformPaths.swift.o", ".atllbuild/Shell.swift.o", ".atllbuild/Task.swift.o", ".atllbuild/Tools.swift.o", ".atllbuild/Operators.swift.o", ".atllbuild/Parser.swift.o", ".atllbuild/Regex.swift.o", ".atllbuild/Result.swift.o", ".atllbuild/Tokenizer.swift.o", ".atllbuild/Yaml.swift.o"]
module-name: atbuild
module-output-path: .atllbuild/atbuild.swiftmodule
temps-path: .atllbuild//llbuildtmp
other-args: ["-j8"]
<atllbuild>:
tool: shell
inputs: ["<atllbuild-swiftc>", ".atllbuild/atllbuild.swift.o", ".atllbuild/config.swift.o", ".atllbuild/errors.swift.o", ".atllbuild/main.swift.o", ".atllbuild/PlatformPaths.swift.o", ".atllbuild/Shell.swift.o", ".atllbuild/Task.swift.o", ".atllbuild/Tools.swift.o", ".atllbuild/Operators.swift.o", ".atllbuild/Parser.swift.o", ".atllbuild/Regex.swift.o", ".atllbuild/Result.swift.o", ".atllbuild/Tokenizer.swift.o", ".atllbuild/Yaml.swift.o"]
inputs: ["<atllbuild-swiftc>", ".atllbuild/atllbuild.swift.o", ".atllbuild/config.swift.o", ".atllbuild/errors.swift.o", ".atllbuild/main.swift.o", ".atllbuild/Nop.swift.o", ".atllbuild/PlatformPaths.swift.o", ".atllbuild/Shell.swift.o", ".atllbuild/Task.swift.o", ".atllbuild/Tools.swift.o", ".atllbuild/Operators.swift.o", ".atllbuild/Parser.swift.o", ".atllbuild/Regex.swift.o", ".atllbuild/Result.swift.o", ".atllbuild/Tokenizer.swift.o", ".atllbuild/Yaml.swift.o"]
outputs: ["<atllbuild>", ".atllbuild/atbuild"]
args: ["/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc", "-o", ".atllbuild/atbuild", ".atllbuild/atllbuild.swift.o", ".atllbuild/config.swift.o", ".atllbuild/errors.swift.o", ".atllbuild/main.swift.o", ".atllbuild/PlatformPaths.swift.o", ".atllbuild/Shell.swift.o", ".atllbuild/Task.swift.o", ".atllbuild/Tools.swift.o", ".atllbuild/Operators.swift.o", ".atllbuild/Parser.swift.o", ".atllbuild/Regex.swift.o", ".atllbuild/Result.swift.o", ".atllbuild/Tokenizer.swift.o", ".atllbuild/Yaml.swift.o"]
args: ["/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc", "-o", ".atllbuild/atbuild", ".atllbuild/atllbuild.swift.o", ".atllbuild/config.swift.o", ".atllbuild/errors.swift.o", ".atllbuild/main.swift.o", ".atllbuild/Nop.swift.o", ".atllbuild/PlatformPaths.swift.o", ".atllbuild/Shell.swift.o", ".atllbuild/Task.swift.o", ".atllbuild/Tools.swift.o", ".atllbuild/Operators.swift.o", ".atllbuild/Parser.swift.o", ".atllbuild/Regex.swift.o", ".atllbuild/Result.swift.o", ".atllbuild/Tokenizer.swift.o", ".atllbuild/Yaml.swift.o"]
description: Linking executable atbuild
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