-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Package.swift
159 lines (154 loc) · 5.59 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
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import CompilerPluginSupport
import PackageDescription
// TODO: Once https://github.com/michaeleisel/ZippyJSON/pull/67 is in a release, remove this conditional.
let isBuildingForCocoaPods = Context.environment["SAFEDI_MACRO_COCOAPODS_BUILD"] != nil
let package = Package(
name: "SafeDI",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
.macCatalyst(.v13),
.visionOS(.v1),
],
products: [
/// A library containing SafeDI macros, property wrappers, and types.
.library(
name: "SafeDI",
targets: ["SafeDI"]
),
] + (isBuildingForCocoaPods ? [] : [
/// A SafeDI plugin that must be run on the root source module in a project.
.plugin(
name: "SafeDIGenerator",
targets: ["SafeDIGenerator"]
),
.plugin(
name: "InstallSafeDITool",
targets: ["InstallSafeDITool"]
),
]),
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.0"),
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "600.0.0"),
.package(url: "https://github.com/pointfreeco/swift-macro-testing.git", from: "0.5.0"),
] + (isBuildingForCocoaPods ? [] : [
.package(url: "https://github.com/michaeleisel/ZippyJSON.git", from: "1.2.0"),
]),
targets: [
// Macros
.target(
name: "SafeDI",
dependencies: ["SafeDIMacros"],
swiftSettings: [
.swiftLanguageMode(.v6),
]
),
.testTarget(
name: "SafeDITests",
dependencies: [
"SafeDI",
"SafeDICore",
],
swiftSettings: [
.swiftLanguageMode(.v6),
]
),
.macro(
name: "SafeDIMacros",
dependencies: [
"SafeDICore",
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
],
swiftSettings: [
.swiftLanguageMode(.v6),
]
),
.testTarget(
name: "SafeDIMacrosTests",
dependencies: [
"SafeDIMacros",
"SafeDICore",
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
.product(name: "MacroTesting", package: "swift-macro-testing"),
],
swiftSettings: [
.swiftLanguageMode(.v6),
]
),
// Plugins
.plugin(
name: "InstallSafeDITool",
capability: .command(
intent: .custom(
verb: "safedi-release-install",
description: "Installs a release version of the SafeDITool build plugin executable."
),
permissions: [
.writeToPackageDirectory(reason: "Downloads the SafeDI release build plugin executable into your project directory."),
.allowNetworkConnections(scope: .all(ports: []), reason: "Downloads the SafeDI release build plugin executable from GitHub."),
]
),
dependencies: []
),
// Core
.target(
name: "SafeDICore",
dependencies: [
.product(name: "Collections", package: "swift-collections"),
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
],
swiftSettings: [
.swiftLanguageMode(.v6),
]
),
.testTarget(
name: "SafeDICoreTests",
dependencies: ["SafeDICore"],
swiftSettings: [
.swiftLanguageMode(.v6),
]
),
] + (isBuildingForCocoaPods ? [] : [
// Plugins
.plugin(
name: "SafeDIGenerator",
capability: .buildTool(),
dependencies: ["SafeDITool"]
),
.executableTarget(
name: "SafeDITool",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax"),
.byNameItem(name: "ZippyJSON", condition: .when(platforms: [.iOS, .tvOS, .macOS])),
"SafeDICore",
],
swiftSettings: [
.swiftLanguageMode(.v6),
]
),
.testTarget(
name: "SafeDIToolTests",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.byNameItem(name: "ZippyJSON", condition: .when(platforms: [.iOS, .tvOS, .macOS])),
"SafeDITool",
],
swiftSettings: [
.swiftLanguageMode(.v6),
]
),
])
)