change Scheme.Build.targets spec

This commit is contained in:
Yonas Kolb
2017-12-22 18:59:23 +08:00
parent 835a9f137c
commit cb3ffc3d2b
2 changed files with 27 additions and 38 deletions
+8 -11
View File
@@ -396,14 +396,12 @@ Schemes allows for more control than the convenience [Target Scheme](#target-sch
- [ ] ***archive***: The archive action
### Build
- [x] **targets**: **[Build Target]** - A list of targets to build
- [x] **name**: **String** - the name of the target
- [ ] **buildTypes**: **[String]** - A list of build types for this target. The default is all types. The build types are:
- `run`
- `test`
- `profile`
- `analyze`
- `archive`
- [x] **targets**: **String** or **[String]** - A map of target names to build and which build types they should be enabled for. The buildTypes can either be `all`, `none` or an array of the following types:
- `run`
- `test`
- `profile`
- `analyze`
- `archive`
### Common Build Action options
The different actions share some properties:
@@ -422,9 +420,8 @@ scheme:
Production:
build:
targets:
- name: MyTarget1
- name: MyTarget2
buildTypes: [run, archive]
MyTarget1: all
MyTarget2: [run, archive]
run:
config: prod-debug
commandLineArguments: "--option value"
+19 -27
View File
@@ -189,36 +189,28 @@ extension Scheme: NamedJSONDictionaryConvertible {
extension Scheme.Build: JSONObjectConvertible {
public init(jsonDictionary: JSONDictionary) throws {
targets = try jsonDictionary.json(atKeyPath: "targets")
}
}
extension Scheme.BuildTarget: JSONObjectConvertible {
public init(jsonDictionary: JSONDictionary) throws {
target = try jsonDictionary.json(atKeyPath: "target")
if jsonDictionary["buildTypes"] == nil {
buildTypes = BuildType.all
} else if let types: String = jsonDictionary.json(atKeyPath: "buildTypes") {
switch types {
case "all": buildTypes = BuildType.all
case "none": buildTypes = []
case "testing": buildTypes = [.testing, .analyzing]
case "indexing": buildTypes = [.testing, .analyzing, .archiving]
default: buildTypes = BuildType.all
}
} else if let types: [String: Bool] = jsonDictionary.json(atKeyPath: "buildTypes") {
var buildTypes: [BuildType] = []
for (type, build) in types {
if build, let buildType = BuildType.from(jsonValue: type) {
buildTypes.append(buildType)
let targetDictionary: JSONDictionary = try jsonDictionary.json(atKeyPath: "targets")
var targets: [Scheme.BuildTarget] = []
for (target, possibleBuildTypes) in targetDictionary {
let buildTypes: [BuildType]
if let string = possibleBuildTypes as? String {
switch string {
case "all": buildTypes = BuildType.all
case "none": buildTypes = []
case "testing": buildTypes = [.testing, .analyzing]
case "indexing": buildTypes = [.testing, .analyzing, .archiving]
default: buildTypes = BuildType.all
}
} else if let enabledDictionary = possibleBuildTypes as? [String: Bool] {
buildTypes = enabledDictionary.filter { $0.value }.flatMap { BuildType.from(jsonValue: $0.key) }
} else if let array = possibleBuildTypes as? [String] {
buildTypes = array.flatMap(BuildType.from)
} else {
buildTypes = BuildType.all
}
self.buildTypes = buildTypes
} else {
let stringBuildTypes: [String] = try jsonDictionary.json(atKeyPath: "buildTypes")
self.buildTypes = stringBuildTypes.flatMap(BuildType.from)
targets.append(Scheme.BuildTarget(target: target, buildTypes: buildTypes))
}
self.targets = targets.sorted { $0.target < $1.target }
}
}