-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathPackage.swift
More file actions
209 lines (185 loc) · 6.59 KB
/
Package.swift
File metadata and controls
209 lines (185 loc) · 6.59 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
// swift-tools-version: 6.1
import CompilerPluginSupport
import PackageDescription
let package = Package(
name: "swift-mmio",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
.macCatalyst(.v13),
.visionOS(.v1),
],
products: [
// MMIO
.library(name: "MMIO", targets: ["MMIO"]),
// SVD
.library(name: "SVD", targets: ["SVD"]),
.library(name: "SVD2LLDB", type: .dynamic, targets: ["SVD2LLDB"]),
.executable(
// FIXME: rdar://112530586
// XPM skips build plugin if product and target names are not identical.
// Rename this product to "svd2swift" when Xcode bug is resolved.
name: "SVD2Swift",
targets: ["SVD2Swift"]),
.plugin(name: "SVD2SwiftPlugin", targets: ["SVD2SwiftPlugin"]),
],
dependencies: [
.package(
url: "https://github.com/apple/swift-argument-parser.git",
from: "1.4.0"),
// FIXME: Update to non-prerelease
// The 6.2 release is needed for `swiftlang/swift-syntax#2947` "Don’t remove
//#if attributes with AttributeRemover" which missed the 6.1 release.
.package(
url: "https://github.com/swiftlang/swift-syntax.git",
from: "602.0.0-prerelease-2025-05-29"),
],
targets: [
// MMIO
.target(
name: "MMIO",
dependencies: ["MMIOMacros", "MMIOVolatile"]),
.testTarget(
name: "MMIOTests",
dependencies: ["MMIO", "MMIOUtilities"]),
// FIXME: feature flag
// Ideally this would be represented as MMIO + Feature: Interposable
// MMIOInterposableTests would have a dependency on MMIO with this feature
// enabled.
.target(
name: "MMIOInterposable",
dependencies: ["MMIOMacros", "MMIOVolatile"],
swiftSettings: [.define("FEATURE_INTERPOSABLE")]),
.testTarget(
name: "MMIOInterposableTests",
dependencies: ["MMIOInterposable", "MMIOUtilities"],
swiftSettings: [.define("FEATURE_INTERPOSABLE")]),
// Only runs in release.
.testTarget(
name: "MMIOFileCheckTests",
dependencies: [
// This is conceptually a build-time only dependency.
"MMIO",
"MMIOUtilities",
],
exclude: ["Tests"]),
.macro(
name: "MMIOMacros",
dependencies: [
"MMIOUtilities",
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
.product(name: "SwiftOperators", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacroExpansion", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
]),
.testTarget(
name: "MMIOMacrosTests",
dependencies: [
"MMIOMacros",
// FIXME: rdar://119344431
// XPM drops transitive dependency causing linker errors.
// Remove this dependency when Xcode bug is resolved.
"MMIOUtilities",
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(
name: "SwiftSyntaxMacrosGenericTestSupport", package: "swift-syntax"),
]),
.target(name: "MMIOUtilities"),
.testTarget(
name: "MMIOUtilitiesTests",
dependencies: ["MMIOUtilities"]),
.systemLibrary(name: "MMIOVolatile"),
// SVD
.target(
name: "SVD",
dependencies: ["MMIOUtilities", "XML"]),
.testTarget(
name: "SVDTests",
dependencies: ["MMIOUtilities", "SVD"]),
.target(name: "CLLDB"),
.target(
name: "SVD2LLDB",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"CLLDB",
"SVD",
],
swiftSettings: [.interoperabilityMode(.Cxx)]),
.testTarget(
name: "SVD2LLDBTests",
dependencies: ["SVD2LLDB"],
swiftSettings: [.interoperabilityMode(.Cxx)]),
.executableTarget(
name: "SVD2Swift",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"SVD",
]),
.testTarget(
name: "SVD2SwiftTests",
dependencies: ["SVD", "SVD2Swift"]),
.plugin(
name: "SVD2SwiftPlugin",
capability: .buildTool,
dependencies: ["SVD2Swift"]),
.testTarget(
name: "SVD2SwiftPluginTests",
dependencies: ["MMIO"],
plugins: ["SVD2SwiftPlugin"]),
// XML
.target(
name: "XML",
dependencies: ["MMIOUtilities", "XMLCore", "XMLMacros"]),
.target(name: "XMLCore"),
.macro(
name: "XMLMacros",
dependencies: [
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
]),
.testTarget(
name: "XMLMacrosTests",
dependencies: [
"XMLMacros",
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(
name: "SwiftSyntaxMacrosGenericTestSupport", package: "swift-syntax"),
]),
],
cxxLanguageStandard: .cxx11)
let svd2lldb = "FEATURE_SVD2LLDB"
if featureIsEnabled(named: svd2lldb, override: nil) {
let target = package.targets.first { $0.name == "SVD2LLDB" }
guard let target = target else { fatalError("Manifest inconsistency") }
target.linkerSettings = [.linkedFramework("LLDB")]
}
// Package API Extensions
func featureIsEnabled(named featureName: String, override: Bool?) -> Bool {
let key = "SWIFT_MMIO_\(featureName)"
let environment = Context.environment[key] != nil
return override ?? environment
}
// MARK: - Language Feature Flags
for target in package.targets {
guard ![.system, .plugin].contains(target.type) else { continue }
var swiftSettings = target.swiftSettings ?? []
// Swift 6.0 - SE-335: Introduce existential any
swiftSettings.append(.enableUpcomingFeature("ExistentialAny"))
// Swift 6.0 - SE-409: Access-level modifiers on import declarations
swiftSettings.append(.enableUpcomingFeature("InternalImportsByDefault"))
// Swift 6.1 - SE-444: Member import visibility
swiftSettings.append(.enableUpcomingFeature("MemberImportVisibility"))
// Swift 6.2 - SE-461: Run nonisolated async functions on the caller's actor
swiftSettings.append(.enableUpcomingFeature("NonisolatedNonsendingByDefault"))
// Swift 6.2 - SE-470: Global-actor isolated conformances
swiftSettings.append(.enableUpcomingFeature("InferIsolatedConformances"))
target.swiftSettings = swiftSettings
}