Commit 162d86b6 authored by Drew's avatar Drew

Implement required overlays

Fixes https://github.com/AnarchyTools/atbuild/issues/32
parent 00150eb9
Pipeline #889 failed with stage
......@@ -272,6 +272,28 @@ final public class Package {
}
}
//error on required overlays
for (_, task) in self.tasks {
if let requiredOverlays_v = task["required-overlays"] {
guard let requiredOverlays = requiredOverlays_v.vector else {
fatalError("Non-vector \(requiredOverlays_v)")
}
nextSet: for overlaySet_v in requiredOverlays {
guard let overlaySet = overlaySet_v.vector else {
fatalError("Non-vector \(overlaySet_v)")
}
for overlay_s in overlaySet {
guard let overlay = overlay_s.string else {
fatalError("Non-string \(overlay_s)")
}
if task.appliedOverlays.contains(overlay) { continue nextSet }
}
print("Task \(task.key) requires at least one of \(overlaySet.map() {$0.string}) but it was not applied. Applied overlays: \(task.appliedOverlays)")
return nil
}
}
}
//load remote tasks
for remotePackage in remotePackages {
for (_, task) in remotePackage.tasks {
......
......@@ -22,7 +22,8 @@ class PackageTests: Test {
PackageTests.testBasic,
PackageTests.testImport,
PackageTests.testOverlays,
PackageTests.testExportedOverlays
PackageTests.testExportedOverlays,
PackageTests.testRequireOverlays
]
let filename = __FILE__
......@@ -137,4 +138,17 @@ class PackageTests: Test {
try test.assert(compileOptions2[5].string == "MOST_AWESOME")
}
static func testRequireOverlays() throws {
let filepath = "./tests/collateral/require_overlays.atpkg"
if let _ = Package(filepath: filepath, overlay: []) {
print("Overlays were not required")
try test.assert(false)
}
guard let _ = Package(filepath: filepath, overlay: ["osx"]) else {
print("Overlays were provided")
try test.assert(false)
fatalError()
}
}
}
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