Commit 87f60470 authored by Drew's avatar Drew

Merge pull request #29 from AnarchyTools/only-platforms

Add only-platforms
parents 4141cc44 3e38cdc0
Pipeline #1846 passed with stage
......@@ -39,18 +39,22 @@ final public class Task {
private var kvp: [String:ParseValue]
public var onlyPlatforms: [String] = []
public enum Option: String {
case Tool = "tool"
case UseOverlays = "use-overlays"
case Overlays = "overlays"
case Dependencies = "dependencies"
case OnlyPlatforms = "only-platforms"
public static var allOptions: [Option] {
return [
Tool,
UseOverlays,
Overlays,
Dependencies
Dependencies,
OnlyPlatforms
]
}
}
......@@ -99,6 +103,14 @@ final public class Task {
if let dep = value.string { self.dependencies.append(dep) }
}
}
if let onlyPlatforms = kvp[Option.OnlyPlatforms.rawValue] {
guard let o = onlyPlatforms.vector else { fatalError("Non-vector \(Option.OnlyPlatforms.rawValue) \(onlyPlatforms)")}
for o in o {
guard case .StringLiteral(let platform) = o else { fatalError("Non-string \(Option.OnlyPlatforms.rawValue) \(o)")}
self.onlyPlatforms.append(platform)
}
}
}
public subscript(key: String) -> ParseValue? {
......
;; This is the most basic of sample files.
(package
:name "basic"
:version "0.1.0-dev"
:tasks {
:build {
:tool "lldb-build"
:name "json-swift"
:output-type "lib"
:sources ["src/**.swift" "lib/**.swift"]
:only-platforms ["linux" "osx"]
}
}
)
; End of the sample.
\ No newline at end of file
......@@ -27,7 +27,8 @@ class PackageTests: Test {
PackageTests.testImportPaths,
PackageTests.testChainedImportOverlays,
PackageTests.nonVectorImport,
PackageTests.testRequireOverlays
PackageTests.testRequireOverlays,
PackageTests.testOnlyPlatforms
]
......@@ -244,4 +245,12 @@ class PackageTests: Test {
try test.assert(false) //no diagnostic
}
}
static func testOnlyPlatforms() throws {
let filepath = Path("tests/collateral/only-platforms.atpkg")
let p = try Package(filepath: filepath, overlay: [], focusOnTask: nil)
guard let task = p.tasks["build"] else { fatalError("No build task")}
try test.assert(task.onlyPlatforms == ["linux","osx"])
}
}
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