fix(swift): resolve libusage.a from this package, not from the builder's directory
The manifest linked `../zig-out/lib/libusage.a`, which is only correct when this package is the root one being built: consumed as a dependency, SwiftPM resolves the relative path against the *consumer's* directory and the link fails with "no such file or directory". The tray is the first consumer, so the path is now absolute, computed in the manifest from `#filePath` — the manifest always knows where it lives, whatever is building it. Verified both ways: `swift run --package-path swift usage-smoke tests/fixtures` here, and a throwaway package that depends on `../usage-core/swift` and prints `abi=3 providers=8`.
1234562 unmodified lines9101112131415161718192021222324255 unmodified lines31323334253536373839403141424344// swift-tools-version: 5.9import Foundationimport PackageDescription
// Wraps the Zig usage core for native hosts. Build the library first:// zig build (repo root, produces zig-out/lib/libusage.a)2 unmodified lines//// 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/ .pathlet staticLibrary = "\(packageRoot)/zig-out/lib/libusage.a"
let package = Package( name: "UsageCore", platforms: [.macOS(.v13)], products: [5 unmodified lines .target( 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])] ), ])