diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-30 21:34:41 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-12 13:22:02 -0300 |
| commit | 2348776791e9dd17afeb12a06ba42a4a71917bcf (patch) | |
| tree | 780c4b12b76c8b97a28408dd40944d65f159fdc7 /src/host/root.zig | |
| parent | 590ba7b9b579b97e34b51ab7e3460ebc85713343 (diff) | |
| download | sketchbook-2348776791e9dd17afeb12a06ba42a4a71917bcf.tar.gz sketchbook-2348776791e9dd17afeb12a06ba42a4a71917bcf.zip | |
sketchbook: a drawing layer on top, host fixes for replay and migration
Diffstat (limited to 'src/host/root.zig')
| -rw-r--r-- | src/host/root.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/host/root.zig b/src/host/root.zig index 2876c0f..8cc15e1 100644 --- a/src/host/root.zig +++ b/src/host/root.zig @@ -59,6 +59,22 @@ pub fn main(init: std.process.Init, linked: ?abi.Sketch) !void { } if (linked == null and options.library == null) fatal("no sketch library given (see --help)"); + // A scripted run from fresh state works on files of its own, moved to + // the given path at exit: two runs of one build step (two `zig build`s + // at once share its output path) never share a state, store or + // recordings file, nor fail on the store's lock. + var private_buf: [std.fs.max_path_bytes]u8 = undefined; + const given = options.state; + const private = script_path != null and options.fresh; + if (private) options.state = std.mem.print(&private_buf, "{s}.{d}", .{ given, std.os.linux.getpid() }) catch fatal("--state path too long"); + defer if (private) for ([_][]const u8{ "", ".inputs", ".store" }) |suffix| { + var from: [std.fs.max_path_bytes + 16]u8 = undefined; + var to: [std.fs.max_path_bytes + 16]u8 = undefined; + const a = std.mem.printSentinel(&from, "{s}{s}", .{ options.state, suffix }, 0) catch continue; + const b = std.mem.printSentinel(&to, "{s}{s}", .{ given, suffix }, 0) catch continue; + _ = std.os.linux.rename(a.ptr, b.ptr); + }; + sdl_heap.install(); { var host: Host = undefined; |
