Commit 3e38cdc0 authored by Drew's avatar Drew

Add only-platforms

This is a new task-level property to allow the skipping of tasks on platforms other than the ones specified
parent 4141cc44
Pipeline #1845 passed with stage
...@@ -39,18 +39,22 @@ final public class Task { ...@@ -39,18 +39,22 @@ final public class Task {
private var kvp: [String:ParseValue] private var kvp: [String:ParseValue]
public var onlyPlatforms: [String] = []
public enum Option: String { public enum Option: String {
case Tool = "tool" case Tool = "tool"
case UseOverlays = "use-overlays" case UseOverlays = "use-overlays"
case Overlays = "overlays" case Overlays = "overlays"
case Dependencies = "dependencies" case Dependencies = "dependencies"
case OnlyPlatforms = "only-platforms"
public static var allOptions: [Option] { public static var allOptions: [Option] {
return [ return [
Tool, Tool,
UseOverlays, UseOverlays,
Overlays, Overlays,
Dependencies Dependencies,
OnlyPlatforms
] ]
} }
} }
...@@ -99,6 +103,14 @@ final public class Task { ...@@ -99,6 +103,14 @@ final public class Task {
if let dep = value.string { self.dependencies.append(dep) } 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? { 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 { ...@@ -27,7 +27,8 @@ class PackageTests: Test {
PackageTests.testImportPaths, PackageTests.testImportPaths,
PackageTests.testChainedImportOverlays, PackageTests.testChainedImportOverlays,
PackageTests.nonVectorImport, PackageTests.nonVectorImport,
PackageTests.testRequireOverlays PackageTests.testRequireOverlays,
PackageTests.testOnlyPlatforms
] ]
...@@ -244,4 +245,12 @@ class PackageTests: Test { ...@@ -244,4 +245,12 @@ class PackageTests: Test {
try test.assert(false) //no diagnostic 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