From 65aac132571a887d181120ba37197e3e4d931c9c Mon Sep 17 00:00:00 2001 From: pfg Date: Fri, 3 Jul 2020 18:15:01 -0700 Subject: [PATCH] don't try to find config_h if it's not needed --- build.zig | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/build.zig b/build.zig index 3daef75a58..f9cd1b0dea 100644 --- a/build.zig +++ b/build.zig @@ -34,15 +34,6 @@ pub fn build(b: *Builder) !void { const test_step = b.step("test", "Run all the tests"); - const config_h_text = if (b.option( - []const u8, - "config_h", - "Path to the generated config.h", - )) |config_h_path| - try std.fs.cwd().readFileAlloc(b.allocator, toNativePathSep(b, config_h_path), max_config_h_bytes) - else - try findAndReadConfigH(b); - var test_stage2 = b.addTest("src-self-hosted/test.zig"); test_stage2.setBuildMode(.Debug); // note this is only the mode of the test harness test_stage2.addPackagePath("stage2_tests", "test/stage2/test.zig"); @@ -58,6 +49,7 @@ pub fn build(b: *Builder) !void { const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false; const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse false; + const config_h_path_option = b.option([]const u8, "config_h", "Path to the generated config.h"); if (!only_install_lib_files) { var exe = b.addExecutable("zig", "src-self-hosted/main.zig"); @@ -66,6 +58,11 @@ pub fn build(b: *Builder) !void { b.default_step.dependOn(&exe.step); if (enable_llvm) { + const config_h_text = if (config_h_path_option) |config_h_path| + try std.fs.cwd().readFileAlloc(b.allocator, toNativePathSep(b, config_h_path), max_config_h_bytes) + else + try findAndReadConfigH(b); + var ctx = parseConfigH(b, config_h_text); ctx.llvm = try findLLVM(b, ctx.llvm_config_exe);