| ... | @@ -34,15 +34,6 @@ pub fn build(b: *Builder) !void { | ... | @@ -34,15 +34,6 @@ pub fn build(b: *Builder) !void { |
| 34 | | 34 | |
| 35 | const test_step = b.step("test", "Run all the tests"); | 35 | const test_step = b.step("test", "Run all the tests"); |
| 36 | | 36 | |
| 37 | const config_h_text = if (b.option( | | |
| 38 | []const u8, | | |
| 39 | "config_h", | | |
| 40 | "Path to the generated config.h", | | |
| 41 | )) |config_h_path| | | |
| 42 | try std.fs.cwd().readFileAlloc(b.allocator, toNativePathSep(b, config_h_path), max_config_h_bytes) | | |
| 43 | else | | |
| 44 | try findAndReadConfigH(b); | | |
| 45 | | | |
| 46 | var test_stage2 = b.addTest("src-self-hosted/test.zig"); | 37 | var test_stage2 = b.addTest("src-self-hosted/test.zig"); |
| 47 | test_stage2.setBuildMode(.Debug); // note this is only the mode of the test harness | 38 | test_stage2.setBuildMode(.Debug); // note this is only the mode of the test harness |
| 48 | test_stage2.addPackagePath("stage2_tests", "test/stage2/test.zig"); | 39 | test_stage2.addPackagePath("stage2_tests", "test/stage2/test.zig"); |
| ... | @@ -58,6 +49,7 @@ pub fn build(b: *Builder) !void { | ... | @@ -58,6 +49,7 @@ pub fn build(b: *Builder) !void { |
| 58 | | 49 | |
| 59 | const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false; | 50 | const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false; |
| 60 | const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse false; | 51 | const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse false; |
| | 52 | const config_h_path_option = b.option([]const u8, "config_h", "Path to the generated config.h"); |
| 61 | | 53 | |
| 62 | if (!only_install_lib_files) { | 54 | if (!only_install_lib_files) { |
| 63 | var exe = b.addExecutable("zig", "src-self-hosted/main.zig"); | 55 | var exe = b.addExecutable("zig", "src-self-hosted/main.zig"); |
| ... | @@ -66,6 +58,11 @@ pub fn build(b: *Builder) !void { | ... | @@ -66,6 +58,11 @@ pub fn build(b: *Builder) !void { |
| 66 | b.default_step.dependOn(&exe.step); | 58 | b.default_step.dependOn(&exe.step); |
| 67 | | 59 | |
| 68 | if (enable_llvm) { | 60 | if (enable_llvm) { |
| | 61 | const config_h_text = if (config_h_path_option) |config_h_path| |
| | 62 | try std.fs.cwd().readFileAlloc(b.allocator, toNativePathSep(b, config_h_path), max_config_h_bytes) |
| | 63 | else |
| | 64 | try findAndReadConfigH(b); |
| | 65 | |
| 69 | var ctx = parseConfigH(b, config_h_text); | 66 | var ctx = parseConfigH(b, config_h_text); |
| 70 | ctx.llvm = try findLLVM(b, ctx.llvm_config_exe); | 67 | ctx.llvm = try findLLVM(b, ctx.llvm_config_exe); |
| 71 | | 68 | |