Commit d2f7b25e authored by Drew's avatar Drew
parent a83fb695
......@@ -19,7 +19,7 @@ final public class Task {
public var tool: String = "atllbuild"
public var importedPath: String ///the directory at which the task was imported. This includes a trailing /.
var mixins: [String] = [] ///The mixins we should apply to this task
var overlays: [String] = [] ///The overlays we should apply to this task
public var allKeys: [String]
......@@ -32,12 +32,12 @@ final public class Task {
self.key = name
self.allKeys = [String](kvp.keys)
self.tool = kvp["tool"]?.string ?? self.tool
if let mixins = kvp["mixins"]?.vector {
for mixin in mixins {
if let overlays = kvp["overlays"]?.vector {
for mixin in overlays {
guard let str = mixin.string else {
fatalError("Non-string mixin \(mixin)")
}
self.mixins.append(str)
self.overlays.append(str)
}
}
......@@ -61,7 +61,7 @@ final public class Package {
public var version: String = ""
public var tasks: [String:Task] = [:]
var mixins: [String: ParseValue] = [:]
var overlays: [String: ParseValue] = [:]
var adjustedImportPath: String = ""
/**Calculate the pruned dependency graph for the given task
......@@ -130,7 +130,7 @@ final public class Package {
guard let str = mixin.string else {
fatalError("Non-string mixin \(mixin)")
}
task.mixins.append(str)
task.overlays.append(str)
usedConfigurations.append(requestedConfiguration)
}
}
......@@ -160,24 +160,24 @@ final public class Package {
}
}
//load remote mixins
//load remote overlays
for remotePackage in remotePackages {
for (mixinName, value) in remotePackage.mixins {
self.mixins["\(remotePackage.name).\(mixinName)"] = value
for (mixinName, value) in remotePackage.overlays {
self.overlays["\(remotePackage.name).\(mixinName)"] = value
}
}
if let mixins = type.properties["mixins"]?.map {
for (name, mixin) in mixins {
self.mixins[name] = mixin
if let overlays = type.properties["overlays"]?.map {
for (name, mixin) in overlays {
self.overlays[name] = mixin
}
}
//swap in mixins
//swap in overlays
for (name, task) in self.tasks {
for mixinName in task.mixins {
guard let mixin = mixins[mixinName]?.map else {
fatalError("Can't find mixin named \(mixinName) in \(mixins)")
for mixinName in task.overlays {
guard let mixin = overlays[mixinName]?.map else {
fatalError("Can't find mixin named \(mixinName) in \(overlays)")
}
for (optionName, optionValue) in mixin {
guard let vectorValue = optionValue.vector else {
......
;; A mixin sample file
(package
:name "mixin"
:name "overlay"
:version "0.1.0-dev"
:mixins {
:sample-mixin {
:overlays {
:sample-overlay {
:compileOptions ["-D" "MORE_AWESOME"]
}
:sample-mixin-two {
:sample-overlay-two {
:compileOptions ["-D" "MOST_AWESOME"]
}
}
......@@ -20,9 +20,9 @@
:output-type "lib"
:source [ "src/**.swift" "lib/**.swift" ]
:compileOptions ["-D" "AWESOME"]
:mixins ["sample-mixin"]
:overlays ["sample-overlay"]
:configurations {
:awesome ["sample-mixin-two"]
:awesome ["sample-overlay-two"]
}
}
}
......
(package
:name "mixins_dst"
:name "overlays_dst"
:version "0.1.0-dev"
:mixins {
:exported-mixin {
:overlays {
:exported-overlay {
:compileOptions ["-D" "MOST_AWESOME"]
}
}
......
;; A mixin sample file
;; An overlay sample file
(package
:name "mixins_src"
:name "overlays_src"
:version "0.1.0-dev"
:import ["mixins_dst.atpkg"]
:import ["overlays_dst.atpkg"]
:mixins {
:sample-mixin {
:overlays {
:sample-overlay {
:compileOptions ["-D" "MORE_AWESOME"]
}
}
......@@ -18,7 +18,7 @@
:output-type "lib"
:source [ "src/**.swift" "lib/**.swift" ]
:compileOptions ["-D" "AWESOME"]
:mixins ["sample-mixin" "mixins_dst.exported-mixin"]
:overlays ["sample-overlay" "overlays_dst.exported-overlay"]
}
}
)
......
......@@ -21,8 +21,8 @@ class PackageTests: Test {
let tests = [
PackageTests.testBasic,
PackageTests.testImport,
PackageTests.testMixins,
PackageTests.testExportedMixins
PackageTests.testOverlays,
PackageTests.testExportedOverlays
]
let filename = __FILE__
......@@ -60,8 +60,8 @@ class PackageTests: Test {
try test.assert(package.tasks["import_dst.build"]!.importedPath == "./tests/collateral/")
}
static func testMixins() throws {
let filepath = "./tests/collateral/mixins.atpkg"
static func testOverlays() throws {
let filepath = "./tests/collateral/overlays.atpkg"
guard let package = Package(filepath: filepath, configurations: [:]) else { print("error"); try test.assert(false); return }
guard let compileOptions = package.tasks["build"]?["compileOptions"]?.vector else {
fatalError("No compile options?")
......@@ -86,8 +86,8 @@ class PackageTests: Test {
}
static func testExportedMixins() throws {
let filepath = "./tests/collateral/mixins_src.atpkg"
static func testExportedOverlays() throws {
let filepath = "./tests/collateral/overlays_src.atpkg"
guard let package2 = Package(filepath: filepath, configurations: [:]) else { print("error"); try test.assert(false); return }
guard let compileOptions2 = package2.tasks["build"]?["compileOptions"]?.vector else {
......
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