aboutsummaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-12-12 16:03:20 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-12-12 16:03:20 -0500
commit2b9302107fdd4adbbcfc2735afd7f2e4cd4c6769 (patch)
tree2066ea0666b9f3c3794e2eb40b84a9b31e96283b /build.zig
parentcd5fd653d7dd738d4c67b304e9cb17fb211f0163 (diff)
downloadzig-2b9302107fdd4adbbcfc2735afd7f2e4cd4c6769.tar.gz
zig-2b9302107fdd4adbbcfc2735afd7f2e4cd4c6769.zip
self-hosted: cleanup build looking for llvm-config
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig88
1 files changed, 14 insertions, 74 deletions
diff --git a/build.zig b/build.zig
index 223c225383..2ac98634ae 100644
--- a/build.zig
+++ b/build.zig
@@ -92,81 +92,21 @@ const LibraryDep = struct {
};
fn findLLVM(b: &Builder) -> LibraryDep {
- const libs_output = {
- const args1 = [][]const u8{"llvm-config-5.0", "--libs", "--system-libs"};
- const args2 = [][]const u8{"llvm-config", "--libs", "--system-libs"};
- const max_output_size = 10 * 1024;
- const good_result = os.ChildProcess.exec(b.allocator, args1, null, null, max_output_size) %% |err| {
- if (err == error.FileNotFound) {
- os.ChildProcess.exec(b.allocator, args2, null, null, max_output_size) %% |err2| {
- std.debug.panic("unable to spawn {}: {}\n", args2[0], err2);
- }
- } else {
- std.debug.panic("unable to spawn {}: {}\n", args1[0], err);
- }
- };
- switch (good_result.term) {
- os.ChildProcess.Term.Exited => |code| {
- if (code != 0) {
- std.debug.panic("llvm-config exited with {}:\n{}\n", code, good_result.stderr);
- }
- },
- else => {
- std.debug.panic("llvm-config failed:\n{}\n", good_result.stderr);
- },
- }
- good_result.stdout
- };
- const includes_output = {
- const args1 = [][]const u8{"llvm-config-5.0", "--includedir"};
- const args2 = [][]const u8{"llvm-config", "--includedir"};
- const max_output_size = 10 * 1024;
- const good_result = os.ChildProcess.exec(b.allocator, args1, null, null, max_output_size) %% |err| {
- if (err == error.FileNotFound) {
- os.ChildProcess.exec(b.allocator, args2, null, null, max_output_size) %% |err2| {
- std.debug.panic("unable to spawn {}: {}\n", args2[0], err2);
- }
- } else {
- std.debug.panic("unable to spawn {}: {}\n", args1[0], err);
- }
- };
- switch (good_result.term) {
- os.ChildProcess.Term.Exited => |code| {
- if (code != 0) {
- std.debug.panic("llvm-config --includedir exited with {}:\n{}\n", code, good_result.stderr);
- }
- },
- else => {
- std.debug.panic("llvm-config failed:\n{}\n", good_result.stderr);
- },
- }
- good_result.stdout
- };
- const libdir_output = {
- const args1 = [][]const u8{"llvm-config-5.0", "--libdir"};
- const args2 = [][]const u8{"llvm-config", "--libdir"};
- const max_output_size = 10 * 1024;
- const good_result = os.ChildProcess.exec(b.allocator, args1, null, null, max_output_size) %% |err| {
- if (err == error.FileNotFound) {
- os.ChildProcess.exec(b.allocator, args2, null, null, max_output_size) %% |err2| {
- std.debug.panic("unable to spawn {}: {}\n", args2[0], err2);
- }
- } else {
- std.debug.panic("unable to spawn {}: {}\n", args1[0], err);
- }
- };
- switch (good_result.term) {
- os.ChildProcess.Term.Exited => |code| {
- if (code != 0) {
- std.debug.panic("llvm-config --libdir exited with {}:\n{}\n", code, good_result.stderr);
- }
- },
- else => {
- std.debug.panic("llvm-config failed:\n{}\n", good_result.stderr);
- },
- }
- good_result.stdout
+ const llvm_config_exe = b.findProgram(
+ [][]const u8{"llvm-config-5.0", "llvm-config"},
+ [][]const u8{
+ "/usr/local/opt/llvm@5/",
+ "/mingw64/bin",
+ "/c/msys64/mingw64/bin",
+ "c:/msys64/mingw64/bin",
+ "C:/Libraries/llvm-5.0.0/bin",
+ }) %% |err|
+ {
+ std.debug.panic("unable to find llvm-config: {}\n", err);
};
+ const libs_output = b.exec([][]const u8{llvm_config_exe, "--libs", "--system-libs"});
+ const includes_output = b.exec([][]const u8{llvm_config_exe, "--includedir"});
+ const libdir_output = b.exec([][]const u8{llvm_config_exe, "--libdir"});
var result = LibraryDep {
.libs = ArrayList([]const u8).init(b.allocator),