Skip to content

Commit 32dc546

Browse files
Upgrade compiler (#155)
* upgrade compiler to support testing search libraries * update to swift 5.2 * extract common actions in compiler shell * change argument order in playground cli * update templates * update templates: auto search testing libraries
1 parent f21daf6 commit 32dc546

File tree

19 files changed

+412
-172
lines changed

19 files changed

+412
-172
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ BUILD_PATH = /tmp/$(TOOL_NAME)/$(version)
88
PREFIX_BIN = $(prefix)/bin
99
PREFIX_TESTS = $(prefix)/share/tests
1010
TAR_FILENAME = $(version).tar.gz
11-
SWIFT_PACKAGE_PATH = project
11+
SWIFT_PACKAGE_PATH = .
1212
BINARIES_PATH = $(BUILD_PATH)/release
13-
BINARIES = nef\
14-
nefc\
13+
BINARIES = nefc\
1514
nef-clean\
1615
nef-playground\
1716
nef-markdown\
@@ -26,6 +25,7 @@ BINARIES = nef\
2625
.PHONY: install
2726
install: uninstall build install_folders
2827
$(foreach binary,$(BINARIES),$(shell install $(BINARIES_PATH)/$(binary) $(PREFIX_BIN)/$(binary)))
28+
@install $(BINARIES_PATH)/nef-menu $(PREFIX_BIN)/nef
2929
@cp -R Documentation.app $(PREFIX_TESTS)
3030

3131
.PHONY: install_folders

Package.swift

+306-30
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,318 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.2
22
import PackageDescription
33

4+
// MARK: - Dependencies
5+
extension Target.Dependency {
6+
static var bow: Target.Dependency {
7+
.product(name: "Bow", package: "Bow")
8+
}
9+
10+
static var bowEffects: Target.Dependency {
11+
.product(name: "BowEffects", package: "Bow")
12+
}
13+
14+
static var bowOptics: Target.Dependency {
15+
.product(name: "BowOptics", package: "Bow")
16+
}
17+
18+
static var swiftLine: Target.Dependency {
19+
.product(name: "Swiftline", package: "Swiftline")
20+
}
21+
22+
static var argumentParser: Target.Dependency {
23+
.product(name: "ArgumentParser", package: "swift-argument-parser")
24+
}
25+
}
26+
27+
extension Target {
28+
var asDependency: Target.Dependency {
29+
.target(name: name)
30+
}
31+
}
32+
33+
// MARK: - Libraries
34+
extension Target {
35+
static var modules: [Target] {
36+
[
37+
.nefModels,
38+
.nefCommon,
39+
.nefCore,
40+
.nefRender,
41+
.nefMarkdown,
42+
.nefJekyll,
43+
.nefCarbon,
44+
.nefCompiler,
45+
.nefClean,
46+
.nefPlayground,
47+
.nefPlaygroundBook,
48+
]
49+
}
50+
51+
static var nefModels: Target {
52+
.target(name: "NefModels",
53+
dependencies: [.bow,
54+
.bowEffects,
55+
.bowOptics],
56+
path: "project/Component/NefModels")
57+
}
58+
59+
static var nefCommon: Target {
60+
.target(name: "NefCommon",
61+
dependencies: [nefModels.asDependency],
62+
path: "project/Component/NefCommon")
63+
}
64+
65+
static var nefCore: Target {
66+
.target(name: "NefCore",
67+
dependencies: [nefCommon.asDependency],
68+
path: "project/Core")
69+
}
70+
71+
static var nefRender: Target {
72+
.target(name: "NefRender",
73+
dependencies: [nefCore.asDependency],
74+
path: "project/Component/NefRender")
75+
}
76+
77+
static var nefMarkdown: Target {
78+
.target(name: "NefMarkdown",
79+
dependencies: [nefRender.asDependency],
80+
path: "project/Component/NefMarkdown")
81+
82+
}
83+
static var nefJekyll: Target {
84+
.target(name: "NefJekyll",
85+
dependencies: [nefRender.asDependency],
86+
path: "project/Component/NefJekyll")
87+
}
88+
89+
static var nefCarbon: Target {
90+
.target(name: "NefCarbon",
91+
dependencies: [nefRender.asDependency],
92+
path: "project/Component/NefCarbon")
93+
}
94+
95+
static var nefCompiler: Target {
96+
.target(name: "NefCompiler",
97+
dependencies: [nefRender.asDependency],
98+
path: "project/Component/NefCompiler")
99+
}
100+
101+
static var nefClean: Target {
102+
.target(name: "NefClean",
103+
dependencies: [nefCommon.asDependency],
104+
path: "project/Component/NefClean")
105+
}
106+
107+
static var nefPlayground: Target {
108+
.target(name: "NefPlayground",
109+
dependencies: [nefCommon.asDependency],
110+
path: "project/Component/NefPlayground")
111+
}
112+
113+
static var nefPlaygroundBook: Target {
114+
.target(name: "NefSwiftPlayground",
115+
dependencies: [nefCommon.asDependency],
116+
path: "project/Component/NefSwiftPlayground")
117+
}
118+
}
119+
120+
extension Target {
121+
static var nef: Target {
122+
.target(name: "nef",
123+
dependencies: [.swiftLine] + Target.modules.map { $0.asDependency },
124+
path: "project/Component/nef")
125+
}
126+
}
127+
128+
// MARK: - Tests
129+
extension Target {
130+
static var tests: [Target] {
131+
[
132+
.coreTests,
133+
]
134+
}
135+
136+
static var coreTests: Target {
137+
.testTarget(name: "CoreTests",
138+
dependencies: [Target.nefCore.asDependency],
139+
path: "project/Tests/CoreTests")
140+
}
141+
}
142+
143+
// MARK: - UI (command-line-tool)
144+
extension Target {
145+
static var ui: [Target] {
146+
[
147+
.cliKit,
148+
.uiMenu,
149+
.uiCompiler,
150+
.uiClean,
151+
.uiMarkdown,
152+
.uiMarkdownPage,
153+
.uiJekyll,
154+
.uiJekyllPage,
155+
.uiCarbon,
156+
.uiCarbonPage,
157+
.uiPlayground,
158+
.uiPlaygroundBook,
159+
]
160+
}
161+
162+
static var cliKit: Target {
163+
.target(name: "CLIKit",
164+
dependencies: [.argumentParser,
165+
Target.nef.asDependency],
166+
path: "project/UI",
167+
exclude: ["Nef/main.swift",
168+
"Compiler/main.swift",
169+
"Clean/main.swift",
170+
"Markdown/main.swift",
171+
"MarkdownPage/main.swift",
172+
"Jekyll/main.swift",
173+
"JekyllPage/main.swift",
174+
"Carbon/main.swift",
175+
"CarbonPage/main.swift",
176+
"Playground/main.swift",
177+
"PlaygroundBook/main.swift"])
178+
}
179+
180+
static var uiMenu: Target {
181+
.target(name: "NefMenu",
182+
dependencies: [Target.cliKit.asDependency,
183+
Target.nef.asDependency],
184+
path: "project/UI/Nef",
185+
sources: ["main.swift"])
186+
}
187+
188+
static var uiCompiler: Target {
189+
.target(name: "Compiler",
190+
dependencies: [Target.cliKit.asDependency,
191+
Target.nef.asDependency],
192+
path: "project/UI/Compiler",
193+
sources: ["main.swift"])
194+
}
195+
196+
static var uiClean: Target {
197+
.target(name: "Clean",
198+
dependencies: [Target.cliKit.asDependency,
199+
Target.nef.asDependency],
200+
path: "project/UI/Clean",
201+
sources: ["main.swift"])
202+
}
203+
204+
static var uiMarkdown: Target {
205+
.target(name: "Markdown",
206+
dependencies: [Target.cliKit.asDependency,
207+
Target.nef.asDependency],
208+
path: "project/UI/Markdown",
209+
sources: ["main.swift"])
210+
}
211+
212+
static var uiMarkdownPage: Target {
213+
.target(name: "MarkdownPage",
214+
dependencies: [Target.cliKit.asDependency,
215+
Target.nef.asDependency],
216+
path: "project/UI/MarkdownPage",
217+
sources: ["main.swift"])
218+
}
219+
220+
static var uiJekyll: Target {
221+
.target(name: "Jekyll",
222+
dependencies: [Target.cliKit.asDependency,
223+
Target.nef.asDependency],
224+
path: "project/UI/Jekyll",
225+
sources: ["main.swift"])
226+
}
227+
228+
static var uiJekyllPage: Target {
229+
.target(name: "JekyllPage",
230+
dependencies: [Target.cliKit.asDependency,
231+
Target.nef.asDependency],
232+
path: "project/UI/JekyllPage",
233+
sources: ["main.swift"])
234+
}
235+
236+
static var uiCarbon: Target {
237+
.target(name: "Carbon",
238+
dependencies: [Target.cliKit.asDependency,
239+
Target.nef.asDependency],
240+
path: "project/UI/Carbon",
241+
sources: ["main.swift"])
242+
}
243+
244+
static var uiCarbonPage: Target {
245+
.target(name: "CarbonPage",
246+
dependencies: [Target.cliKit.asDependency,
247+
Target.nef.asDependency],
248+
path: "project/UI/CarbonPage",
249+
sources: ["main.swift"])
250+
}
251+
252+
static var uiPlayground: Target {
253+
.target(name: "Playground",
254+
dependencies: [Target.cliKit.asDependency,
255+
Target.nef.asDependency],
256+
path: "project/UI/Playground",
257+
sources: ["main.swift"])
258+
}
259+
260+
static var uiPlaygroundBook: Target {
261+
.target(name: "PlaygroundBook",
262+
dependencies: [Target.cliKit.asDependency,
263+
Target.nef.asDependency],
264+
path: "project/UI/PlaygroundBook",
265+
sources: ["main.swift"])
266+
}
267+
}
268+
269+
// MARK: - Products
270+
extension Product {
271+
static var nef: Product {
272+
.library(name: "nef", targets: [Target.nef.name,
273+
Target.nefModels.name])
274+
}
275+
276+
static var cli: [Product] {
277+
[
278+
.executable(name: "nef-menu", targets: [Target.uiMenu.name]),
279+
.executable(name: "nefc", targets: [Target.uiCompiler.name]),
280+
.executable(name: "nef-clean", targets: [Target.uiClean.name]),
281+
.executable(name: "nef-markdown", targets: [Target.uiMarkdown.name]),
282+
.executable(name: "nef-markdown-page", targets: [Target.uiMarkdownPage.name]),
283+
.executable(name: "nef-jekyll", targets: [Target.uiJekyll.name]),
284+
.executable(name: "nef-jekyll-page", targets: [Target.uiJekyllPage.name]),
285+
.executable(name: "nef-carbon", targets: [Target.uiCarbon.name]),
286+
.executable(name: "nef-carbon-page", targets: [Target.uiCarbonPage.name]),
287+
.executable(name: "nef-playground", targets: [Target.uiPlayground.name]),
288+
.executable(name: "nef-playground-book", targets: [Target.uiPlaygroundBook.name]),
289+
]
290+
}
291+
}
292+
293+
4294
let package = Package(
5295
name: "nef",
296+
6297
platforms: [
7298
.macOS(.v10_14),
8299
],
300+
9301
products: [
10-
.library(name: "nef", targets: ["nef", "NefModels"]),
11-
],
302+
[Product.nef],
303+
Product.cli,
304+
].flatMap { $0 },
305+
12306
dependencies: [
13-
.package(url: "https://github.com/bow-swift/bow", .branch("master")),
14-
.package(url: "https://github.com/bow-swift/Swiftline", .exact("0.5.4")),
307+
.package(name: "Bow", url: "https://github.com/bow-swift/bow.git", .branch("master")),
308+
.package(url: "https://github.com/bow-swift/Swiftline.git", .exact("0.5.5")),
309+
.package(url: "https://github.com/apple/swift-argument-parser", .exact("0.0.5")),
15310
],
311+
16312
targets: [
17-
.target(name: "NefModels", dependencies: ["Bow", "BowEffects", "BowOptics"], path: "project/Component/NefModels", publicHeadersPath: "Support Files"),
18-
.target(name: "NefCommon", dependencies: ["NefModels"], path: "project/Component/NefCommon", publicHeadersPath: "Support Files"),
19-
.target(name: "NefCore", dependencies: ["NefCommon"], path: "project/Core", publicHeadersPath: "Support Files"),
20-
.target(name: "NefRender", dependencies: ["NefCore"], path: "project/Component/NefRender", publicHeadersPath: "Support Files"),
21-
.target(name: "NefMarkdown", dependencies: ["NefRender"], path: "project/Component/NefMarkdown", publicHeadersPath: "Support Files"),
22-
.target(name: "NefJekyll", dependencies: ["NefRender"], path: "project/Component/NefJekyll", publicHeadersPath: "Support Files"),
23-
.target(name: "NefCarbon", dependencies: ["NefRender"], path: "project/Component/NefCarbon", publicHeadersPath: "Support Files"),
24-
.target(name: "NefCompiler", dependencies: ["NefRender"], path: "project/Component/NefCompiler", publicHeadersPath: "Support Files"),
25-
.target(name: "NefClean", dependencies: ["NefCommon"], path: "project/Component/NefClean", publicHeadersPath: "Support Files"),
26-
.target(name: "NefPlayground", dependencies: ["NefCommon"], path: "project/Component/NefPlayground", publicHeadersPath: "Support Files"),
27-
.target(name: "NefSwiftPlayground", dependencies: ["NefCommon"], path: "project/Component/NefSwiftPlayground", publicHeadersPath: "Support Files"),
28-
29-
.target(name: "nef",
30-
dependencies: ["Swiftline",
31-
"NefCore",
32-
"NefCompiler",
33-
"NefClean",
34-
"NefMarkdown",
35-
"NefJekyll",
36-
"NefCarbon",
37-
"NefPlayground",
38-
"NefSwiftPlayground"],
39-
path: "project/Component/nef",
40-
publicHeadersPath: "Support Files"),
41-
]
313+
Target.modules,
314+
Target.tests,
315+
Target.ui,
316+
[Target.nef],
317+
].flatMap { $0 }
42318
)

project/Component/NefCompiler/Algebras/CompilerShell.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ public protocol CompilerShell {
1010
func carthage(project: URL, platform: Platform, cached: Bool) -> IO<CompilerShellError, Void>
1111
func build(xcworkspace: URL, scheme: String, platform: Platform, derivedData: URL, log: URL) -> IO<CompilerShellError, Void>
1212
func dependencies(platform: Platform) -> IO<CompilerShellError, URL>
13-
func compile(file: URL, sources: [URL], platform: Platform, frameworks: [URL], linkers: [URL], output: URL, log: URL) -> IO<CompilerShellError, Void>
13+
func libraries(platform: Platform) -> IO<CompilerShellError, URL>
14+
func compile(file: URL, options: CompilerOptions, output: URL, log: URL) -> IO<CompilerShellError, Void>
1415
}

0 commit comments

Comments
 (0)