diff options
| author | Chris Boesch <chrboesch@noreply.codeberg.org> | 2026-06-26 12:40:52 +0200 |
|---|---|---|
| committer | Chris Boesch <chrboesch@noreply.codeberg.org> | 2026-06-26 12:40:52 +0200 |
| commit | e55204d3429fbe4077c142e3a6a6e5a49e9ccb2b (patch) | |
| tree | 56665a6298818bf883a64368d627fea255c0a805 | |
| parent | 529b294cc3da53702905cace380c3e5d9282a69a (diff) | |
| parent | fe465a466e436c9362449f8ffe2701970b8cac39 (diff) | |
Merge pull request 'added absolute path to exercises' (#475) from root_path into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/475
| -rw-r--r-- | build.zig | 1 | ||||
| -rw-r--r-- | rivendell/elrond.zig | 7 |
2 files changed, 7 insertions, 1 deletions
@@ -81,6 +81,7 @@ pub fn build(b: *Build) !void { const run = b.addRunArtifact(elrond); run.addArg(b.fmt("--zig={s}", .{b.graph.zig_exe})); run.addArg(b.fmt("--work-path={s}", .{work_path})); + run.addArg(b.fmt("--root-path={s}", .{b.root.root_dir.path.?})); if (exno) |n| { run.addArg(b.fmt("--only={d}", .{n})); diff --git a/rivendell/elrond.zig b/rivendell/elrond.zig index d7a0e1a..fa0ed22 100644 --- a/rivendell/elrond.zig +++ b/rivendell/elrond.zig @@ -109,6 +109,7 @@ const Context = struct { arena: std.mem.Allocator, zig_exe: []const u8, work_path: []const u8, + root_path: []const u8, }; const Error = error{Failed}; @@ -158,6 +159,7 @@ pub fn main(init: std.process.Init) !void { var zig_exe: []const u8 = "zig"; var work_path: []const u8 = "exercises"; + var root_path: []const u8 = ""; var mode: Mode = .normal; var only_n: ?usize = null; var start_n: ?usize = null; @@ -170,6 +172,8 @@ pub fn main(init: std.process.Init) !void { zig_exe = v; } else if (cutPrefix(u8, arg, "--work-path=")) |v| { work_path = v; + } else if (cutPrefix(u8, arg, "--root-path=")) |v| { + root_path = v; } else if (cutPrefix(u8, arg, "--only=")) |v| { only_n = std.fmt.parseInt(usize, v, 10) catch { print("invalid --only value: {s}\n", .{v}); @@ -197,6 +201,7 @@ pub fn main(init: std.process.Init) !void { .arena = arena, .zig_exe = zig_exe, .work_path = work_path, + .root_path = root_path, }; switch (mode) { @@ -310,7 +315,7 @@ fn runExe(ctx: Context, ex: Exercise) !void { const arena = ctx.arena; print("Compiling {s}...\n", .{ex.main_file}); - const path = std.fs.path.join(arena, &.{ ctx.work_path, ex.main_file }) catch @panic("OOM"); + const path = std.fs.path.join(arena, &.{ ctx.root_path, ctx.work_path, ex.main_file }) catch @panic("OOM"); var argv = std.ArrayList([]const u8).initCapacity(arena, 8) catch @panic("OOM"); argv.append(arena, ctx.zig_exe) catch @panic("OOM"); |
