From 1cf910fb51259e786e8964072eb98a17353bc3c8 Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Sat, 8 Apr 2023 09:02:38 +0200 Subject: [PATCH] build: enable full parallelism when -Dhealed is set The eowyn.sh script is used in a github workflow, but after commit 0d56ba3 (build: restore the exercise chain), the github action will take more time to complete. Enable full build parallelism, when -Dhealed is true and -Dn is null. Use the standard CompileStep and RunStep, instead of ZiglingStep. On my PC, this change reduces the build time by about 30%. --- build.zig | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index d2702d0..6a0bcb8 100644 --- a/build.zig +++ b/build.zig @@ -593,6 +593,28 @@ pub fn build(b: *Build) !void { } start_step.dependOn(&prev_step.step); + return; + } else if (use_healed) { + const test_step = b.step("test", "Test the healed exercises"); + b.default_step = test_step; + + for (exercises) |ex| { + const base_name = ex.baseName(); + const file_path = std.fs.path.join(b.allocator, &[_][]const u8{ + "patches/healed", ex.main_file, + }) catch unreachable; + + const build_step = b.addExecutable(.{ .name = base_name, .root_source_file = .{ .path = file_path } }); + if (ex.C) { + build_step.linkLibC(); + } + build_step.install(); + + const run_step = build_step.run(); + + test_step.dependOn(&run_step.step); + } + return; } @@ -604,7 +626,7 @@ pub fn build(b: *Build) !void { for (exercises, 0..) |ex, i| { const base_name = ex.baseName(); const file_path = std.fs.path.join(b.allocator, &[_][]const u8{ - if (use_healed) "patches/healed" else "exercises", ex.main_file, + "exercises", ex.main_file, }) catch unreachable; const build_step = b.addExecutable(.{ .name = base_name, .root_source_file = .{ .path = file_path } });