forked from tuist/tuist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Product.swift
183 lines (168 loc) 路 5.23 KB
/
Product.swift
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import Foundation
public enum Product: String, CustomStringConvertible, CaseIterable, Codable {
case app
case staticLibrary = "static_library"
case dynamicLibrary = "dynamic_library"
case framework
case staticFramework
case unitTests = "unit_tests"
case uiTests = "ui_tests"
case bundle
case commandLineTool
case appExtension = "app_extension"
// case watchApp = "watch_app"
case watch2App = "watch_2_app"
// case watchExtension = "watch_extension"
case watch2Extension = "watch_2_extension"
case tvExtension = "tv_extension"
// case messagesApplication = "messages_application"
case messagesExtension = "messages_extension"
case stickerPackExtension = "sticker_pack_extension"
case appClip
public var caseValue: String {
switch self {
case .app:
return "app"
case .staticLibrary:
return "staticLibrary"
case .dynamicLibrary:
return "dynamicLibrary"
case .framework:
return "framework"
case .staticFramework:
return "staticFramework"
case .unitTests:
return "unitTests"
case .uiTests:
return "uiTests"
case .bundle:
return "bundle"
case .appExtension:
return "appExtension"
// case .watchApp:
// return "watchApp"
case .watch2App:
return "watch2App"
// case .watchExtension:
// return "watchExtension"
case .watch2Extension:
return "watch2Extension"
case .tvExtension:
return "tvExtension"
// case .messagesApplication:
// return "messagesApplication"
case .messagesExtension:
return "messagesExtension"
case .stickerPackExtension:
return "stickerPackExtension"
case .commandLineTool:
return "commandLineTool"
case .appClip:
return "appClip"
}
}
public var description: String {
switch self {
case .app:
return "application"
case .staticLibrary:
return "static library"
case .dynamicLibrary:
return "dynamic library"
case .framework:
return "framework"
case .staticFramework:
return "staticFramework"
case .unitTests:
return "unit tests"
case .uiTests:
return "ui tests"
case .bundle:
return "bundle"
case .appExtension:
return "app extension"
// case .watchApp:
// return "watch application"
case .watch2App:
return "watch 2 application"
// case .watchExtension:
// return "watch extension"
case .watch2Extension:
return "watch 2 extension"
case .tvExtension:
return "tv extension"
// case .messagesApplication:
// return "iMessage application"
case .messagesExtension:
return "iMessage extension"
case .stickerPackExtension:
return "sticker pack extension"
case .commandLineTool:
return "command line tool"
case .appClip:
return "appClip"
}
}
/// Returns true if the target can be ran.
public var runnable: Bool {
switch self {
case .app, .appClip, .commandLineTool, .watch2App:
return true
default:
return false
}
}
/// Returns true if the product is a tests bundle.
public var testsBundle: Bool {
self == .uiTests || self == .unitTests
}
public static func forPlatform(_ platform: Platform) -> Set<Product> {
var base: [Product] = [
.app,
.staticLibrary,
.dynamicLibrary,
.framework,
]
if platform == .iOS {
base.append(.appExtension)
base.append(.stickerPackExtension)
// base.append(.messagesApplication)
base.append(.messagesExtension)
base.append(.appClip)
}
if platform == .tvOS {
base.append(.tvExtension)
}
if platform == .macOS ||
platform == .tvOS ||
platform == .iOS
{
base.append(.unitTests)
base.append(.uiTests)
}
if platform == .macOS {
base.append(.commandLineTool)
}
// if platform == .watchOS {
// base.append(contentsOf: [
// .watchApp,
// .watch2App,
// .watchExtension,
// .watch2Extension,
// ])
// }
return Set(base)
}
public var isStatic: Bool {
[.staticLibrary, .staticFramework].contains(self)
}
public var isFramework: Bool {
[.framework, .staticFramework].contains(self)
}
public var isDynamic: Bool {
[.framework, .dynamicLibrary].contains(self)
}
public func canHostTests() -> Bool {
[.app, .appClip].contains(self)
}
}