-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackage.swift
More file actions
273 lines (270 loc) · 11.8 KB
/
Copy pathPackage.swift
File metadata and controls
273 lines (270 loc) · 11.8 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
263
264
265
266
267
268
269
270
271
272
273
// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
// CompressionFamily — shared protocol surface for the Swift
// compression-library family. Always resolved from its public Git
// repository so J2KSwift stays URL-consumable as a SwiftPM dependency
// (see #438).
//
// The previous `FileManager.fileExists("../CompressionFamily")` probe was
// relative to the *current working directory*. SwiftPM evaluates a
// dependency's manifest with CWD set to the consuming root package, so any
// consumer that happened to have a `CompressionFamily` directory beside its
// own package root caused J2KSwift to fall back to a `.package(path:)`
// dependency — which a stable-versioned consumer is not allowed to depend
// on transitively ("unstable-version package"). Always using the URL form
// removes that footgun. For local co-development of J2KSwift +
// CompressionFamily, use `swift package edit CompressionFamily
// --path ../CompressionFamily`.
let compressionFamilyDependency: Package.Dependency = .package(
url: "https://github.com/Raster-Lab/CompressionFamily.git",
from: "1.0.0")
let package = Package(
name: "J2KSwift",
platforms: [
.macOS(.v15),
.iOS(.v18),
.tvOS(.v17),
.watchOS(.v10),
.visionOS(.v1)
],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "J2KCore",
targets: ["J2KCore"]),
.library(
name: "J2KCodec",
targets: ["J2KCodec"]),
.library(
name: "J2KFileFormat",
targets: ["J2KFileFormat"]),
.library(
name: "J2KMetal",
targets: ["J2KMetal"]),
.library(
name: "JPIP",
targets: ["JPIP"]),
.library(
name: "J2K3D",
targets: ["J2K3D"]),
// v10.17.0 — DICOM-bridge helpers product. Phase 1 ships the
// Transfer Syntax UID enum + J2KEncodingConfiguration mapping +
// codestream sniffer + PhotometricInterpretation enum mirror.
// ADR-004 compliant: no DICOM library dependency anywhere in
// J2KSwift; this product depends only on J2KCore + J2KCodec.
// Consumers who don't need DICOM ergonomics simply don't import
// J2KDICOMHelpers.
.library(
name: "J2KDICOMHelpers",
targets: ["J2KDICOMHelpers"]),
.executable(
name: "j2k",
targets: ["J2KCLI"]),
.executable(
name: "J2KTestApp",
targets: ["J2KTestApp"]),
// v8 Phase 6.3 — XPC daemon (macOS-only). Long-lived
// process that holds J2KMetalSession warm across CLI
// invocations, listening on a Mach service registered
// via launchd. Skeleton scope: ping/pong only; decode
// RPC + shared-memory marshalling land in Phase 6.4-6.6.
.executable(
name: "j2kd",
targets: ["J2KDaemon"]),
.library(
name: "J2KDaemonProtocol",
targets: ["J2KDaemonProtocol"]),
.library(
name: "J2KDaemonCore",
targets: ["J2KDaemonCore"]),
.library(
name: "J2KDaemonClient",
targets: ["J2KDaemonClient"]),
],
dependencies: [
compressionFamilyDependency,
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "J2KCore",
dependencies: [
.product(name: "CompressionFamily", package: "CompressionFamily"),
]),
// v9.4-research — custom C+NEON tier-1 HT block encoder. Plain C
// target with caller-owned-buffer entry point. No global statics,
// no allocator hits. Default-off behind J2K_NEON_HOT_PATH env var
// until the in-proc warm A/B clears the v9.3 baseline (see
// V9_4_NEON_HOT_PATH_RESEARCH.md decision matrix).
.target(
name: "J2KCodecNEON",
path: "Sources/J2KCodecNEON",
// v11.0.0: the -O3/-fno-* unsafeFlags were removed after an
// interleaved warm A/B (DX -0.44 ms, MG +1.35 ms, CT +0.06 ms
// vs SwiftPM's default release C optimization — all inside the
// 3 ms gate). Any unsafeFlags in the manifest makes the whole
// package ineligible as a versioned SwiftPM dependency; this
// was the last one.
publicHeadersPath: "include"),
.target(
name: "J2KCodec",
dependencies: [
"J2KCore",
"J2KMetal",
"J2KCodecNEON",
.product(name: "CompressionFamily", package: "CompressionFamily"),
]),
.target(
name: "J2KFileFormat",
dependencies: ["J2KCore", "J2KCodec"]),
.target(
name: "J2KMetal",
dependencies: ["J2KCore"],
// The .metal source file is documentation/reference
// material — regenerated via Scripts/build_metallib.sh
// and committed as `default.metallib`. Excluded from
// the build to avoid Xcode auto-discovering it as a
// Metal source target (which would compile a second
// metallib and collide with the pre-copied one in iOS
// Simulator builds).
//
// **v8 Phase 6.2 (iOS support)**: dropping
// `.process("J2KShaders.metal")` from resources +
// adding it to `exclude:` aligns macOS and iOS Xcode
// builds with the SwiftPM `swift build` behaviour
// (both rely on the pre-compiled metallib).
exclude: ["J2KShaders.metal"],
resources: [
// v5.15: ship a pre-compiled `default.metallib`
// alongside the .metal source. SwiftPM's
// `.process()` does NOT compile .metal files under
// `swift build` (only Xcode handles that); checking
// in a pre-built metallib is the only way to make
// the runtime metallib path live for SPM consumers.
// Regenerate via `Scripts/build_metallib.sh` when
// J2KShaders.metal changes (script verifies parity
// with the source). The runtime path falls back to
// source-compiling J2KMetalShaderSource.kernelSource
// if the metallib is missing or corrupt.
.copy("default.metallib")
]),
.target(
name: "JPIP",
dependencies: ["J2KCore", "J2KCodec", "J2KFileFormat", "J2K3D"]),
.target(
name: "J2K3D",
dependencies: ["J2KCore", "J2KCodec"]),
// v10.17.0 — DICOM-bridge helpers. Pure additive surface,
// ADR-004 compliant: depends only on J2KCore + J2KCodec.
// No DICOM library dependency introduced.
.target(
name: "J2KDICOMHelpers",
dependencies: ["J2KCore", "J2KCodec"]),
// v11.0.0 — test-app scaffolding models extracted from J2KCore.
// A library target (not part of the J2KTestApp executable)
// because J2KCLICore consumes it for `j2k testapp --headless`
// and J2KTestAppTests must not link an @main executable into
// the unified test binary (see the J2KCLICore comment below).
.target(
name: "J2KTestAppCore",
dependencies: ["J2KCore"],
path: "Sources/J2KTestAppCore"),
.testTarget(
name: "J2KCoreTests",
dependencies: ["J2KCore", "J2KFileFormat"]),
.testTarget(
name: "J2KCodecTests",
dependencies: [
"J2KCodec", "J2KFileFormat", "J2KMetal",
"J2KCodecNEON",
.product(name: "CompressionFamily", package: "CompressionFamily"),
]),
.testTarget(
name: "J2KFileFormatTests",
dependencies: ["J2KFileFormat"]),
.testTarget(
name: "J2KMetalTests",
dependencies: ["J2KMetal", "J2KCodec"]),
.testTarget(
name: "JPIPTests",
dependencies: ["JPIP", "J2KCodec"]),
.testTarget(
name: "J2KCLITests",
dependencies: ["J2KCore", "J2KCLICore"]),
.testTarget(
name: "JP3DTests",
dependencies: ["J2K3D", "J2KCore", "JPIP"]),
// v10.17.0 — J2KDICOMHelpers Phase 1 test target.
.testTarget(
name: "J2KDICOMHelpersTests",
dependencies: ["J2KDICOMHelpers", "J2KCore", "J2KCodec"]),
.testTarget(
name: "J2KComplianceTests",
dependencies: ["J2K3D", "J2KCore"]),
.testTarget(
name: "J2KTestAppTests",
dependencies: ["J2KTestAppCore", "J2KCore"]),
.systemLibrary(
name: "CZlib",
path: "Sources/CZlib"),
// All CLI command logic. A library (not the executable) so that
// J2KCLITests can depend on it without linking an executable
// `@main` into the unified test binary — a linked-in CLI entry
// point hijacks SwiftPM's swift-testing pass (which executes the
// test binary directly), printing CLI usage and exiting 1 even
// when every XCTest suite passes.
.target(
name: "J2KCLICore",
dependencies: ["J2KCore", "J2KCodec", "J2KFileFormat", "J2K3D", "JPIP", "CZlib", "J2KDaemonClient", "J2KTestAppCore"],
path: "Sources/J2KCLICore"),
// Thin `@main` wrapper producing the `j2k` executable.
.executableTarget(
name: "J2KCLI",
dependencies: ["J2KCLICore"],
path: "Sources/J2KCLI"),
// v8 Phase 6.3 — XPC daemon protocol (macOS-only at the
// type level via #if os(macOS)). Shared between the
// daemon executable, the daemon-side service, and the
// CLI client.
.target(
name: "J2KDaemonProtocol",
path: "Sources/J2KDaemonProtocol"),
// v8 Phase 6.4 — daemon-side service implementation
// (J2KDaemonService, J2KDaemonListenerDelegate). Shared
// between the daemon executable and the test suite so
// the in-process round-trip tests use the real
// implementation rather than a duplicate.
.target(
name: "J2KDaemonCore",
dependencies: ["J2KDaemonProtocol", "J2KCore", "J2KCodec"],
path: "Sources/J2KDaemonCore"),
// v8 Phase 6.4 — client-side wrapper around
// NSXPCConnection. Auto-discovers the Mach service,
// exposes a type-safe async ping API, surfaces
// "daemon unavailable" cleanly so callers can fall
// back to in-process decode.
.target(
name: "J2KDaemonClient",
dependencies: ["J2KDaemonProtocol", "J2KCore"],
path: "Sources/J2KDaemonClient"),
// v8 Phase 6.3 — XPC daemon executable. macOS-only.
.executableTarget(
name: "J2KDaemon",
dependencies: ["J2KDaemonProtocol", "J2KDaemonCore", "J2KCodec"],
path: "Sources/J2KDaemon"),
.testTarget(
name: "J2KDaemonTests",
dependencies: ["J2KDaemonProtocol", "J2KDaemonCore"],
path: "Tests/J2KDaemonTests"),
.testTarget(
name: "J2KDaemonClientTests",
dependencies: ["J2KDaemonProtocol", "J2KDaemonCore", "J2KDaemonClient", "J2KCore", "J2KCodec"],
path: "Tests/J2KDaemonClientTests"),
.executableTarget(
name: "J2KTestApp",
dependencies: ["J2KCore", "J2KCodec", "J2K3D", "J2KTestAppCore"],
path: "Sources/J2KTestApp"),
]
)