about summary refs log tree commit diff
path: root/pkgs/development/compilers/swift/swiftpm/patches/nix-pkgconfig-vars.patch
blob: e032ce80bf90beba4e7beea6eb6ef6c94df23348 (plain) (blame)
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
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
         }
     }
 }