diff options
Diffstat (limited to 'pkgs/development/compilers/swift/swiftpm')
10 files changed, 147 insertions, 90 deletions
diff --git a/pkgs/development/compilers/swift/swiftpm/cmake-glue.nix b/pkgs/development/compilers/swift/swiftpm/cmake-glue.nix index f297eafd389b1..252040dd3ec01 100644 --- a/pkgs/development/compilers/swift/swiftpm/cmake-glue.nix +++ b/pkgs/development/compilers/swift/swiftpm/cmake-glue.nix @@ -57,9 +57,6 @@ in lib.mapAttrs mkInstallScript { ''; Yams = '' - add_library(CYaml SHARED IMPORTED) - set_property(TARGET CYaml PROPERTY IMPORTED_LOCATION "@out@/lib/libCYaml@sharedLibExt@") - add_library(Yams SHARED IMPORTED) set_property(TARGET Yams PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libYams@sharedLibExt@") ''; diff --git a/pkgs/development/compilers/swift/swiftpm/default.nix b/pkgs/development/compilers/swift/swiftpm/default.nix index 3025672563d27..b5abb8bf0336e 100644 --- a/pkgs/development/compilers/swift/swiftpm/default.nix +++ b/pkgs/development/compilers/swift/swiftpm/default.nix @@ -8,6 +8,7 @@ , swiftpm2nix , Foundation , XCTest +, pkg-config , sqlite , ncurses , substituteAll @@ -38,13 +39,12 @@ let propagatedBuildInputs = [ Foundation ]; patches = [ ./patches/cmake-disable-rpath.patch + ./patches/cmake-fix-quoting.patch ./patches/disable-index-store.patch ./patches/disable-sandbox.patch + ./patches/disable-xctest.patch ./patches/fix-clang-cxx.patch - (substituteAll { - src = ./patches/disable-xctest.patch; - inherit (builtins) storeDir; - }) + ./patches/nix-pkgconfig-vars.patch (substituteAll { src = ./patches/fix-stdlib-path.patch; inherit (builtins) storeDir; @@ -60,6 +60,21 @@ let --replace \ 'librariesPath = applicationPath.parentDirectory' \ "librariesPath = AbsolutePath(\"$out\")" + + # Fix case-sensitivity issues. + # Upstream PR: https://github.com/apple/swift-package-manager/pull/6500 + substituteInPlace Sources/CMakeLists.txt \ + --replace \ + 'packageCollectionsSigning' \ + 'PackageCollectionsSigning' + substituteInPlace Sources/PackageCollectionsSigning/CMakeLists.txt \ + --replace \ + 'SubjectPublickeyInfo' \ + 'SubjectPublicKeyInfo' + substituteInPlace Sources/PackageCollections/CMakeLists.txt \ + --replace \ + 'FilepackageCollectionsSourcesStorage' \ + 'FilePackageCollectionsSourcesStorage' ''; }; @@ -67,12 +82,15 @@ let runtimeDeps = [ git ] ++ lib.optionals stdenv.isDarwin [ xcbuild.xcrun - # vtool is used to determine a minimum deployment target. This is part of - # cctools, but adding that as a build input puts an unwrapped linker in - # PATH, and breaks builds. This small derivation exposes just vtool. - (runCommandLocal "vtool" { } '' + # These tools are part of cctools, but adding that as a build input puts + # an unwrapped linker in PATH, and breaks builds. This small derivation + # exposes just the tools we need: + # - vtool is used to determine a minimum deployment target. + # - libtool is used to build static libraries. + (runCommandLocal "swiftpm-cctools" { } '' mkdir -p $out/bin ln -s ${cctools}/bin/vtool $out/bin/vtool + ln -s ${cctools}/bin/libtool $out/bin/libtool '') ]; @@ -282,6 +300,12 @@ let swift-tools-support-core ]; + postPatch = '' + # Tries to link against CYaml, but that's private. + substituteInPlace Sources/SwiftDriver/CMakeLists.txt \ + --replace CYaml "" + ''; + postInstall = cmakeGlue.SwiftDriver + '' # Swift modules are not installed. mkdir -p $out/${swiftModuleSubdir} @@ -294,8 +318,11 @@ let src = generated.sources.swift-crypto; postPatch = '' + # Fix use of hardcoded tool paths on Darwin. substituteInPlace CMakeLists.txt \ --replace /usr/bin/ar $NIX_CC/bin/ar + substituteInPlace CMakeLists.txt \ + --replace /usr/bin/ranlib $NIX_CC/bin/ranlib ''; postInstall = cmakeGlue.SwiftCrypto + '' @@ -313,6 +340,7 @@ let buildInputs = [ llbuild + sqlite swift-argument-parser swift-collections swift-crypto @@ -342,6 +370,7 @@ in stdenv.mkDerivation (commonAttrs // { ]; buildInputs = [ ncursesInput + pkg-config sqlite XCTest ] @@ -385,10 +414,10 @@ in stdenv.mkDerivation (commonAttrs // { mkdir -p $out/bin $out/lib/swift - cp $binPath/swift-package $out/bin/ + cp $binPath/swift-package-manager $out/bin/swift-package wrapProgram $out/bin/swift-package \ --prefix PATH : ${lib.makeBinPath runtimeDeps} - for tool in swift-build swift-test swift-run swift-package-collection; do + for tool in swift-build swift-test swift-run swift-package-collection swift-experimental-destination; do ln -s $out/bin/swift-package $out/bin/$tool done diff --git a/pkgs/development/compilers/swift/swiftpm/generated/default.nix b/pkgs/development/compilers/swift/swiftpm/generated/default.nix index 45d09093c62c9..dbcd0f18e71fc 100644 --- a/pkgs/development/compilers/swift/swiftpm/generated/default.nix +++ b/pkgs/development/compilers/swift/swiftpm/generated/default.nix @@ -4,11 +4,11 @@ hashes = { "swift-argument-parser" = "1jph9w7lk9nr20fsv2c8p4hisx3dda817fh7pybd0r0j1jwa9nmw"; "swift-collections" = "1k6sjx5rqmp3gklny77b480hyzy6gkhpi23r0s8ljfbrcwawgnan"; - "swift-crypto" = "020b8q4ss2k7a65r5dgh59z40i6sn7ij1allxkh8c8a9d0jzn313"; - "swift-driver" = "1lcb5wqragc74nd0fjnk47lyph9hs0i9cps1mplvp2i91yzjqk05"; - "swift-llbuild" = "07zbp2dyfqd1bnyg7snpr9brn40jf22ivly5v10mql3hrg76a18h"; + "swift-crypto" = "0kllp7j0hd8k67l9b9zr2c3ddc5bvshldchzivhcz3q31qvq9ag8"; + "swift-driver" = "0cbvddj54k3sbw0vzlmzhccs7h43hi5kq6i3n2i0mysz3bf0c6zg"; + "swift-llbuild" = "106vnssh6pgy5s9dnq1hi1c9v2wkfydqgncg5dy7c9n23iisjy3s"; "swift-system" = "0402hkx2q2dv27gccnn8ma79ngvwiwzkhcv4zlcdldmy6cgi0px7"; - "swift-tools-support-core" = "134f9x44jnzdy8cwi6hs372dwbyqvr4qmsjzjy25wzpyv6m9rhrz"; - "Yams" = "1893y13sis2aimi1a5kgkczbf06z4yig054xb565yg2xm13srb45"; + "swift-tools-support-core" = "1qvblyiazv58qwyxgyk2dh5ymbab3y70vm2q81qs6rmv43hs8ciz"; + "Yams" = "0b4lprxl4f6yqq0djnp394mxgmsxm2pljr7fh4f6ihdhnpwfsfvl"; }; } diff --git a/pkgs/development/compilers/swift/swiftpm/generated/workspace-state.json b/pkgs/development/compilers/swift/swiftpm/generated/workspace-state.json index 48a6350ece965..187df519fb7b3 100644 --- a/pkgs/development/compilers/swift/swiftpm/generated/workspace-state.json +++ b/pkgs/development/compilers/swift/swiftpm/generated/workspace-state.json @@ -46,8 +46,8 @@ }, "state": { "checkoutState": { - "revision": "ddb07e896a2a8af79512543b1c7eb9797f8898a5", - "version": "1.1.7" + "revision": "75ec60b8b4cc0f085c3ac414f3dca5625fa3588e", + "version": "2.2.4" }, "name": "sourceControlCheckout" }, @@ -63,8 +63,8 @@ }, "state": { "checkoutState": { - "branch": "release/5.7", - "revision": "82b274af66cfbb8f3131677676517b34d01e30fd" + "branch": "release/5.8", + "revision": "7cfe0c0b6e6297efe88a3ce34e6138ee7eda969e" }, "name": "sourceControlCheckout" }, @@ -80,8 +80,8 @@ }, "state": { "checkoutState": { - "branch": "release/5.7", - "revision": "564424db5fdb62dcb5d863bdf7212500ef03a87b" + "branch": "release/5.8", + "revision": "dccfc2e127a34b89a849407594cf2d604b598ba9" }, "name": "sourceControlCheckout" }, @@ -114,8 +114,8 @@ }, "state": { "checkoutState": { - "branch": "release/5.7", - "revision": "286b48b1d73388e1d49b2bb33aabf995838104e3" + "branch": "release/5.8", + "revision": "ac4871e01ef338cb95b5d28328cab0ec1dfae935" }, "name": "sourceControlCheckout" }, @@ -131,8 +131,8 @@ }, "state": { "checkoutState": { - "revision": "9ff1cc9327586db4e0c8f46f064b6a82ec1566fa", - "version": "4.0.6" + "revision": "f47ba4838c30dbd59998a4e4c87ab620ff959e8a", + "version": "5.0.5" }, "name": "sourceControlCheckout" }, @@ -140,5 +140,5 @@ } ] }, - "version": 5 + "version": 6 } diff --git a/pkgs/development/compilers/swift/swiftpm/patches/cmake-fix-quoting.patch b/pkgs/development/compilers/swift/swiftpm/patches/cmake-fix-quoting.patch new file mode 100644 index 0000000000000..04f51e9ec8351 --- /dev/null +++ b/pkgs/development/compilers/swift/swiftpm/patches/cmake-fix-quoting.patch @@ -0,0 +1,12 @@ +--- a/Sources/PackageCollectionsSigning/CMakeLists.txt ++++ b/Sources/PackageCollectionsSigning/CMakeLists.txt +@@ -43,6 +43,7 @@ target_link_libraries(PackageCollectionsSigning PUBLIC + PackageCollectionsModel + TSCBasic) + target_link_libraries(PackageCollectionsSigning PRIVATE +- PackageCollectionsSigningLibc +- $<$<PLATFORM_ID:Darwin>:SHELL:-Xlinker -framework -Xlinker Security>) ++ PackageCollectionsSigningLibc) ++target_link_options(PackageCollectionsSigning PRIVATE ++ "$<$<PLATFORM_ID:Darwin>:SHELL:-Xlinker -framework -Xlinker Security>") + diff --git a/pkgs/development/compilers/swift/swiftpm/patches/disable-sandbox.patch b/pkgs/development/compilers/swift/swiftpm/patches/disable-sandbox.patch index 406e1d68d0e42..0c76d59f9dfb1 100644 --- a/pkgs/development/compilers/swift/swiftpm/patches/disable-sandbox.patch +++ b/pkgs/development/compilers/swift/swiftpm/patches/disable-sandbox.patch @@ -2,13 +2,13 @@ Nix may already sandbox the build, in which case sandbox_apply will fail. --- a/Sources/Basics/Sandbox.swift +++ b/Sources/Basics/Sandbox.swift -@@ -30,12 +30,14 @@ public enum Sandbox { +@@ -33,12 +33,14 @@ public enum Sandbox { readOnlyDirectories: [AbsolutePath] = [] - ) -> [String] { + ) throws -> [String] { #if os(macOS) + let env = ProcessInfo.processInfo.environment + if env["NIX_BUILD_TOP"] == nil || env["IN_NIX_SHELL"] != nil { - let profile = macOSSandboxProfile(strictness: strictness, writableDirectories: writableDirectories, readOnlyDirectories: readOnlyDirectories) + let profile = try macOSSandboxProfile(strictness: strictness, writableDirectories: writableDirectories, readOnlyDirectories: readOnlyDirectories) return ["/usr/bin/sandbox-exec", "-p", profile] + command - #else + } @@ -17,5 +17,5 @@ Nix may already sandbox the build, in which case sandbox_apply will fail. return command - #endif } - + /// Basic strictness level of a sandbox applied to a command line. diff --git a/pkgs/development/compilers/swift/swiftpm/patches/disable-xctest.patch b/pkgs/development/compilers/swift/swiftpm/patches/disable-xctest.patch index e24d154d29873..b587393dc2a21 100644 --- a/pkgs/development/compilers/swift/swiftpm/patches/disable-xctest.patch +++ b/pkgs/development/compilers/swift/swiftpm/patches/disable-xctest.patch @@ -1,21 +1,21 @@ XCTest is not fully open-source, only the Swift library parts. We don't have a command-line runner available, so disable support. ---- a/Sources/Commands/TestingSupport.swift -+++ b/Sources/Commands/TestingSupport.swift -@@ -60,7 +60,7 @@ enum TestingSupport { +--- a/Sources/Commands/Utilities/TestingSupport.swift ++++ b/Sources/Commands/Utilities/TestingSupport.swift +@@ -72,7 +72,7 @@ enum TestingSupport { /// - Returns: Array of TestSuite - static func getTestSuites(fromTestAt path: AbsolutePath, swiftTool: SwiftTool, swiftOptions: SwiftToolOptions) throws -> [TestSuite] { + static func getTestSuites(fromTestAt path: AbsolutePath, swiftTool: SwiftTool, enableCodeCoverage: Bool, sanitizers: [Sanitizer]) throws -> [TestSuite] { // Run the correct tool. - #if os(macOS) + #if false let data: String = try withTemporaryFile { tempFile in - let args = [try TestingSupport.xctestHelperPath(swiftTool: swiftTool).pathString, path.pathString, tempFile.path.pathString] - var env = try TestingSupport.constructTestEnvironment(toolchain: try swiftTool.getToolchain(), options: swiftOptions, buildParameters: swiftTool.buildParametersForTest()) + let args = [try Self.xctestHelperPath(swiftTool: swiftTool).pathString, path.pathString, tempFile.path.pathString] + var env = try Self.constructTestEnvironment( --- a/Sources/swiftpm-xctest-helper/main.swift +++ b/Sources/swiftpm-xctest-helper/main.swift -@@ -9,8 +9,11 @@ - */ +@@ -11,8 +11,11 @@ + //===----------------------------------------------------------------------===// #if os(macOS) -import XCTest @@ -27,7 +27,7 @@ command-line runner available, so disable support. /// A helper tool to get list of tests from a XCTest Bundle on macOS. /// -@@ -132,6 +135,7 @@ do { +@@ -134,6 +137,7 @@ do { exit(1) } @@ -35,14 +35,3 @@ command-line runner available, so disable support. #else #if os(Windows) ---- a/Sources/PackageModel/Destination.swift -+++ b/Sources/PackageModel/Destination.swift -@@ -174,7 +174,7 @@ public struct Destination: Encodable, Equatable { - arguments: ["/usr/bin/xcrun", "--sdk", "macosx", "--show-sdk-platform-path"], - environment: environment).spm_chomp() - -- if let platformPath = platformPath, !platformPath.isEmpty { -+ if let platformPath = platformPath, !platformPath.isEmpty && !platformPath.starts(with: "@storeDir@") { - // For XCTest framework. - let fwk = AbsolutePath(platformPath).appending( - components: "Developer", "Library", "Frameworks") diff --git a/pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch b/pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch index 60c4e33eb154f..93c43c664ed36 100644 --- a/pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch +++ b/pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch @@ -2,9 +2,20 @@ Swiftpm may invoke clang, not clang++, to compile C++. Our cc-wrapper also doesn't pick up the arguments that enable C++ compilation in this case. Patch swiftpm to properly invoke clang++. +--- a/Sources/Build/BuildPlan.swift ++++ b/Sources/Build/BuildPlan.swift +@@ -2089,7 +2089,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan { + for target in dependencies.staticTargets { + if case let target as ClangTarget = target.underlyingTarget, target.isCXX { + if buildParameters.hostTriple.isDarwin() { +- buildProduct.additionalFlags += ["-lc++"] ++ buildProduct.additionalFlags += ["-lc++", "-lc++abi"] + } else if buildParameters.hostTriple.isWindows() { + // Don't link any C++ library. + } else { --- a/Sources/Build/LLBuildManifestBuilder.swift +++ b/Sources/Build/LLBuildManifestBuilder.swift -@@ -782,7 +782,7 @@ extension LLBuildManifestBuilder { +@@ -786,7 +786,7 @@ extension LLBuildManifestBuilder { args += ["-c", path.source.pathString, "-o", path.object.pathString] @@ -13,21 +24,10 @@ swiftpm to properly invoke clang++. args.insert(clangCompiler, at: 0) let objectFileNode: Node = .file(path.object) ---- a/Sources/PackageModel/Destination.swift -+++ b/Sources/PackageModel/Destination.swift -@@ -153,7 +153,7 @@ public struct Destination: Encodable, Equatable { - - var extraCPPFlags: [String] = [] - #if os(macOS) -- extraCPPFlags += ["-lc++"] -+ extraCPPFlags += ["-lc++", "-lc++abi"] - #elseif os(Windows) - extraCPPFlags += [] - #else --- a/Sources/PackageModel/Toolchain.swift +++ b/Sources/PackageModel/Toolchain.swift -@@ -20,7 +20,7 @@ public protocol Toolchain { - var macosSwiftStdlib: AbsolutePath { get } +@@ -23,7 +23,7 @@ public protocol Toolchain { + var macosSwiftStdlib: AbsolutePath { get throws } /// Path of the `clang` compiler. - func getClangCompiler() throws -> AbsolutePath @@ -46,7 +46,7 @@ swiftpm to properly invoke clang++. private let environment: EnvironmentVariables -@@ -150,29 +150,31 @@ public final class UserToolchain: Toolchain { +@@ -196,29 +196,31 @@ public final class UserToolchain: Toolchain { } /// Returns the path to clang compiler tool. @@ -70,7 +70,7 @@ swiftpm to properly invoke clang++. // Then, check the toolchain. + let tool = isCXX ? "clang++" : "clang"; do { -- if let toolPath = try? UserToolchain.getTool("clang", binDir: self.destination.binDir) { +- if let toolPath = try? UserToolchain.getTool("clang", binDir: self.destination.toolchainBinDir) { - self._clangCompiler = toolPath + if let toolPath = try? UserToolchain.getTool(tool, binDir: self.destination.binDir) { + self._clangCompiler[isCXX] = toolPath @@ -88,18 +88,18 @@ swiftpm to properly invoke clang++. --- a/Sources/SPMBuildCore/BuildParameters.swift +++ b/Sources/SPMBuildCore/BuildParameters.swift -@@ -342,7 +342,7 @@ private struct _Toolchain: Encodable { +@@ -394,7 +394,7 @@ private struct _Toolchain: Encodable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(toolchain.swiftCompilerPath, forKey: .swiftCompiler) - try container.encode(toolchain.getClangCompiler(), forKey: .clangCompiler) + try container.encode(toolchain.getClangCompiler(isCXX: false), forKey: .clangCompiler) - try container.encode(toolchain.extraCCFlags, forKey: .extraCCFlags) - try container.encode(toolchain.extraCPPFlags, forKey: .extraCPPFlags) + try container.encode(toolchain.extraFlags.cCompilerFlags, forKey: .extraCCFlags) + // Maintaining `extraCPPFlags` key for compatibility with older encoding. --- a/Sources/XCBuildSupport/XcodeBuildSystem.swift +++ b/Sources/XCBuildSupport/XcodeBuildSystem.swift -@@ -172,7 +172,7 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem { +@@ -182,7 +182,7 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem { // Generate a table of any overriding build settings. var settings: [String: String] = [:] // An error with determining the override should not be fatal here. @@ -107,15 +107,15 @@ swiftpm to properly invoke clang++. + settings["CC"] = try? buildParameters.toolchain.getClangCompiler(isCXX: false).pathString // Always specify the path of the effective Swift compiler, which was determined in the same way as for the native build system. settings["SWIFT_EXEC"] = buildParameters.toolchain.swiftCompilerPath.pathString - settings["LIBRARY_SEARCH_PATHS"] = "$(inherited) \(buildParameters.toolchain.toolchainLibDir.pathString)" + settings["LIBRARY_SEARCH_PATHS"] = "$(inherited) \(try buildParameters.toolchain.toolchainLibDir.pathString)" --- a/Tests/BuildTests/MockBuildTestHelper.swift +++ b/Tests/BuildTests/MockBuildTestHelper.swift -@@ -15,7 +15,7 @@ struct MockToolchain: PackageModel.Toolchain { +@@ -23,7 +23,7 @@ struct MockToolchain: PackageModel.Toolchain { #else - let extraCPPFlags: [String] = ["-lstdc++"] + let extraFlags = BuildFlags(cxxCompilerFlags: ["-lstdc++"]) #endif - func getClangCompiler() throws -> AbsolutePath { + func getClangCompiler(isCXX: Bool) throws -> AbsolutePath { - return AbsolutePath("/fake/path/to/clang") + return AbsolutePath(path: "/fake/path/to/clang") } diff --git a/pkgs/development/compilers/swift/swiftpm/patches/fix-stdlib-path.patch b/pkgs/development/compilers/swift/swiftpm/patches/fix-stdlib-path.patch index 327ccf37e4253..6c9c21cfb98ea 100644 --- a/pkgs/development/compilers/swift/swiftpm/patches/fix-stdlib-path.patch +++ b/pkgs/development/compilers/swift/swiftpm/patches/fix-stdlib-path.patch @@ -4,20 +4,22 @@ necessary for back-deployment of some features. --- a/Sources/PackageModel/Toolchain.swift +++ b/Sources/PackageModel/Toolchain.swift -@@ -43,10 +43,16 @@ extension Toolchain { - } +@@ -53,12 +53,18 @@ extension Toolchain { - public var macosSwiftStdlib: AbsolutePath { -+ if swiftCompilerPath.pathString.starts(with: "@storeDir@") { -+ return AbsolutePath("@swiftLib@/lib/swift/macosx") -+ } - return AbsolutePath("../../lib/swift/macosx", relativeTo: resolveSymlinks(swiftCompilerPath)) + public var macosSwiftStdlib: AbsolutePath { + get throws { ++ if swiftCompilerPath.pathString.starts(with: "@storeDir@") { ++ return AbsolutePath("@swiftLib@/lib/swift/macosx") ++ } + return try AbsolutePath(validating: "../../lib/swift/macosx", relativeTo: resolveSymlinks(swiftCompilerPath)) + } } public var toolchainLibDir: AbsolutePath { -+ if swiftCompilerPath.pathString.starts(with: "@storeDir@") { -+ return AbsolutePath("@swiftLib@/lib") -+ } - // FIXME: Not sure if it's better to base this off of Swift compiler or our own binary. - return AbsolutePath("../../lib", relativeTo: resolveSymlinks(swiftCompilerPath)) - } + get throws { ++ if swiftCompilerPath.pathString.starts(with: "@storeDir@") { ++ return AbsolutePath("@swiftLib@/lib") ++ } + // FIXME: Not sure if it's better to base this off of Swift compiler or our own binary. + return try AbsolutePath(validating: "../../lib", relativeTo: resolveSymlinks(swiftCompilerPath)) + } diff --git a/pkgs/development/compilers/swift/swiftpm/patches/nix-pkgconfig-vars.patch b/pkgs/development/compilers/swift/swiftpm/patches/nix-pkgconfig-vars.patch new file mode 100644 index 0000000000000..e032ce80bf90b --- /dev/null +++ b/pkgs/development/compilers/swift/swiftpm/patches/nix-pkgconfig-vars.patch @@ -0,0 +1,28 @@ +Swift parses .pc files manually, but this means it bypasses our pkg-config +wrapper. That wrapper normally takes care of introducing the correct +PKG_CONFIG_PATH for cross compiling. + +--- a/Sources/PackageLoading/PkgConfig.swift ++++ b/Sources/PackageLoading/PkgConfig.swift +@@ -123,14 +123,17 @@ public struct PkgConfig { + + private static var envSearchPaths: [AbsolutePath] { + get throws { +- if let configPath = ProcessEnv.vars["PKG_CONFIG_PATH"] { ++ var result: [AbsolutePath] = [] ++ for envVar in ["PKG_CONFIG_PATH", "PKG_CONFIG_PATH_FOR_TARGET"] { ++ if let configPath = ProcessEnv.vars[envVar] { + #if os(Windows) +- return try configPath.split(separator: ";").map({ try AbsolutePath(validating: String($0)) }) ++ result += try configPath.split(separator: ";").map({ try AbsolutePath(validating: String($0)) }) + #else +- return try configPath.split(separator: ":").map({ try AbsolutePath(validating: String($0)) }) ++ result += try configPath.split(separator: ":").map({ try AbsolutePath(validating: String($0)) }) + #endif + } +- return [] ++ } ++ return result + } + } + } |