diff options
-rw-r--r-- | build.zig | 18 | ||||
-rw-r--r-- | src/test.zig | 5 |
2 files changed, 14 insertions, 9 deletions
diff --git a/build.zig b/build.zig index f869257..8fe6807 100644 --- a/build.zig +++ b/build.zig @@ -1,12 +1,12 @@ //! Build recipe const Build = std.Build; +const CompileStep = Build.CompileStep; +const CrossTarget = std.zig.CrossTarget; +const Mode = std.builtin.Mode; const getExternalExecutor = std.zig.system.NativeTargetInfo.getExternalExecutor; const std = @import("std"); -pub fn build(b: *Build) !void { - const target = b.standardTargetOptions(.{}); - const optimize = b.standardOptimizeOption(.{}); - +fn addExecutable(b: *Build, target: CrossTarget, optimize: Mode) *CompileStep { const bin = b.addExecutable(.{ .name = "roux", .root_source_file = .{ .path = "src/main.zig" }, @@ -30,6 +30,14 @@ pub fn build(b: *Build) !void { "arm64/targ.c", "arm64/abi.c", "arm64/isel.c", "arm64/emit.c", "rv64/targ.c", "rv64/abi.c", "rv64/isel.c", "rv64/emit.c", }, &cflags); + return bin; +} + +pub fn build(b: *Build) !void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const bin = addExecutable(b, target, optimize); b.installArtifact(bin); const run_cmd = b.addRunArtifact(bin); run_cmd.step.dependOn(b.getInstallStep()); @@ -44,7 +52,7 @@ pub fn build(b: *Build) !void { }); const run_tests = b.addRunArtifact(tests); run_tests.addArg("-b"); - run_tests.addArtifactArg(bin); + run_tests.addArtifactArg(addExecutable(b, .{}, optimize)); run_tests.addArgs(&.{ "-z", b.zig_exe }); run_tests.addArgs(&.{ "-t", try target.zigTriple(b.allocator) }); switch (getExternalExecutor(tests.target_info, bin.target_info, .{})) { diff --git a/src/test.zig b/src/test.zig index 04d7f00..cdd9805 100644 --- a/src/test.zig +++ b/src/test.zig @@ -232,10 +232,7 @@ fn check(ssa: []const u8) anyerror!void { const s = try joinPath(allocator, &.{ dir, "a.s" }); defer allocator.free(s); const ir_loc = b: { - const ir = try collectOutput(if (emulator) |executor| - &.{ executor, bin, ssa } - else - &.{ bin, ssa }); + const ir = try collectOutput(&.{ bin, "-t", qbe_target, ssa }); errdefer allocator.free(ir); try tmp.parent_dir.writeFile(s, ir); break :b loc(ir); |