-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathPackage.swift
203 lines (179 loc) · 5.82 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
// swift-tools-version:5.10
import Foundation
import PackageDescription
#if os(Windows)
let osIsWindows = true
#else
let osIsWindows = false
#endif
/// Settings to be passed to swiftc for all targets.
let allTargetsSwiftSettings: [SwiftSetting] = [
.unsafeFlags(["-warnings-as-errors"])
]
/// Dependencies for documentation extraction.
///
/// Most people don't need to extract documentation; set `HYLO_ENABLE_DOC_GENERATION` in your
/// environment if you do.
let docGenerationDependency: [Package.Dependency] =
ProcessInfo.processInfo.environment["HYLO_ENABLE_DOC_GENERATION"] != nil
? [.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.1.0")] : []
let package = Package(
name: "Hylo",
platforms: [
.macOS(.v13)
],
products: [
.executable(name: "hc", targets: ["hc"]),
.executable(name: "hylo-demangle", targets: ["hylo-demangle"]),
.library(name: "FrontEnd", targets: ["FrontEnd"]),
],
dependencies: [
.package(
url: "https://github.com/apple/swift-argument-parser.git",
from: "1.1.4"),
.package(
url: "https://github.com/apple/swift-collections.git",
from: "1.0.0"),
.package(
url: "https://github.com/apple/swift-algorithms.git",
from: "1.2.0"),
.package(
url: "https://github.com/hylo-lang/Durian.git",
from: "1.2.0"),
.package(
url: "https://github.com/attaswift/BigInt.git",
from: "5.3.0"),
.package(
url: "https://github.com/hylo-lang/Swifty-LLVM",
branch: "main"),
.package(
url: "https://github.com/apple/swift-format",
from: "508.0.1"),
.package(
url: "https://github.com/SwiftPackageIndex/SPIManifest.git",
from: "0.12.0"),
]
+ docGenerationDependency,
targets: [
// The compiler's executable target.
.executableTarget(
name: "hc",
dependencies: [
"Driver"
],
swiftSettings: allTargetsSwiftSettings),
.executableTarget(
name: "hylo-demangle",
dependencies: [
"IR"
],
swiftSettings: allTargetsSwiftSettings),
.target(
name: "Driver",
dependencies: [
"FrontEnd",
"IR",
"CodeGenLLVM",
"StandardLibrary",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
swiftSettings: allTargetsSwiftSettings),
// Targets related to the compiler's internal library.
.target(
name: "FrontEnd",
dependencies: [
"Utils",
.product(name: "Collections", package: "swift-collections"),
.product(name: "Durian", package: "Durian"),
.product(name: "BigInt", package: "BigInt"),
.product(name: "SwiftyLLVM", package: "Swifty-LLVM"),
],
swiftSettings: allTargetsSwiftSettings),
.target(
name: "IR",
dependencies: ["Utils", "FrontEnd"],
swiftSettings: allTargetsSwiftSettings),
.target(
name: "CodeGenLLVM",
dependencies: [
"FrontEnd",
"IR",
"Utils",
.product(name: "SwiftyLLVM", package: "Swifty-LLVM"),
],
path: "Sources/CodeGen/LLVM",
swiftSettings: allTargetsSwiftSettings),
.target(
name: "Utils",
dependencies: [
.product(name: "BigInt", package: "BigInt"),
.product(name: "Collections", package: "swift-collections"),
.product(name: "Algorithms", package: "swift-algorithms"),
],
swiftSettings: allTargetsSwiftSettings),
.target(
name: "TestUtils",
dependencies: ["FrontEnd", "Driver", "Utils"],
swiftSettings: allTargetsSwiftSettings),
.target(
name: "StandardLibrary",
dependencies: ["FrontEnd", "Utils"],
path: "StandardLibrary",
resources: [.copy("Sources")],
swiftSettings: allTargetsSwiftSettings),
.plugin(
name: "TestGeneratorPlugin", capability: .buildTool(),
// Workaround for SPM bug; see PortableBuildToolPlugin.swift
dependencies: osIsWindows ? [] : ["GenerateHyloFileTests"]),
.executableTarget(
name: "GenerateHyloFileTests",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"Utils",
],
swiftSettings: allTargetsSwiftSettings),
// Test targets.
.testTarget(
name: "UtilsTests",
dependencies: ["Utils", .product(name: "Algorithms", package: "swift-algorithms")],
swiftSettings: allTargetsSwiftSettings),
.testTarget(
name: "DriverTests",
dependencies: ["Driver", "TestUtils"],
swiftSettings: allTargetsSwiftSettings),
.testTarget(
name: "ManglingTests",
dependencies: ["FrontEnd", "IR", "TestUtils", "StandardLibrary"],
swiftSettings: allTargetsSwiftSettings),
.testTarget(
name: "HyloTests",
dependencies: [
"FrontEnd", "IR", "TestUtils", "StandardLibrary", "Utils",
.product(name: "Algorithms", package: "swift-algorithms"),
],
exclude: ["TestCases"],
swiftSettings: allTargetsSwiftSettings,
plugins: ["TestGeneratorPlugin"]),
.testTarget(
name: "EndToEndTests",
dependencies: ["Driver", "TestUtils"],
exclude: ["TestCases"],
swiftSettings: allTargetsSwiftSettings,
plugins: ["TestGeneratorPlugin"]),
.testTarget(
name: "LibraryTests",
dependencies: ["Driver", "TestUtils"],
exclude: ["TestCases"],
swiftSettings: allTargetsSwiftSettings,
plugins: ["TestGeneratorPlugin"]),
]
// On Windows we have a dummy library target that can be used to build all the build tool
// dependencies for non-reentrant builds. See SPMBuildToolSupport/README.md for more info.
+ (osIsWindows
? [
.target(
name: "BuildToolDependencies",
dependencies: ["GenerateHyloFileTests"],
swiftSettings: allTargetsSwiftSettings)
] : []) as [PackageDescription.Target]
)