forked from yonaskolb/XcodeGen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAggregateTarget.swift
More file actions
96 lines (85 loc) · 3.18 KB
/
AggregateTarget.swift
File metadata and controls
96 lines (85 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import Foundation
import JSONUtilities
import XcodeProj
public struct AggregateTarget: ProjectTarget {
public var name: String
public var type: PBXProductType = .none
public var targets: [String]
public var settings: Settings
public var buildScripts: [BuildScript]
public var buildToolPlugins: [BuildToolPlugin]
public var configFiles: [String: String]
public var scheme: TargetScheme?
public var attributes: [String: Any]
public init(
name: String,
targets: [String],
settings: Settings = .empty,
configFiles: [String: String] = [:],
buildScripts: [BuildScript] = [],
buildToolPlugins: [BuildToolPlugin] = [],
scheme: TargetScheme? = nil,
attributes: [String: Any] = [:]
) {
self.name = name
self.targets = targets
self.settings = settings
self.configFiles = configFiles
self.buildScripts = buildScripts
self.buildToolPlugins = buildToolPlugins
self.scheme = scheme
self.attributes = attributes
}
}
extension AggregateTarget: CustomStringConvertible {
public var description: String {
"\(name)\(targets.isEmpty ? "" : ": \(targets.joined(separator: ", "))")"
}
}
extension AggregateTarget: Equatable {
public static func == (lhs: AggregateTarget, rhs: AggregateTarget) -> Bool {
lhs.name == rhs.name &&
lhs.targets == rhs.targets &&
lhs.settings == rhs.settings &&
lhs.configFiles == rhs.configFiles &&
lhs.buildScripts == rhs.buildScripts &&
lhs.buildToolPlugins == rhs.buildToolPlugins &&
lhs.scheme == rhs.scheme &&
NSDictionary(dictionary: lhs.attributes).isEqual(to: rhs.attributes)
}
}
extension AggregateTarget: NamedJSONDictionaryConvertible {
public init(name: String, jsonDictionary: JSONDictionary) throws {
self.name = jsonDictionary.json(atKeyPath: "name") ?? name
targets = jsonDictionary.json(atKeyPath: "targets") ?? []
settings = try BuildSettingsParser(jsonDictionary: jsonDictionary).parse()
configFiles = jsonDictionary.json(atKeyPath: "configFiles") ?? [:]
buildScripts = jsonDictionary.json(atKeyPath: "buildScripts") ?? []
buildToolPlugins = jsonDictionary.json(atKeyPath: "buildToolPlugins") ?? []
scheme = jsonDictionary.json(atKeyPath: "scheme")
attributes = jsonDictionary.json(atKeyPath: "attributes") ?? [:]
}
}
extension AggregateTarget: JSONEncodable {
public func toJSONValue() -> Any {
[
"settings": settings.toJSONValue(),
"targets": targets,
"configFiles": configFiles,
"attributes": attributes,
"buildScripts": buildScripts.map { $0.toJSONValue() },
"buildToolPlugins": buildToolPlugins.map { $0.toJSONValue() },
"scheme": scheme?.toJSONValue(),
] as [String: Any?]
}
}
extension AggregateTarget: PathContainer {
static var pathProperties: [PathProperty] {
[
.dictionary([
.string("configFiles"),
.object("buildScripts", BuildScript.pathProperties),
]),
]
}
}