diff options
| author | Chris Boesch <chrboesch@noreply.codeberg.org> | 2024-08-22 16:44:30 +0000 |
|---|---|---|
| committer | Chris Boesch <chrboesch@noreply.codeberg.org> | 2024-08-22 16:44:30 +0000 |
| commit | 296a2b5c6ad3b03dbd237453e7c267d1ca1bab07 (patch) | |
| tree | c2da51c2ff2769f9f1352b8ae209bc4123cabd24 /build.zig | |
| parent | ed88236fa729f12e98fafc6fd39a3c7913f10511 (diff) | |
| parent | 8e35cf79901ffe38b3325412a605fdb6cefbeb8f (diff) | |
Merge pull request 'Fixes changes in zig build system.' (#148) from i_147 into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/148
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -15,7 +15,7 @@ const print = std.debug.print; // 1) Getting Started // 2) Version Changes comptime { - const required_zig = "0.14.0-dev.839"; + const required_zig = "0.14.0-dev.1224"; const current_zig = builtin.zig_version; const min_zig = std.SemanticVersion.parse(required_zig) catch unreachable; if (current_zig.order(min_zig) == .lt) { @@ -316,7 +316,7 @@ const ZiglingStep = struct { std.process.exit(2); }; - self.run(exe_path.?, options.progress_node) catch { + self.run(exe_path, options.progress_node) catch { self.printErrors(); if (self.exercise.hint) |hint| @@ -426,7 +426,7 @@ const ZiglingStep = struct { print("{s}PASSED{s}\n\n", .{ green_text, reset_text }); } - fn compile(self: *ZiglingStep, prog_node: std.Progress.Node) !?[]const u8 { + fn compile(self: *ZiglingStep, prog_node: std.Progress.Node) ![]const u8 { print("Compiling: {s}\n", .{self.exercise.main_file}); const b = self.step.owner; @@ -457,7 +457,21 @@ const ZiglingStep = struct { zig_args.append("--listen=-") catch @panic("OOM"); - return try self.step.evalZigProcess(zig_args.items, prog_node, false); + // + // NOTE: After many changes in zig build system, we need to create the cache path manually. + // See https://github.com/ziglang/zig/pull/21115 + // Maybe there is a better way (in the future). + const exe_dir = try self.step.evalZigProcess(zig_args.items, prog_node, false); + const exe_name = switch (self.exercise.kind) { + .exe => self.exercise.name(), + .@"test" => "test", + }; + const sep = std.fs.path.sep_str; + const root_path = exe_dir.?.root_dir.path.?; + const sub_path = exe_dir.?.subPathOrDot(); + const exe_path = b.fmt("{s}{s}{s}{s}{s}", .{ root_path, sep, sub_path, sep, exe_name }); + + return exe_path; } fn help(self: *ZiglingStep) void { |
