File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -46,24 +46,21 @@ extension String: Error {
46
46
}
47
47
48
48
func makeFile( ) throws {
49
- let pkgConfigPath = " /usr/local/lib/pkgconfig "
49
+ guard let brew = which ( " brew " ) else { throw " Missing callable `brew` instance. " }
50
+ guard let brewPrefix = run ( brew, args: [ " --prefix " ] ) else { throw " Brew could not detect installation prefix location. " }
51
+ let pkgConfigPath = " \( brewPrefix) /lib/pkgconfig "
50
52
let pkgConfigDir = URL ( fileURLWithPath: pkgConfigPath)
51
53
52
- // Make /usr/local /lib/pkgconfig if it doesn't already exist
54
+ // Make <brew-prefix> /lib/pkgconfig if it doesn't already exist
53
55
if !FileManager. default. fileExists ( atPath: pkgConfigPath) {
54
56
try FileManager . default. createDirectory ( at: pkgConfigDir,
55
57
withIntermediateDirectories: true )
56
58
}
57
59
let cllvmPath = pkgConfigDir. appendingPathComponent ( " cllvm.pc " )
58
-
59
- let brewLLVMConfig : ( ) -> String ? = {
60
- guard let brew = which ( " brew " ) else { return nil }
61
- guard let brewPrefix = run ( brew, args: [ " --prefix " ] ) else { return nil }
62
- return which ( brewPrefix + " /opt/llvm/bin/llvm-config " )
63
- }
60
+ let brewLLVMConfig = which ( brewPrefix + " /opt/llvm/bin/llvm-config " )
64
61
65
62
/// Ensure we have llvm-config in the PATH
66
- guard let llvmConfig = which ( " llvm-config-11 " ) ?? which ( " llvm-config " ) ?? brewLLVMConfig ( ) else {
63
+ guard let llvmConfig = which ( " llvm-config-11 " ) ?? which ( " llvm-config " ) ?? brewLLVMConfig else {
67
64
throw " Failed to find llvm-config. Ensure llvm-config is installed and " +
68
65
" in your PATH "
69
66
}
You can’t perform that action at this time.
0 commit comments