forked from steipete/CodexBar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackage.swift
More file actions
202 lines (194 loc) · 8.46 KB
/
Copy pathPackage.swift
File metadata and controls
202 lines (194 loc) · 8.46 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
// swift-tools-version: 6.2
import Foundation
import PackageDescription
let sweetCookieKitPath = "../SweetCookieKit"
let useLocalSweetCookieKit =
ProcessInfo.processInfo.environment["CODEXBAR_USE_LOCAL_SWEETCOOKIEKIT"] == "1"
let sweetCookieKitDependency: Package.Dependency =
useLocalSweetCookieKit && FileManager.default.fileExists(atPath: sweetCookieKitPath)
? .package(path: sweetCookieKitPath)
: .package(url: "https://github.com/steipete/SweetCookieKit", from: "0.4.1")
let sqlite3LibDir = ProcessInfo.processInfo.environment["CODEXBAR_SQLITE3_LIB_DIR"]?
.trimmingCharacters(in: .whitespacesAndNewlines)
let sqlite3LinkerSettings: [LinkerSetting] = if let sqlite3LibDir, !sqlite3LibDir.isEmpty {
[.unsafeFlags(["-L\(sqlite3LibDir)"], .when(platforms: [.linux]))]
} else {
[]
}
let package = Package(
name: "CodexBar",
defaultLocalization: "en",
platforms: [
.macOS(.v14),
],
products: {
var products: [Product] = [
.library(name: "CodexBarCore", targets: ["CodexBarCore"]),
.executable(name: "CodexBarCLI", targets: ["CodexBarCLI"]),
// Offline adaptive-refresh replay harness. Keep the supporting library package-internal.
.executable(name: "AdaptiveReplayCLI", targets: ["AdaptiveReplayCLI"]),
]
#if os(macOS)
products.append(contentsOf: [
.executable(name: "CodexBar", targets: ["CodexBar"]),
.executable(name: "CodexBarClaudeWatchdog", targets: ["CodexBarClaudeWatchdog"]),
.executable(name: "CodexBarWidget", targets: ["CodexBarWidget"]),
.executable(name: "CodexBarClaudeWebProbe", targets: ["CodexBarClaudeWebProbe"]),
])
#endif
return products
}(),
dependencies: [
.package(url: "https://github.com/sparkle-project/Sparkle", from: "2.9.3"),
.package(url: "https://github.com/steipete/Commander", from: "0.2.1"),
.package(url: "https://github.com/apple/swift-crypto.git", from: "3.0.0"),
.package(url: "https://github.com/apple/swift-log", from: "1.13.2"),
.package(url: "https://github.com/sindresorhus/KeyboardShortcuts", from: "2.4.0"),
.package(url: "https://github.com/zats/Vortex", revision: "ef5392088d4aeb255c4eee83157dbdafcd31bf07"),
sweetCookieKitDependency,
],
targets: {
var targets: [Target] = [
// Both glibc and static-musl CLI builds use this target; the module map supplies sqlite3 linkage.
.systemLibrary(
name: "CSQLite3",
providers: [
.apt(["libsqlite3-dev"]),
.brew(["sqlite3"]),
]),
.target(
name: "CodexBarCore",
dependencies: [
.target(name: "CSQLite3", condition: .when(platforms: [.linux])),
.product(name: "Crypto", package: "swift-crypto"),
.product(name: "Logging", package: "swift-log"),
.product(name: "SweetCookieKit", package: "SweetCookieKit"),
],
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
],
linkerSettings: sqlite3LinkerSettings),
.executableTarget(
name: "CodexBarCLI",
dependencies: [
"CodexBarCore",
.product(name: "Commander", package: "Commander"),
.product(name: "Crypto", package: "swift-crypto"),
],
path: "Sources/CodexBarCLI",
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
],
linkerSettings: sqlite3LinkerSettings),
// Sole owner of the adaptive refresh decision table. Package-internal so the app and
// offline replay tool share behavior without publishing another library product.
.target(
name: "AdaptiveRefreshCore",
dependencies: [],
path: "Sources/AdaptiveRefreshCore",
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
]),
// Offline adaptive-refresh replay harness: pure Foundation,
// no CodexBar/CodexBarCore dependency, so it builds anywhere CodexBarCore does.
.target(
name: "AdaptiveReplayKit",
dependencies: ["AdaptiveRefreshCore"],
path: "Sources/AdaptiveReplayKit",
exclude: ["README.md"],
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
]),
.executableTarget(
name: "AdaptiveReplayCLI",
dependencies: ["AdaptiveReplayKit"],
path: "Sources/AdaptiveReplayCLI",
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
]),
.testTarget(
name: "AdaptiveReplayCLITests",
dependencies: ["AdaptiveReplayCLI", "AdaptiveReplayKit"],
path: "Tests/AdaptiveReplayCLITests",
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
.enableExperimentalFeature("SwiftTesting"),
]),
.testTarget(
name: "AdaptiveReplayKitTests",
dependencies: ["AdaptiveRefreshCore", "AdaptiveReplayKit"],
path: "Tests/AdaptiveReplayKitTests",
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
.enableExperimentalFeature("SwiftTesting"),
]),
.testTarget(
name: "CodexBarLinuxTests",
dependencies: [
"CodexBarCore",
"CodexBarCLI",
.target(name: "CSQLite3", condition: .when(platforms: [.linux])),
],
path: "TestsLinux",
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
.enableExperimentalFeature("SwiftTesting"),
]),
]
#if os(macOS)
targets.append(contentsOf: [
.executableTarget(
name: "CodexBarClaudeWatchdog",
dependencies: [],
path: "Sources/CodexBarClaudeWatchdog",
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
]),
.executableTarget(
name: "CodexBar",
dependencies: [
.product(name: "Sparkle", package: "Sparkle"),
.product(name: "KeyboardShortcuts", package: "KeyboardShortcuts"),
.product(name: "Vortex", package: "Vortex"),
"AdaptiveRefreshCore",
"CodexBarCore",
],
path: "Sources/CodexBar",
resources: [
.process("Resources"),
],
swiftSettings: [
// Opt into Swift 6 strict concurrency (approachable migration path).
.enableUpcomingFeature("StrictConcurrency"),
.define("ENABLE_SPARKLE"),
]),
.executableTarget(
name: "CodexBarWidget",
dependencies: ["CodexBarCore"],
path: "Sources/CodexBarWidget",
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
]),
.executableTarget(
name: "CodexBarClaudeWebProbe",
dependencies: ["CodexBarCore"],
path: "Sources/CodexBarClaudeWebProbe",
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
]),
])
targets.append(.testTarget(
name: "CodexBarTests",
dependencies: ["CodexBar", "CodexBarCore", "CodexBarCLI", "CodexBarWidget"],
path: "Tests",
exclude: ["AdaptiveReplayCLITests", "AdaptiveReplayKitTests"],
resources: [
.copy("CodexBarTests/Fixtures"),
],
swiftSettings: [
.enableUpcomingFeature("StrictConcurrency"),
.enableExperimentalFeature("SwiftTesting"),
]))
#endif
return targets
}())