File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 9
9
*/
10
10
11
11
import Utility
12
+ import func POSIX. getenv
12
13
13
14
enum PkgConfigError : ErrorProtocol {
14
15
case CouldNotFindConfigFile
15
16
}
16
17
17
18
struct PkgConfig {
18
- static let searchPaths = [ " /usr/local/lib/pkgconfig " ]
19
+ static let searchPaths = [ " /usr/local/lib/pkgconfig " ,
20
+ " /usr/local/share/pkgconfig " ,
21
+ " /usr/lib/pkgconfig " ,
22
+ " /usr/share/pkgconfig " ,
23
+ // FIXME: These should only be searched for linux?
24
+ " /usr/lib/x86_64-linux-gnu/pkgconfig " ,
25
+ " /usr/local/lib/x86_64-linux-gnu/pkgconfig " ,
26
+ ]
19
27
20
28
let name : String
21
29
let pcFile : String
@@ -29,8 +37,15 @@ struct PkgConfig {
29
37
parser = PkgConfigParser ( pcFile: pcFile)
30
38
}
31
39
40
+ static var envSearchPaths : [ String ] {
41
+ if let configPath = getenv ( " PKG_CONFIG_PATH " ) {
42
+ return configPath. characters. split ( separator: " : " ) . map ( String . init)
43
+ }
44
+ return [ ]
45
+ }
46
+
32
47
static func locatePCFile( name: String ) throws -> String {
33
- for path in searchPaths {
48
+ for path in ( searchPaths + envSearchPaths ) {
34
49
let pcFile = Path . join ( path, " \( name) .pc " )
35
50
if pcFile. isFile {
36
51
return pcFile
You can’t perform that action at this time.
0 commit comments