Commit d871a589 authored by Drew's avatar Drew

Support specifying compile options

Close #4
parent 04e3599e
Pipeline #657 passed with stage
......@@ -25,6 +25,7 @@ tasks:
bootstrapOnly: true
llbuildyaml: "llbuild-linux.yaml"
linkSDK: false
compileOptions: ["-D","CORELIBS_FOUNDATION"]
bootstrap:
tool: "nop"
......
......@@ -41,7 +41,7 @@ final class ATllbuild : Tool {
- parameter workdir: A temporary working directory for `atllbuild` to use
- parameter modulename: The name of the module to be built.
- returns: The string contents for llbuild.yaml suitable for processing by swift-build-tool */
func llbuildyaml(sources: [String], workdir: String, modulename: String, linkSDK: Bool) -> String {
func llbuildyaml(sources: [String], workdir: String, modulename: String, linkSDK: Bool, compileOptions: [String]) -> String {
//this format is largely undocumented, but I reverse-engineered it from SwiftPM.
var yaml = "client:\n name: swift-build\n\n"
......@@ -82,6 +82,7 @@ final class ATllbuild : Tool {
if linkSDK {
args.appendContentsOf(["-sdk", SDKPath])
}
args.appendContentsOf(compileOptions)
yaml += " other-args: \(args)\n"
......@@ -113,6 +114,13 @@ final class ATllbuild : Tool {
try manager.createDirectoryAtPath(workDirectory, withIntermediateDirectories: false, attributes: nil)
//parse arguments
var compileOptions: [String] = []
if let opts = args["compileOptions"]?.array {
for o in opts {
guard let os = o.string else { throw AnarchyBuildError.CantParseYaml("Compile option \(o) is not a string") }
compileOptions.append(os)
}
}
guard let sourceDescriptions = args["source"]?.array?.flatMap({$0.string}) else { throw AnarchyBuildError.CantParseYaml("Can't find sources for atllbuild.") }
let sources = collectSources(sourceDescriptions)
......@@ -142,7 +150,7 @@ final class ATllbuild : Tool {
llbuildyamlpath = workDirectory + "llbuild.yaml"
}
try llbuildyaml(sources, workdir: workDirectory, modulename: name, linkSDK: sdk).writeToFile(llbuildyamlpath, atomically: false, encoding: NSUTF8StringEncoding)
try llbuildyaml(sources, workdir: workDirectory, modulename: name, linkSDK: sdk, compileOptions: compileOptions).writeToFile(llbuildyamlpath, atomically: false, encoding: NSUTF8StringEncoding)
if bootstrapOnly { return }
//now we try running sbt
......
......@@ -17,7 +17,7 @@ commands:
module-name: atbuild
module-output-path: .atllbuild/atbuild.swiftmodule
temps-path: .atllbuild//llbuildtmp
other-args: ["-j8"]
other-args: ["-j8", "-D", "CORELIBS_FOUNDATION"]
<atllbuild>:
tool: shell
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"]
......
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