Modern Apps git

xtool.git

Public
git clone https://git.maproj.org/xtool.git
main ▾

xtool.git / Package.swift

Package.swift231 lines · 9.3 KiBRaw
1// swift-tools-version:6.2
2
3import PackageDescription
4
5let xtoolVersion: String? = {
6 if let explicitVersion = Context.environment["XTOOL_VERSION"] {
7 return explicitVersion
8 } else if let info = Context.gitInformation {
9 let gitCommit = info.currentCommit
10 let gitTag = info.currentTag
11 let gitRef = gitTag ?? "commit \(gitCommit)"
12 return gitRef
13 } else {
14 return nil
15 }
16}()
17
18let hasUncommittedChanges = Context.gitInformation?.hasUncommittedChanges ?? false
19
20let cSettings: [CSetting] = [
21 .define("_GNU_SOURCE", .when(platforms: [.linux])),
22]
23
24let swiftSettings: [SwiftSetting] = {
25 var settings: [SwiftSetting] = []
26 if Context.environment["XTL_CI"] == "1" {
27 settings.append(.treatAllWarnings(as: .error))
28 }
29 return settings
30}()
31
32let package = Package(
33 name: "xtool",
34 platforms: [
35 .iOS(.v17),
36 .macOS(.v14),
37 ],
38 products: [
39 .library(
40 name: "XKit",
41 targets: ["XKit"]
42 ),
43 .library(
44 name: "XToolSupport",
45 targets: ["XToolSupport"]
46 ),
47 .executable(
48 name: "xtool",
49 targets: ["xtool"]
50 ),
51 ],
52 dependencies: [
53 .package(url: "https://github.com/xtool-org/xtool-core", .upToNextMinor(from: "1.5.1")),
54 .package(url: "https://github.com/xtool-org/SwiftyMobileDevice", .upToNextMinor(from: "1.7.0")),
55 .package(url: "https://github.com/xtool-org/swift-rcodesign", .upToNextMinor(from: "0.2.0")),
56
57 .package(url: "https://github.com/apple/swift-system", from: "1.4.0"),
58 .package(url: "https://github.com/apple/swift-http-types", from: "1.3.1"),
59 .package(url: "https://github.com/apple/swift-certificates", from: "1.0.0"),
60 .package(url: "https://github.com/apple/swift-crypto", from: "5.0.0"),
61 .package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
62 .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
63 .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
64 .package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
65 .package(url: "https://github.com/apple/swift-collections", from: "1.7.1"),
66 .package(url: "https://github.com/apple/xcode-project-format.git", .upToNextMinor(from: "0.1.0")),
67
68 .package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.0.0"),
69 .package(url: "https://github.com/swiftlang/swift-subprocess", from: "1.0.0"),
70
71 .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.23.0"),
72 .package(url: "https://github.com/swift-server/swift-openapi-async-http-client", from: "1.0.0"),
73 .package(url: "https://github.com/vapor/websocket-kit.git", from: "2.15.0"),
74
75 .package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.3.0"),
76 .package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.6.2"),
77 .package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.3"),
78 // we don't use this but need the explicit dependency to keep the lockfile stable.
79 // TODO: remove once https://github.com/pointfreeco/combine-schedulers/issues/120 is fixed
80 .package(url: "https://github.com/OpenCombine/OpenCombine.git", from: "0.14.0"),
81
82 .package(url: "https://github.com/attaswift/BigInt", from: "6.0.0"),
83 .package(url: "https://github.com/jpsim/Yams", from: "6.0.0"),
84 .package(url: "https://github.com/saagarjha/unxip", from: "3.2.0"),
85
86 // NB: this should only be imported from XcodeProjects
87 .package(url: "https://github.com/tuist/XcodeProj.git", from: "9.17.5"),
88 ],
89 targets: [
90 .target(
91 name: "CXKit",
92 dependencies: [
93 .product(name: "OpenSSL", package: "xtool-core")
94 ],
95 cSettings: cSettings + [
96 .define("XTOOL_HAS_UNCOMMITTED_CHANGES", to: hasUncommittedChanges ? "1" : "0"),
97 ] + (
98 xtoolVersion
99 .map { [.define("XTOOL_VERSION", to: "\"\($0)\"")] }
100 ?? []
101 )
102 ),
103 .target(
104 name: "DeveloperAPI",
105 dependencies: [
106 .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
107 ],
108 exclude: ["openapi-generator-config.yaml", "patch.js"],
109 swiftSettings: swiftSettings,
110 ),
111 // common utilities shared across xtool targets
112 .target(
113 name: "XUtils",
114 dependencies: [
115 "CXKit",
116 .product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
117 .product(name: "Dependencies", package: "swift-dependencies"),
118 .product(name: "SystemPackage", package: "swift-system"),
119 .product(
120 name: "Subprocess",
121 package: "swift-subprocess",
122 condition: .when(platforms: [.linux, .macOS])
123 ),
124 ],
125 swiftSettings: swiftSettings,
126 ),
127 .target(
128 name: "XKit",
129 dependencies: [
130 "DeveloperAPI",
131 "CXKit",
132 "XUtils",
133 .product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
134 .product(name: "Dependencies", package: "swift-dependencies"),
135 .product(name: "SwiftyMobileDevice", package: "SwiftyMobileDevice"),
136 .product(name: "RCodesign", package: "swift-rcodesign"),
137 .product(name: "ProtoCodable", package: "xtool-core"),
138 .product(name: "Superutils", package: "xtool-core"),
139 .product(name: "Crypto", package: "swift-crypto"),
140 .product(name: "CryptoExtras", package: "swift-crypto"),
141 .product(name: "X509", package: "swift-certificates"),
142 .product(name: "BigInt", package: "BigInt"),
143 .product(name: "HTTPTypes", package: "swift-http-types"),
144 .product(name: "HTTPTypesFoundation", package: "swift-http-types"),
145 .product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
146 .product(
147 name: "OpenAPIAsyncHTTPClient",
148 package: "swift-openapi-async-http-client",
149 condition: .when(platforms: [.linux])
150 ),
151 .product(
152 name: "AsyncHTTPClient",
153 package: "async-http-client",
154 condition: .when(platforms: [.linux])
155 ),
156 .product(
157 name: "WebSocketKit",
158 package: "websocket-kit",
159 condition: .when(platforms: [.linux])
160 ),
161 ],
162 cSettings: cSettings,
163 swiftSettings: swiftSettings,
164 ),
165 .testTarget(
166 name: "XToolTests",
167 dependencies: [
168 "XKit",
169 "XToolSupport",
170 "XCLIUtils",
171 "PackLib",
172 .product(name: "Crypto", package: "swift-crypto"),
173 .product(name: "X509", package: "swift-certificates"),
174 .product(name: "CustomDump", package: "swift-custom-dump"),
175 ],
176 swiftSettings: swiftSettings,
177 ),
178 .target(
179 name: "XCLIUtils",
180 dependencies: [
181 "XUtils",
182 .product(name: "Dependencies", package: "swift-dependencies"),
183 .product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
184 ],
185 swiftSettings: swiftSettings,
186 ),
187 .target(
188 name: "XToolSupport",
189 dependencies: [
190 "SwiftyMobileDevice",
191 "XKit",
192 "XCLIUtils",
193 "PackLib",
194 .product(name: "ArgumentParser", package: "swift-argument-parser"),
195 .product(name: "SystemPackage", package: "swift-system"),
196 .product(name: "Dependencies", package: "swift-dependencies"),
197 .product(name: "libunxip", package: "unxip"),
198 ],
199 cSettings: cSettings,
200 swiftSettings: swiftSettings,
201 ),
202 .target(
203 name: "XcodeProjects",
204 dependencies: [
205 .product(name: "XcodeProj", package: "XcodeProj"),
206 .product(name: "XcodeProjectFormat", package: "xcode-project-format"),
207 ],
208 ),
209 .target(
210 name: "PackLib",
211 dependencies: [
212 "XUtils",
213 "XcodeProjects",
214 .product(name: "Superutils", package: "xtool-core"),
215 .product(name: "Yams", package: "Yams"),
216 .product(name: "XcodeProjectFormat", package: "xcode-project-format"),
217 ],
218 swiftSettings: swiftSettings,
219 ),
220 .executableTarget(
221 name: "xtool",
222 dependencies: [
223 "SwiftyMobileDevice",
224 "XKit",
225 "XToolSupport",
226 ],
227 cSettings: cSettings,
228 swiftSettings: swiftSettings,
229 ),
230 ]
231)