-
Notifications
You must be signed in to change notification settings - Fork 6
/
Package.swift
375 lines (336 loc) Β· 11.8 KB
/
Package.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
// swift-tools-version:5.2
import PackageDescription
// MARK: - Target.Dependencies
extension Target.Dependency {
static var bow: Target.Dependency {
.product(name: "Bow", package: "Bow")
}
static var bowEffects: Target.Dependency {
.product(name: "BowEffects", package: "Bow")
}
static var bowOptics: Target.Dependency {
.product(name: "BowOptics", package: "Bow")
}
static var swiftLine: Target.Dependency {
.product(name: "Swiftline", package: "Swiftline")
}
}
extension Target {
var asDependency: Target.Dependency {
.target(name: name)
}
}
// MARK: - Libraries
extension Target {
static var modules: [Target] {
#if os(Linux)
return [
.nefModels,
.nefCommon,
.nefCore,
.nefRender,
.nefMarkdown,
.nefJekyll,
.nefPlaygroundBook,
]
#else
return [
.nefModels,
.nefCommon,
.nefCore,
.nefRender,
.nefMarkdown,
.nefJekyll,
.nefCarbon,
.nefCompiler,
.nefClean,
.nefPlayground,
.nefPlaygroundBook,
]
#endif
}
static var nefModels: Target {
#if os(Linux)
return .target(name: "NefModels",
dependencies: [.bow,
.bowEffects,
.bowOptics],
path: "project/Component/NefModels",
exclude: ["CarbonView.swift"])
#else
return .target(name: "NefModels",
dependencies: [.bow,
.bowEffects,
.bowOptics],
path: "project/Component/NefModels")
#endif
}
static var nefCommon: Target {
.target(name: "NefCommon",
dependencies: [nefModels.asDependency],
path: "project/Component/NefCommon")
}
static var nefCore: Target {
.target(name: "NefCore",
dependencies: [nefCommon.asDependency],
path: "project/Core")
}
static var nefRender: Target {
.target(name: "NefRender",
dependencies: [nefCore.asDependency],
path: "project/Component/NefRender")
}
static var nefMarkdown: Target {
.target(name: "NefMarkdown",
dependencies: [nefRender.asDependency],
path: "project/Component/NefMarkdown")
}
static var nefJekyll: Target {
.target(name: "NefJekyll",
dependencies: [nefRender.asDependency],
path: "project/Component/NefJekyll")
}
static var nefCarbon: Target {
.target(name: "NefCarbon",
dependencies: [nefRender.asDependency],
path: "project/Component/NefCarbon")
}
static var nefCompiler: Target {
.target(name: "NefCompiler",
dependencies: [nefRender.asDependency],
path: "project/Component/NefCompiler")
}
static var nefClean: Target {
.target(name: "NefClean",
dependencies: [nefCommon.asDependency],
path: "project/Component/NefClean")
}
static var nefPlayground: Target {
.target(name: "NefPlayground",
dependencies: [nefCommon.asDependency],
path: "project/Component/NefPlayground")
}
static var nefPlaygroundBook: Target {
.target(name: "NefSwiftPlayground",
dependencies: [nefCommon.asDependency],
path: "project/Component/NefSwiftPlayground")
}
}
extension Target {
static var nef: Target {
#if os(Linux)
return .target(name: "nef",
dependencies: [.swiftLine] + Target.modules.map { $0.asDependency },
path: "project/Component/nef",
exclude: ["CleanAPI.swift",
"CompilerAPI.swift",
"CarbonAPI.swift",
"PlaygroundAPI.swift",
"Instances/MacCompilerShell.swift",
"Instances/MacNefPlaygroundSystem.swift"])
#else
return .target(name: "nef",
dependencies: [.swiftLine] + Target.modules.map { $0.asDependency },
path: "project/Component/nef")
#endif
}
}
// MARK: - Tests
extension Target {
static var tests: [Target] {
[
.coreTests,
]
}
static var coreTests: Target {
.testTarget(name: "CoreTests",
dependencies: [Target.nefCore.asDependency],
path: "project/Tests/CoreTests")
}
}
// MARK: - UI (command-line-tool)
extension Target {
static var ui: [Target] {
[
.cliKit,
.uiMenu,
.uiCompiler,
.uiClean,
.uiMarkdown,
.uiMarkdownPage,
.uiJekyll,
.uiJekyllPage,
.uiCarbon,
.uiCarbonPage,
.uiPlayground,
.uiPlaygroundBook,
]
}
static var cliKit: Target {
.target(name: "CLIKit",
dependencies: [.product(name: "ArgumentParser", package: "swift-argument-parser"),
Target.nef.asDependency],
path: "project/UI",
exclude: ["Nef/main.swift",
"Compiler/main.swift",
"Clean/main.swift",
"Markdown/main.swift",
"MarkdownPage/main.swift",
"Jekyll/main.swift",
"JekyllPage/main.swift",
"Carbon/main.swift",
"CarbonPage/main.swift",
"Playground/main.swift",
"PlaygroundBook/main.swift"])
}
static var uiMenu: Target {
.target(name: "NefMenu",
dependencies: [Target.cliKit.asDependency,
Target.nef.asDependency],
path: "project/UI/Nef",
sources: ["main.swift"])
}
static var uiCompiler: Target {
.target(name: "Compiler",
dependencies: [Target.cliKit.asDependency,
Target.nef.asDependency],
path: "project/UI/Compiler",
sources: ["main.swift"])
}
static var uiClean: Target {
.target(name: "Clean",
dependencies: [Target.cliKit.asDependency,
Target.nef.asDependency],
path: "project/UI/Clean",
sources: ["main.swift"])
}
static var uiMarkdown: Target {
.target(name: "Markdown",
dependencies: [Target.cliKit.asDependency,
Target.nef.asDependency],
path: "project/UI/Markdown",
sources: ["main.swift"])
}
static var uiMarkdownPage: Target {
.target(name: "MarkdownPage",
dependencies: [Target.cliKit.asDependency,
Target.nef.asDependency],
path: "project/UI/MarkdownPage",
sources: ["main.swift"])
}
static var uiJekyll: Target {
.target(name: "Jekyll",
dependencies: [Target.cliKit.asDependency,
Target.nef.asDependency],
path: "project/UI/Jekyll",
sources: ["main.swift"])
}
static var uiJekyllPage: Target {
.target(name: "JekyllPage",
dependencies: [Target.cliKit.asDependency,
Target.nef.asDependency],
path: "project/UI/JekyllPage",
sources: ["main.swift"])
}
static var uiCarbon: Target {
.target(name: "Carbon",
dependencies: [Target.cliKit.asDependency,
Target.nef.asDependency],
path: "project/UI/Carbon",
sources: ["main.swift"])
}
static var uiCarbonPage: Target {
.target(name: "CarbonPage",
dependencies: [Target.cliKit.asDependency,
Target.nef.asDependency],
path: "project/UI/CarbonPage",
sources: ["main.swift"])
}
static var uiPlayground: Target {
.target(name: "Playground",
dependencies: [Target.cliKit.asDependency,
Target.nef.asDependency],
path: "project/UI/Playground",
sources: ["main.swift"])
}
static var uiPlaygroundBook: Target {
.target(name: "PlaygroundBook",
dependencies: [Target.cliKit.asDependency,
Target.nef.asDependency],
path: "project/UI/PlaygroundBook",
sources: ["main.swift"])
}
}
// MARK: - Products
extension Product {
static var nef: Product {
.library(name: "nef", targets: [Target.nef.name,
Target.nefModels.name])
}
static var cli: [Product] {
[
.executable(name: "nef-menu", targets: [Target.uiMenu.name]),
.executable(name: "nefc", targets: [Target.uiCompiler.name]),
.executable(name: "nef-clean", targets: [Target.uiClean.name]),
.executable(name: "nef-markdown", targets: [Target.uiMarkdown.name]),
.executable(name: "nef-markdown-page", targets: [Target.uiMarkdownPage.name]),
.executable(name: "nef-jekyll", targets: [Target.uiJekyll.name]),
.executable(name: "nef-jekyll-page", targets: [Target.uiJekyllPage.name]),
.executable(name: "nef-carbon", targets: [Target.uiCarbon.name]),
.executable(name: "nef-carbon-page", targets: [Target.uiCarbonPage.name]),
.executable(name: "nef-playground", targets: [Target.uiPlayground.name]),
.executable(name: "nef-playground-book", targets: [Target.uiPlaygroundBook.name]),
]
}
}
// MARK: - Package
extension Package.Dependency {
static var dependencies: [Package.Dependency] {
#if os(Linux)
return [
.package(name: "Bow", url: "https://github.com/bow-swift/bow.git", .exact("0.8.0")),
.package(url: "https://github.com/bow-swift/Swiftline.git", .exact("0.5.6")),
]
#else
return [
.package(name: "Bow", url: "https://github.com/bow-swift/bow.git", .exact("0.8.0")),
.package(url: "https://github.com/bow-swift/Swiftline.git", .exact("0.5.6")),
.package(url: "https://github.com/apple/swift-argument-parser", .exact("0.2.1")),
]
#endif
}
}
extension Target {
static var targets: [Target] {
#if os(Linux)
return [
Target.modules,
Target.tests,
[Target.nef],
].flatMap { $0 }
#else
return [
Target.modules,
Target.tests,
Target.ui,
[Target.nef],
].flatMap { $0 }
#endif
}
}
extension Product {
static var products: [Product] {
#if os(Linux)
return [Product.nef]
#else
return [Product.nef] + Product.cli
#endif
}
}
let package = Package(
name: "nef",
platforms: [.macOS(.v10_14)],
products: Product.products,
dependencies: Package.Dependency.dependencies,
targets: Target.targets
)