Repository navigation
Expand file tree
/
Copy pathPackage.swift
More file actions
330 lines (318 loc) · 12 KB
/
Copy pathPackage.swift
File metadata and controls
330 lines (318 loc) · 12 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
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
// swift-tools-version:6.4
import PackageDescription
import CompilerPluginSupport
/// Targets marked as shared must compile both as full Swift and as Embedded
/// Swift (`--swift-sdk swift-6.4.2-RELEASE_wasm-embedded`). Embedded mode is
/// selected by the Swift SDK, not here, so the same targets also build for
/// host tests.
let package = Package(
name: "AppRuntime",
platforms: [
.macOS(.v12),
.iOS(.v15),
],
products: [
// Shared: C ABI, wire model, guest library and macros.
.library(name: "CRuntime", targets: ["CRuntime"]),
.library(name: "RuntimeABI", targets: ["RuntimeABI"]),
.library(name: "DynamicRuntime", targets: ["DynamicRuntime"]),
// Shared: runtime core with the Swift-registry backend.
.library(name: "RuntimeCore", targets: ["RuntimeCore"]),
.library(name: "RuntimeNative", targets: ["RuntimeNative"]),
// Host only: what every native host shares (the app's keys, the
// startup checks, modules and the generic built-ins).
.library(name: "RuntimeHost", targets: ["RuntimeHost"]),
// Shared: portable provider contracts (declarations; hosts implement them).
.library(name: "DynamicBluetooth", targets: ["DynamicBluetooth"]),
.library(name: "DynamicDevice", targets: ["DynamicDevice"]),
.library(name: "DynamicLocation", targets: ["DynamicLocation"]),
.library(name: "DynamicMotion", targets: ["DynamicMotion"]),
.library(name: "DynamicNetworking", targets: ["DynamicNetworking"]),
.library(name: "DynamicNFC", targets: ["DynamicNFC"]),
.library(name: "DynamicFormatting", targets: ["DynamicFormatting"]),
// Shared: Observation stopgap, render IR and renderer contract, and the
// SwiftUI frontend (§5.3, §9). Guest builds name the Observation and
// SwiftUI modules `Observation` and `SwiftUI`.
.library(name: "DynamicObservation", targets: ["DynamicObservation"]),
.library(name: "DynamicUI", targets: ["DynamicUI"]),
.library(name: "DynamicSwiftUI", targets: ["DynamicSwiftUI"]),
// Linux: bundle model and sandboxing launcher.
.library(name: "AppRuntime", targets: ["AppRuntime"]),
.executable(name: "bundle-runtime", targets: ["BundleRuntime"]),
// Build machine: the types App.swift manifests use (§7.1).
.library(name: "AppManifest", targets: ["AppManifest"]),
// Example guest app. Scripts/guest.py builds its slices and bundle.
.library(name: "ExampleApp", type: .static, targets: ["ExampleApp"]),
// The example app's contracts, for the linked-slice tests.
.library(name: "ExampleContracts", targets: ["ExampleContracts"]),
// Example UI guest app (§9). Scripts/guest.py builds its slices.
.library(name: "ExampleUI", type: .static, targets: ["ExampleUI"]),
// Example host contracts, for tests in nested packages (Packages/).
.library(name: "ExampleHost", targets: ["ExampleHost"]),
],
traits: [
.trait(
name: "GuestExports",
description: "DynamicRuntime defines the rt_dispatch and rt_finalize exports. Guests need it; a host that links an app's native slice turns it off, because the slice defines them."
),
.default(enabledTraits: ["GuestExports"]),
],
dependencies: [
.package(url: "https://github.com/swiftlang/swift-syntax.git", "603.0.0"..<"605.0.0"),
.package(url: "https://github.com/PureSwift/Bluetooth.git", from: "8.2.1"),
],
targets: [
// MARK: - Shared (Embedded Swift compatible)
.target(
name: "CRuntime"
),
.target(
name: "RuntimeABI",
linkerSettings: [
// Embedded String comparison and hashing need Unicode tables.
.linkedLibrary("swiftUnicodeDataTables", .when(platforms: [.wasi])),
]
),
.macro(
name: "DynamicRuntimeMacros",
dependencies: [
"RuntimeABI",
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
]
),
.macro(
name: "ObservationMacros",
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
]
),
.target(
name: "DynamicObservation",
dependencies: ["ObservationMacros"]
),
.target(
name: "DynamicSwiftUI",
dependencies: ["DynamicRuntime", "DynamicObservation", "DynamicUI"]
),
.target(
name: "DynamicRuntime",
dependencies: [
"CRuntime",
"RuntimeABI",
"DynamicRuntimeMacros",
]
),
.target(
name: "RuntimeCore",
dependencies: [
"RuntimeABI",
]
),
.target(
name: "RuntimeNative",
dependencies: [
"CRuntime",
"RuntimeCore",
"DynamicRuntime",
]
),
.target(
name: "RuntimeHost",
dependencies: [
"CRuntime",
"RuntimeABI",
"DynamicRuntime",
"RuntimeNative",
]
),
// MARK: - Contracts
.target(
name: "DynamicDevice",
dependencies: ["DynamicRuntime"],
path: "Contracts/DynamicDevice"
),
.testTarget(
name: "DynamicDeviceTests",
// RuntimeNative supplies the rt_* symbols the proxies link against.
dependencies: ["DynamicDevice", "RuntimeNative"]
),
.target(
name: "DynamicBluetooth",
dependencies: [
"DynamicRuntime",
.product(name: "Bluetooth", package: "Bluetooth"),
.product(name: "BluetoothGATT", package: "Bluetooth"),
],
path: "Contracts/DynamicBluetooth"
),
.testTarget(
name: "DynamicBluetoothTests",
// RuntimeNative supplies the rt_* symbols the proxies link against.
dependencies: ["DynamicBluetooth", "RuntimeNative"]
),
.target(
name: "DynamicLocation",
dependencies: ["DynamicRuntime"],
path: "Contracts/DynamicLocation"
),
.testTarget(
name: "DynamicLocationTests",
// RuntimeNative supplies the rt_* symbols the proxies link against.
dependencies: ["DynamicLocation", "RuntimeNative"]
),
.target(
name: "DynamicMotion",
dependencies: ["DynamicRuntime"],
path: "Contracts/DynamicMotion"
),
.testTarget(
name: "DynamicMotionTests",
// RuntimeNative supplies the rt_* symbols the proxies link against.
dependencies: ["DynamicMotion", "RuntimeNative"]
),
.target(
name: "DynamicNetworking",
dependencies: ["DynamicRuntime"],
path: "Contracts/DynamicNetworking"
),
.testTarget(
name: "DynamicNetworkingTests",
// RuntimeNative supplies the rt_* symbols the proxies link against.
dependencies: ["DynamicNetworking", "RuntimeNative"]
),
.target(
name: "DynamicNFC",
dependencies: ["DynamicRuntime"],
path: "Contracts/DynamicNFC"
),
.testTarget(
name: "DynamicNFCTests",
// RuntimeNative supplies the rt_* symbols the proxies link against.
dependencies: ["DynamicNFC", "RuntimeNative"]
),
.target(
name: "DynamicUI",
dependencies: ["DynamicRuntime"],
path: "Contracts/DynamicUI"
),
.target(
name: "DynamicFormatting",
dependencies: ["DynamicRuntime"],
path: "Contracts/DynamicFormatting"
),
.testTarget(
name: "DynamicFormattingTests",
dependencies: ["DynamicFormatting", "RuntimeNative"]
),
// MARK: - Linux bundle and sandbox
.target(
name: "AppRuntime",
swiftSettings: [.swiftLanguageMode(.v5)]
),
.target(
name: "CBundleRuntime"
),
.executableTarget(
name: "BundleRuntime",
dependencies: ["AppRuntime", "CBundleRuntime"],
swiftSettings: [.swiftLanguageMode(.v5)]
),
// MARK: - Manifest
// Full Swift, no dependencies: guest.py compiles it with App.swift.
.target(
name: "AppManifest"
),
// MARK: - Example
.target(
name: "ExampleContracts",
dependencies: ["DynamicRuntime"],
path: "examples/ExampleContracts"
),
.target(
name: "ExampleHost",
dependencies: ["ExampleContracts", "DynamicRuntime"],
path: "examples/ExampleHost"
),
.target(
name: "ExampleApp",
dependencies: ["ExampleContracts"],
path: "examples/ExampleApp"
),
.target(
name: "ExampleUI",
dependencies: ["DynamicRuntime", "DynamicSwiftUI"],
path: "examples/ExampleUI"
),
// MARK: - Tests
.testTarget(
name: "RuntimeABITests",
dependencies: ["RuntimeABI"]
),
.testTarget(
name: "DynamicRuntimeMacrosTests",
dependencies: [
"DynamicRuntimeMacros",
"RuntimeABI",
.product(name: "SwiftParser", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacroExpansion", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacrosGenericTestSupport", package: "swift-syntax"),
]
),
.testTarget(
name: "DynamicObservationTests",
dependencies: [
"DynamicObservation",
"ObservationMacros",
.product(name: "SwiftParser", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacroExpansion", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacrosGenericTestSupport", package: "swift-syntax"),
]
),
.testTarget(
name: "DynamicUITests",
dependencies: ["DynamicUI", "RuntimeNative"]
),
.testTarget(
name: "DynamicSwiftUITests",
dependencies: ["DynamicSwiftUI", "DynamicUI", "RuntimeNative"]
),
.testTarget(
name: "RuntimeCoreTests",
dependencies: ["RuntimeCore"]
),
.testTarget(
name: "RuntimeHostTests",
dependencies: ["RuntimeHost", "RuntimeNative"]
),
.testTarget(
name: "DynamicRuntimeTests",
dependencies: [
"DynamicRuntime",
"RuntimeNative",
"ExampleContracts",
"ExampleHost",
"ExampleApp",
]
),
.testTarget(
name: "RawStringContractTests",
dependencies: ["DynamicRuntime", "RuntimeNative"]
),
.testTarget(
name: "AppRuntimeTests",
dependencies: ["AppRuntime"],
swiftSettings: [.swiftLanguageMode(.v5)]
),
.testTarget(
name: "AppManifestTests",
dependencies: ["AppManifest"]
),
]
)