-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackage.swift
More file actions
248 lines (242 loc) · 9.07 KB
/
Package.swift
File metadata and controls
248 lines (242 loc) · 9.07 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
// swift-tools-version: 6.2
import PackageDescription
// Platform-specific dependencies
// On Windows: use FlyingFox for HTTP server (polling-based, no NIO dependency)
// On macOS/Linux: use official SwiftNIO releases
var platformDependencies: [Package.Dependency] = []
var runtimePlatformDependencies: [Target.Dependency] = []
var lspDependencies: [Package.Dependency] = []
var lspTargetDependencies: [Target.Dependency] = []
var cliLspDependency: [Target.Dependency] = []
var compilerLLVMDependency: [Target.Dependency] = []
#if os(Windows)
// Windows-specific dependencies
// FlyingFox provides HTTP server and sockets without NIO (uses polling on Windows)
platformDependencies = [
// FlyingFox for HTTP server (includes FlyingSocks for socket support)
.package(url: "https://github.com/swhitty/FlyingFox.git", from: "0.21.0"),
// SwiftSoup for HTML/XML parsing (pure Swift, works on all platforms)
.package(url: "https://github.com/scinfu/SwiftSoup.git", from: "2.7.0"),
]
runtimePlatformDependencies = [
.product(name: "FlyingFox", package: "FlyingFox"),
.product(name: "FlyingSocks", package: "FlyingFox"),
.product(name: "SwiftSoup", package: "SwiftSoup"),
]
// LLVM/native compilation not available on Windows yet (requires LLVM installation)
// LSP not available on Windows yet - JSONRPC has issues
#else
// macOS and Linux dependencies
platformDependencies = [
// SwiftNIO for HTTP server and sockets (2.75.0+ for Swift 6 support)
.package(url: "https://github.com/apple/swift-nio.git", from: "2.75.0"),
// AsyncHTTPClient for outgoing HTTP requests
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.21.0"),
// FileMonitor for file system watching
.package(url: "https://github.com/KrisSimon/FileMonitor.git", from: "2.0.0"),
// LLVM C API bindings for type-safe IR generation (Issue #53)
// Swifty-LLVM requires Swift 6.2 and LLVM 20
.package(url: "https://github.com/hylo-lang/Swifty-LLVM.git", branch: "main"),
// SwiftSoup for HTML/XML parsing (pure Swift, works on all platforms)
.package(url: "https://github.com/scinfu/SwiftSoup.git", from: "2.7.0"),
]
runtimePlatformDependencies = [
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOHTTP1", package: "swift-nio"),
.product(name: "NIOWebSocket", package: "swift-nio"),
.product(name: "NIOFoundationCompat", package: "swift-nio"),
.product(name: "AsyncHTTPClient", package: "async-http-client"),
.product(name: "FileMonitor", package: "FileMonitor"),
.product(name: "SwiftSoup", package: "SwiftSoup"),
]
// LSP dependencies (JSONRPC doesn't support Windows)
lspDependencies = [
.package(url: "https://github.com/ChimeHQ/LanguageServerProtocol", from: "0.14.0"),
]
lspTargetDependencies = [
.product(name: "LanguageServerProtocol", package: "LanguageServerProtocol"),
]
cliLspDependency = [
"AROLSP",
]
// LLVM C API for type-safe IR generation
compilerLLVMDependency = [
.product(name: "SwiftyLLVM", package: "Swifty-LLVM"),
]
#endif
// LLVM linker settings - pkg-config needs help finding LLVM
#if os(macOS)
import Foundation
let llvmPath = ProcessInfo.processInfo.environment["LLVM_PATH"] ?? "/opt/homebrew/opt/llvm@20"
let llvmLibPath = "\(llvmPath)/lib"
let llvmLinkerSettings: [LinkerSetting] = [
.unsafeFlags(["-L\(llvmLibPath)", "-lLLVM-20"]),
.unsafeFlags(["-Xlinker", "-rpath", "-Xlinker", llvmLibPath]),
]
#elseif os(Linux)
import Foundation
let llvmPath = ProcessInfo.processInfo.environment["LLVM_PATH"] ?? "/usr/lib/llvm-20"
let llvmLibPath = "\(llvmPath)/lib"
let llvmLinkerSettings: [LinkerSetting] = [
.unsafeFlags(["-L\(llvmLibPath)", "-lLLVM-20"]),
.unsafeFlags(["-Xlinker", "-rpath", "-Xlinker", llvmLibPath]),
]
#else
// Windows and other platforms: LLVM not available
let llvmLinkerSettings: [LinkerSetting] = []
#endif
let package = Package(
name: "AROParser",
platforms: [
.macOS(.v15),
.iOS(.v18)
],
products: [
.library(
name: "AROParser",
targets: ["AROParser"]
),
// ARORuntime is now a static library that exports C symbols via @_cdecl
// for use by compiled ARO binaries (previously this was in AROCRuntime)
.library(
name: "ARORuntime",
type: .static,
targets: ["ARORuntime"]
),
.library(
name: "AROCompiler",
targets: ["AROCompiler"]
),
.library(
name: "AROPackageManager",
targets: ["AROPackageManager"]
),
.executable(
name: "aro",
targets: ["AROCLI"]
)
],
dependencies: platformDependencies + lspDependencies + [
// Swift Argument Parser for CLI
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.3.0"),
// Yams for YAML parsing (OpenAPI contracts)
.package(url: "https://github.com/jpsim/Yams.git", from: "6.2.0"),
// Swift Crypto for cryptographic operations (SHA256, etc.)
.package(url: "https://github.com/apple/swift-crypto.git", from: "4.0.0"),
// LineNoise for REPL line editing (arrow keys, history)
.package(url: "https://github.com/andybest/linenoise-swift.git", from: "0.0.3"),
],
targets: {
// Core targets available on all platforms
var targets: [Target] = [
// Version information library
.target(
name: "AROVersion",
path: "Sources/AROVersion"
),
// Core parser library
.target(
name: "AROParser",
path: "Sources/AROParser"
),
// Runtime library
.target(
name: "ARORuntime",
dependencies: [
"AROParser",
.product(name: "Yams", package: "Yams"),
.product(name: "Crypto", package: "swift-crypto"),
] + runtimePlatformDependencies,
path: "Sources/ARORuntime"
),
// Native compiler (LLVM IR generation)
.target(
name: "AROCompiler",
dependencies: [
"AROParser",
] + compilerLLVMDependency,
path: "Sources/AROCompiler",
linkerSettings: llvmLinkerSettings
),
// System library for libgit2
.systemLibrary(
name: "Clibgit2",
path: "Sources/Clibgit2",
pkgConfig: "libgit2",
providers: [
.brew(["libgit2"]),
.apt(["libgit2-dev"]),
]
),
// Package manager for plugins
.target(
name: "AROPackageManager",
dependencies: [
"Clibgit2",
.product(name: "Yams", package: "Yams"),
],
path: "Sources/AROPackageManager"
),
// CLI tool
.executableTarget(
name: "AROCLI",
dependencies: [
"AROVersion",
"AROParser",
"ARORuntime",
"AROCompiler",
"AROPackageManager",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "LineNoise", package: "linenoise-swift"),
] + cliLspDependency,
path: "Sources/AROCLI",
linkerSettings: llvmLinkerSettings
),
// Parser tests
.testTarget(
name: "AROParserTests",
dependencies: ["AROParser"],
path: "Tests/AROParserTests"
),
// Runtime tests
.testTarget(
name: "AROuntimeTests",
dependencies: ["ARORuntime"],
path: "Tests/AROuntimeTests"
),
// Compiler tests
.testTarget(
name: "AROCompilerTests",
dependencies: ["AROCompiler", "AROParser"],
path: "Tests/AROCompilerTests"
),
// Package manager tests
.testTarget(
name: "AROPackageManagerTests",
dependencies: ["AROPackageManager"],
path: "Tests/AROPackageManagerTests"
),
]
// LSP targets - not available on Windows (no compatible library)
#if !os(Windows)
targets.append(contentsOf: [
// Language Server Protocol implementation
.target(
name: "AROLSP",
dependencies: [
"AROParser",
] + lspTargetDependencies,
path: "Sources/AROLSP"
),
// LSP tests
.testTarget(
name: "AROLSPTests",
dependencies: ["AROLSP", "AROParser"] + lspTargetDependencies,
path: "Tests/AROLSPTests"
),
])
#endif
return targets
}(),
swiftLanguageModes: [.v6]
)