| ... | @@ -92,81 +92,21 @@ const LibraryDep = struct { | ... | @@ -92,81 +92,21 @@ const LibraryDep = struct { |
| 92 | }; | 92 | }; |
| 93 | | 93 | |
| 94 | fn findLLVM(b: &Builder) -> LibraryDep { | 94 | fn findLLVM(b: &Builder) -> LibraryDep { |
| 95 | const libs_output = { | 95 | const llvm_config_exe = b.findProgram( |
| 96 | const args1 = [][]const u8{"llvm-config-5.0", "--libs", "--system-libs"}; | 96 | [][]const u8{"llvm-config-5.0", "llvm-config"}, |
| 97 | const args2 = [][]const u8{"llvm-config", "--libs", "--system-libs"}; | 97 | [][]const u8{ |
| 98 | const max_output_size = 10 * 1024; | 98 | "/usr/local/opt/llvm@5/", |
| 99 | const good_result = os.ChildProcess.exec(b.allocator, args1, null, null, max_output_size) %% |err| { | 99 | "/mingw64/bin", |
| 100 | if (err == error.FileNotFound) { | 100 | "/c/msys64/mingw64/bin", |
| 101 | os.ChildProcess.exec(b.allocator, args2, null, null, max_output_size) %% |err2| { | 101 | "c:/msys64/mingw64/bin", |
| 102 | std.debug.panic("unable to spawn {}: {}\n", args2[0], err2); | 102 | "C:/Libraries/llvm-5.0.0/bin", |
| 103 | } | 103 | }) %% |err| |
| 104 | } else { | 104 | { |
| 105 | std.debug.panic("unable to spawn {}: {}\n", args1[0], err); | 105 | std.debug.panic("unable to find llvm-config: {}\n", err); |
| 106 | } | | |
| 107 | }; | | |
| 108 | switch (good_result.term) { | | |
| 109 | os.ChildProcess.Term.Exited => |code| { | | |
| 110 | if (code != 0) { | | |
| 111 | std.debug.panic("llvm-config exited with {}:\n{}\n", code, good_result.stderr); | | |
| 112 | } | | |
| 113 | }, | | |
| 114 | else => { | | |
| 115 | std.debug.panic("llvm-config failed:\n{}\n", good_result.stderr); | | |
| 116 | }, | | |
| 117 | } | | |
| 118 | good_result.stdout | | |
| 119 | }; | | |
| 120 | const includes_output = { | | |
| 121 | const args1 = [][]const u8{"llvm-config-5.0", "--includedir"}; | | |
| 122 | const args2 = [][]const u8{"llvm-config", "--includedir"}; | | |
| 123 | const max_output_size = 10 * 1024; | | |
| 124 | const good_result = os.ChildProcess.exec(b.allocator, args1, null, null, max_output_size) %% |err| { | | |
| 125 | if (err == error.FileNotFound) { | | |
| 126 | os.ChildProcess.exec(b.allocator, args2, null, null, max_output_size) %% |err2| { | | |
| 127 | std.debug.panic("unable to spawn {}: {}\n", args2[0], err2); | | |
| 128 | } | | |
| 129 | } else { | | |
| 130 | std.debug.panic("unable to spawn {}: {}\n", args1[0], err); | | |
| 131 | } | | |
| 132 | }; | | |
| 133 | switch (good_result.term) { | | |
| 134 | os.ChildProcess.Term.Exited => |code| { | | |
| 135 | if (code != 0) { | | |
| 136 | std.debug.panic("llvm-config --includedir exited with {}:\n{}\n", code, good_result.stderr); | | |
| 137 | } | | |
| 138 | }, | | |
| 139 | else => { | | |
| 140 | std.debug.panic("llvm-config failed:\n{}\n", good_result.stderr); | | |
| 141 | }, | | |
| 142 | } | | |
| 143 | good_result.stdout | | |
| 144 | }; | | |
| 145 | const libdir_output = { | | |
| 146 | const args1 = [][]const u8{"llvm-config-5.0", "--libdir"}; | | |
| 147 | const args2 = [][]const u8{"llvm-config", "--libdir"}; | | |
| 148 | const max_output_size = 10 * 1024; | | |
| 149 | const good_result = os.ChildProcess.exec(b.allocator, args1, null, null, max_output_size) %% |err| { | | |
| 150 | if (err == error.FileNotFound) { | | |
| 151 | os.ChildProcess.exec(b.allocator, args2, null, null, max_output_size) %% |err2| { | | |
| 152 | std.debug.panic("unable to spawn {}: {}\n", args2[0], err2); | | |
| 153 | } | | |
| 154 | } else { | | |
| 155 | std.debug.panic("unable to spawn {}: {}\n", args1[0], err); | | |
| 156 | } | | |
| 157 | }; | | |
| 158 | switch (good_result.term) { | | |
| 159 | os.ChildProcess.Term.Exited => |code| { | | |
| 160 | if (code != 0) { | | |
| 161 | std.debug.panic("llvm-config --libdir exited with {}:\n{}\n", code, good_result.stderr); | | |
| 162 | } | | |
| 163 | }, | | |
| 164 | else => { | | |
| 165 | std.debug.panic("llvm-config failed:\n{}\n", good_result.stderr); | | |
| 166 | }, | | |
| 167 | } | | |
| 168 | good_result.stdout | | |
| 169 | }; | 106 | }; |
| | 107 | const libs_output = b.exec([][]const u8{llvm_config_exe, "--libs", "--system-libs"}); |
| | 108 | const includes_output = b.exec([][]const u8{llvm_config_exe, "--includedir"}); |
| | 109 | const libdir_output = b.exec([][]const u8{llvm_config_exe, "--libdir"}); |
| 170 | | 110 | |
| 171 | var result = LibraryDep { | 111 | var result = LibraryDep { |
| 172 | .libs = ArrayList([]const u8).init(b.allocator), | 112 | .libs = ArrayList([]const u8).init(b.allocator), |