From 859de57556dc5b97d6d41fa526beef0c850cf6c8 Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Tue, 15 Nov 2022 11:17:21 +0100 Subject: Don't iterate all configs in build script Instead, cicd will now have a job for every configuration --- .github/workflows/main.yml | 5 ++++- build.zig | 29 ++++++++--------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 16b04c1..eb6d82d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,9 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] + step: [examples, test] + compiler: [stage1=true, stage1=false] + release: [release-safe=false, release-safe=true, release-fast=true, release-small=true] runs-on: ${{matrix.os}} steps: - uses: actions/checkout@v3 @@ -18,7 +21,7 @@ jobs: - uses: goto-bus-stop/setup-zig@v2.0.1 with: version: master - - run: zig build + - run: zig build ${{ matrix.step }} -D${{ matrix.compiler }} -D${{ matrix.release }} lint: runs-on: ubuntu-latest steps: diff --git a/build.zig b/build.zig index 03834b4..6a128f2 100644 --- a/build.zig +++ b/build.zig @@ -5,32 +5,19 @@ const Builder = std.build.Builder; pub fn build(b: *Builder) void { const mode = b.standardReleaseOptions(); const target = b.standardTargetOptions(.{}); + const stage1 = b.option(bool, "stage1", "Use the stage 1 compiler") orelse false; - const test_all_step = b.step("test", "Run all tests in all modes."); - for ([_]bool{ true, false }) |stage1| { - for (std.meta.tags(std.builtin.Mode)) |test_mode| { - const mode_str = @tagName(test_mode); - const stage1_str = if (stage1) "stage1" else "stage2"; - - const tests = b.addTest("clap.zig"); - tests.setBuildMode(test_mode); - tests.setTarget(target); - tests.use_stage1 = stage1; - - const test_step = b.step( - b.fmt("test-{s}-{s}", .{ stage1_str, mode_str }), - b.fmt("Run all tests with {s} compiler in {s}.", .{ stage1_str, mode_str }), - ); - test_step.dependOn(&tests.step); - test_all_step.dependOn(test_step); - } - } + const test_step = b.step("test", "Run all tests in all modes."); + const tests = b.addTest("clap.zig"); + tests.setBuildMode(mode); + tests.setTarget(target); + tests.use_stage1 = stage1; + test_step.dependOn(&tests.step); const example_step = b.step("examples", "Build examples"); inline for (.{ "simple", "simple-ex", - //"simple-error", "streaming-clap", "help", "usage", @@ -49,7 +36,7 @@ pub fn build(b: *Builder) void { readme_step.dependOn(readme); const all_step = b.step("all", "Build everything and runs all tests"); - all_step.dependOn(test_all_step); + all_step.dependOn(test_step); all_step.dependOn(example_step); all_step.dependOn(readme_step); -- cgit v1.2.3