diff --git a/swift/Package.swift b/swift/Package.swift index 3430427..01ce9da 100644 --- a/swift/Package.swift +++ b/swift/Package.swift @@ -1,4 +1,5 @@ // swift-tools-version: 5.9 +import Foundation import PackageDescription // Wraps the Zig usage core for native hosts. Build the library first: @@ -9,6 +10,15 @@ import PackageDescription // The core does no I/O: it builds the requests and parses the responses, and UsageDriver feeds it // through URLSession. That is the whole point of the split — TLS, proxies and HTTP/2 stay with the // host, and the rules stay in one place shared with the CLI. +// +// The path to libusage.a is absolute because this package is also consumed as a dependency: a +// relative path would be resolved against whoever is building, not against this directory. +let packageRoot = URL(fileURLWithPath: #filePath) + .deletingLastPathComponent() // the manifest + .deletingLastPathComponent() // swift/ + .path +let staticLibrary = "\(packageRoot)/zig-out/lib/libusage.a" + let package = Package( name: "UsageCore", platforms: [.macOS(.v13)], @@ -22,13 +32,13 @@ let package = Package( name: "UsageCore", dependencies: ["CUsage"], path: "Sources/UsageCore", - linkerSettings: [.unsafeFlags(["../zig-out/lib/libusage.a"])] + linkerSettings: [.unsafeFlags([staticLibrary])] ), .executableTarget( name: "UsageSmoke", dependencies: ["UsageCore"], path: "Sources/UsageSmoke", - linkerSettings: [.unsafeFlags(["../zig-out/lib/libusage.a"])] + linkerSettings: [.unsafeFlags([staticLibrary])] ), ] )