-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPackage.swift
More file actions
262 lines (237 loc) · 12.1 KB
/
Copy pathPackage.swift
File metadata and controls
262 lines (237 loc) · 12.1 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
// swift-tools-version:6.1
import PackageDescription
let package = Package(
name: "swift-compression",
// MARK: Products
products: [
.library(name: "SwiftCompression", targets: ["SwiftCompression"]),
.library(name: "SwiftCompressionUtilities", targets: ["SwiftCompressionUtilities"]),
.library(name: "Brotli", targets: ["Brotli"]),
.library(name: "SwiftCompressionDNA", targets: ["CompressionDNA"]),
.library(name: "SwiftCompressionLZ", targets: ["CompressionLZ"]),
.library(name: "FrequencyTables", targets: ["FrequencyTables"]),
.library(name: "Huffman", targets: ["Huffman"]),
.library(name: "RunLengthEncoding", targets: ["RunLengthEncoding"]),
.library(name: "Snappy", targets: ["Snappy"]),
.library(name: "Zlib", targets: ["Zlib"])
],
// MARK: Traits
traits: [
.default(enabledTraits: [
"Brotli",
"Huffman",
"LZ77",
"RunLengthEncoding",
"Snappy",
"ZlibDeflate",
"ZlibGzip",
"AlgorithmCompress",
"AlgorithmAnyCompressor",
"AlgorithmAnyDecompressor",
"CollectionCompress", "CollectionDecompress",
"BrotliCompress", "BrotliDecompress",
"HuffmanCompress", "HuffmanDecompress",
"LZ77Compress", "LZ77Decompress",
"SnappyCompress", "SnappyDecompress",
"RunLengthEncodingCompress", "RunLengthEncodingDecompress",
"ZlibDeflateCompress", "ZlibDeflateDecompress",
"ZlibGzipCompress", "ZlibGzipDecompress",
]),
.trait(name: "AlgorithmCompress", description: "Enables the `compress(span:)` function for `CompressionAlgorithm`."),
.trait(name: "AlgorithmAnyCompressor", description: "Enables the `compressor: (any Compressor)?` computed property for `CompressionAlgorithm`."),
.trait(name: "AlgorithmAnyDecompressor", description: "Enables the `decompressor: (any Decompressor)?` computed property for `CompressionAlgorithm`."),
.trait(name: "CollectionCompress", enabledTraits: [
"BrotliCompressCollection",
"HuffmanCompressCollection",
"LZ77CompressCollection",
"RunLengthEncodingCompressCollection",
"SnappyCompressCollection",
"ZlibDeflateCompressCollection",
"ZlibGzipCompressCollection",
]),
.trait(name: "CollectionDecompress", enabledTraits: [
"BrotliDecompressCollection",
"HuffmanDecompressCollection",
"LZ77DecompressCollection",
"RunLengthEncodingDecompressCollection",
"SnappyDecompressCollection",
"ZlibDeflateDecompressCollection",
"ZlibGzipDecompressCollection",
]),
.trait(name: "Brotli", description: "Enables Brotli."),
.trait(name: "BrotliCompress", description: "Enables Brotli compression for Span<UInt8>.", enabledTraits: ["Brotli"]),
.trait(name: "BrotliCompressCollection", description: "Enables Brotli compression for some Collection<UInt8>.", enabledTraits: ["BrotliCompress"]),
.trait(name: "BrotliDecompress", description: "Enables Brotli decompression for Span<UInt8>.", enabledTraits: ["Brotli"]),
.trait(name: "BrotliDecompressCollection", description: "Enables Brotli decompression for some Collection<UInt8>.", enabledTraits: ["BrotliDecompress"]),
.trait(name: "Huffman", description: "Enables Huffman."),
.trait(name: "HuffmanCompress", description: "Enables Huffman compression for Span<UInt8>.", enabledTraits: ["Huffman"]),
.trait(name: "HuffmanCompressCollection", description: "Enables Huffman compression for some Collection<UInt8>.", enabledTraits: ["HuffmanCompress"]),
.trait(name: "HuffmanDecompress", description: "Enables Huffman decompression for Span<UInt8>.", enabledTraits: ["Huffman"]),
.trait(name: "HuffmanDecompressCollection", description: "Enables Huffman decompression for some Collection<UInt8>.", enabledTraits: ["HuffmanDecompress"]),
.trait(name: "LZ77", description: "Enables LZ77."),
.trait(name: "LZ77Compress", description: "Enables LZ77 compression for Span<UInt8>.", enabledTraits: ["LZ77"]),
.trait(name: "LZ77CompressCollection", description: "Enables LZ77 compression for some Collection<UInt8>.", enabledTraits: ["LZ77Compress"]),
.trait(name: "LZ77Decompress", description: "Enables LZ77 decompression for Span<UInt8>.", enabledTraits: ["LZ77"]),
.trait(name: "LZ77DecompressCollection", description: "Enables LZ77 decompression for some Collection<UInt8>.", enabledTraits: ["LZ77Decompress"]),
.trait(name: "RunLengthEncoding", description: "Enables RunLengthEncoding."),
.trait(name: "RunLengthEncodingCompress", description: "Enables RunLengthEncoding compression for Span<UInt8>.", enabledTraits: ["RunLengthEncoding"]),
.trait(name: "RunLengthEncodingCompressCollection", description: "Enables RunLengthEncoding compression for some Collection<UInt8>.", enabledTraits: ["RunLengthEncodingCompress"]),
.trait(name: "RunLengthEncodingDecompress", description: "Enables RunLengthEncoding decompression for Span<UInt8>.", enabledTraits: ["RunLengthEncoding"]),
.trait(name: "RunLengthEncodingDecompressCollection", description: "Enables RunLengthEncoding decompression for some Collection<UInt8>.", enabledTraits: ["RunLengthEncodingDecompress"]),
.trait(name: "Snappy", description: "Enables Snappy."),
.trait(name: "SnappyCompress", description: "Enables Snappy compression for Span<UInt8>.", enabledTraits: ["Snappy"]),
.trait(name: "SnappyCompressCollection", description: "Enables Snappy compression for some Collection<UInt8>.", enabledTraits: ["SnappyCompress"]),
.trait(name: "SnappyDecompress", description: "Enables Snappy decompression for Span<UInt8>.", enabledTraits: ["Snappy"]),
.trait(name: "SnappyDecompressCollection", description: "Enables Snappy decompression for some Collection<UInt8>.", enabledTraits: ["SnappyDecompress"]),
.trait(name: "ZlibDeflate", description: "Enables ZlibDeflate."),
.trait(name: "ZlibDeflateCompress", description: "Enables ZlibDeflate compression for Span<UInt8>.", enabledTraits: ["ZlibDeflate"]),
.trait(name: "ZlibDeflateCompressCollection", description: "Enables ZlibDeflate compression for some Collection<UInt8>.", enabledTraits: ["ZlibDeflateCompress"]),
.trait(name: "ZlibDeflateDecompress", description: "Enables ZlibDeflate decompression for Span<UInt8>.", enabledTraits: ["ZlibDeflate"]),
.trait(name: "ZlibDeflateDecompressCollection", description: "Enables ZlibDeflate decompression for some Collection<UInt8>.", enabledTraits: ["ZlibDeflateDecompress"]),
.trait(name: "ZlibGzip", description: "Enables ZlibGzip"),
.trait(name: "ZlibGzipCompress", description: "Enables ZlibGzip compression for Span<UInt8>.", enabledTraits: ["ZlibGzip", "ZlibDeflateCompress"]),
.trait(name: "ZlibGzipCompressCollection", description: "Enables ZlibGzip compression for some Collection<UInt8>.", enabledTraits: ["ZlibGzipCompress"]),
.trait(name: "ZlibGzipDecompress", description: "Enables ZlibGzip decompression for Span<UInt8>.", enabledTraits: ["ZlibGzip", "ZlibDeflateDecompress"]),
.trait(name: "ZlibGzipDecompressCollection", description: "Enables ZlibGzip decompression for some Collection<UInt8>.", enabledTraits: ["ZlibGzipDecompress"]),
],
// MARK: Targets
targets: [
.target(name: "ByteBuilder"),
.target(name: "FrequencyTables"),
.target(name: "SwiftCompressionUtilities"),
.target(
name: "SwiftCompression",
dependencies: [
"Brotli",
"CompressionDNA",
"CompressionLZ",
"Huffman",
"RunLengthEncoding",
"Snappy",
"Zlib",
"SwiftCompressionUtilities",
]
),
.systemLibrary(name: "BrotliShim"),
.target(
name: "Brotli",
dependencies: [
"SwiftCompressionUtilities",
"BrotliShim"
],
linkerSettings: [
.linkedLibrary("brotlienc", .when(traits: ["BrotliCompress"])),
.linkedLibrary("brotlidec", .when(traits: ["BrotliDecompress"]))
]
),
.systemLibrary(name: "ZlibShim"),
.target(
name: "Zlib",
dependencies: [
"SwiftCompressionUtilities",
"ZlibShim"
]
),
.target(
name: "CompressionDNA",
dependencies: [
"ByteBuilder",
"FrequencyTables",
"SwiftCompressionUtilities"
],
path: "Sources/DNA"
),
.target(
name: "CompressionLZ",
dependencies: [
"ByteBuilder",
"SwiftCompressionUtilities"
],
path: "Sources/LZ"
),
.target(
name: "Huffman",
dependencies: [
"ByteBuilder",
"SwiftCompressionUtilities"
]
),
.target(
name: "RunLengthEncoding",
dependencies: [
"SwiftCompressionUtilities"
]
),
.systemLibrary(name: "SnappyShim"),
.target(
name: "Snappy",
dependencies: [
"ByteBuilder",
"SwiftCompressionUtilities",
"SnappyShim"
],
linkerSettings: [
.linkedLibrary("snappy", .when(traits: ["Snappy"]))
]
),
// MARK: Run
.executableTarget(
name: "Run",
dependencies: [
"SwiftCompression"
]
),
// MARK: Unit tests
.testTarget(name: "SwiftCompressionTests", dependencies: ["SwiftCompression"]),
.testTarget(name: "BrotliTests", dependencies: ["Brotli"]),
.testTarget(name: "DNATests", dependencies: ["CompressionDNA"]),
.testTarget(name: "LZTests", dependencies: ["CompressionLZ"]),
.testTarget(name: "SnappyTests", dependencies: ["Snappy"]),
.testTarget(name: "ZlibTests", dependencies: ["Zlib"])
]
)
/*
// MARK: Add dynamic
//
// WARNING: MAKE SURE YOU HAVE "_DynamicX" SYMLINKS TO THE STATIC MODULES!
//
var dynamicProducts:[Product] = []
var dynamicTargets:[Target] = []
for target:Target in package.targets {
if target.type == .regular || target.type == .executable {
target.swiftSettings = [
.define("STATIC")
]
target.path = "Sources/" + target.name
let dynamicName:String = "Dynamic" + target.name
let dynamicProduct:Product, dynamicTarget:Target
if target.type == .executable {
dynamicTarget = .executableTarget(name: dynamicName)
dynamicProduct = .executable(name: dynamicName, targets: [dynamicName])
} else {
dynamicTarget = .target(name: dynamicName)
dynamicProduct = .library(name: dynamicName, type: .dynamic, targets: [dynamicName])
}
dynamicProducts.append(dynamicProduct)
for dependency in target.dependencies {
switch dependency {
case .targetItem(let name, _):
dynamicTarget.dependencies.append(.target(name: "Dynamic" + name))
case .productItem(let name, _, _, _):
dynamicTarget.dependencies.append(.target(name: "Dynamic" + name))
case .byNameItem(let name, _):
dynamicTarget.dependencies.append(.target(name: "Dynamic" + name))
@unknown default:
break
}
}
dynamicTarget.path = "Sources/_" + dynamicName
dynamicTarget.swiftSettings = [
.define("DYNAMIC"),
.unsafeFlags(["-enable-library-evolution"])
]
dynamicTargets.append(dynamicTarget)
}
}
package.products.append(contentsOf: dynamicProducts)
package.targets.append(contentsOf: dynamicTargets)*/