-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathPackage.swift
More file actions
193 lines (185 loc) · 5.68 KB
/
Package.swift
File metadata and controls
193 lines (185 loc) · 5.68 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
// swift-tools-version: 6.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import CompilerPluginSupport
import PackageDescription
let safeDICoreDependencies: [PackageDescription.Target.Dependency] = [
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
]
let package = Package(
name: "SafeDI",
platforms: [
.macOS(.v11),
.iOS(.v15),
.tvOS(.v15),
.watchOS(.v8),
.macCatalyst(.v15),
.visionOS(.v1),
],
products: [
/// A library containing SafeDI macros, property wrappers, and types.
.library(
name: "SafeDI",
targets: ["SafeDI"],
),
/// A SafeDI plugin that must be run on the root source module in a project.
.plugin(
name: "SafeDIGenerator",
targets: ["SafeDIGenerator"],
),
.plugin(
name: "MigrateSafeDIFromVersionOne",
targets: ["MigrateSafeDIFromVersionOne"],
),
.plugin(
name: "InstallSafeDITool",
targets: ["InstallSafeDITool"],
),
],
traits: [
.default(enabledTraits: ["prebuilt"]),
.trait(name: "prebuilt", description: "Use a prebuilt SafeDITool binary from the artifact bundle (default)."),
.trait(name: "sourceBuild", description: "Build SafeDITool from source. Intended for local development and adopting unreleased changes; typically set via `--traits sourceBuild` which replaces the default `prebuilt`."),
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.4.0"),
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.3.0"),
.package(url: "https://github.com/swiftlang/swift-syntax.git", "603.0.0"..<"605.0.0"),
],
targets: [
// Macros
.target(
name: "SafeDI",
dependencies: ["SafeDIMacros"],
swiftSettings: [
.swiftLanguageMode(.v6),
],
),
.testTarget(
name: "SafeDITests",
dependencies: [
"SafeDI",
"SafeDICore",
],
swiftSettings: [
.swiftLanguageMode(.v6),
],
),
.macro(
name: "SafeDIMacros",
dependencies: [
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
] + safeDICoreDependencies,
swiftSettings: [
.swiftLanguageMode(.v6),
],
),
.testTarget(
name: "SafeDIMacrosTests",
dependencies: [
"SafeDIMacros",
.product(name: "SwiftSyntaxMacrosGenericTestSupport", package: "swift-syntax"),
],
swiftSettings: [
.swiftLanguageMode(.v6),
],
),
// Plugins
.plugin(
name: "MigrateSafeDIFromVersionOne",
capability: .command(
intent: .custom(
verb: "safedi-v1-to-v2",
description: "Migrates a project from SafeDI 1.x to 2.x.",
),
permissions: [
.writeToPackageDirectory(reason: "Creates a SafeDIConfiguration.swift file and removes obsolete CSV configuration files."),
],
),
dependencies: [],
),
// Downloads the prebuilt SafeDITool release binary into
// `<xcodeProject>/.safedi/<version>/safeditool`. Xcode-only — avoids
// the `${BUILD_DIR}`-in-tool-path problem that forces Xcode users
// onto the regex-based `PluginScanner` fallback.
.plugin(
name: "InstallSafeDITool",
capability: .command(
intent: .custom(
verb: "safedi-release-install",
description: "Xcode-only: downloads the SafeDITool prebuilt release binary for the current SafeDI version into .safedi/<version>/safeditool next to the .xcodeproj. swift build users get the prebuilt tool via the default `prebuilt` trait and don't need this.",
),
permissions: [
.writeToPackageDirectory(reason: "Downloads the SafeDITool binary into .safedi/<version>/safeditool."),
.allowNetworkConnections(scope: .all(ports: []), reason: "Downloads SafeDITool from the SafeDI GitHub release."),
],
),
dependencies: [],
),
.plugin(
name: "SafeDIGenerator",
capability: .buildTool(),
dependencies: [
.target(name: "SafeDIToolBinary", condition: .when(traits: ["prebuilt"])),
.target(name: "SafeDITool", condition: .when(traits: ["sourceBuild"])),
],
),
.binaryTarget(
name: "SafeDIToolBinary",
url: "https://github.com/dfed/SafeDI/releases/download/2.0.0-beta-5/SafeDITool.artifactbundle.zip",
checksum: "4e95a9bb1c9ac0643d41563dd8fe125cbd72f319a16ff57160d5b4f9f40605a7",
),
.executableTarget(
name: "SafeDITool",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "SwiftParser", package: "swift-syntax"),
"SafeDICore",
],
swiftSettings: [
.swiftLanguageMode(.v6),
],
),
.testTarget(
name: "SafeDIToolTests",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"SafeDITool",
],
swiftSettings: [
.swiftLanguageMode(.v6),
],
),
// Tests for the `SafeDIGenerator` build-tool plugin's in-process
// helpers. The plugin target itself cannot be a test dependency
// (SPM plugins can only depend on executable/binary targets), so
// this target compiles the plugin helpers via symlink:
// `Tests/SafeDIGeneratorPluginTests/PluginScannerStringUtilities.swift`
// → `Plugins/PluginScannerStringUtilities.swift`. The plugin target
// has the same symlink, so both targets share the source.
.testTarget(
name: "SafeDIGeneratorPluginTests",
path: "Tests/SafeDIGeneratorPluginTests",
swiftSettings: [
.swiftLanguageMode(.v6),
],
),
// Core
.target(
name: "SafeDICore",
dependencies: safeDICoreDependencies,
swiftSettings: [
.swiftLanguageMode(.v6),
],
),
.testTarget(
name: "SafeDICoreTests",
dependencies: ["SafeDICore"],
swiftSettings: [
.swiftLanguageMode(.v6),
],
),
],
)