summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-16 23:46:16 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit5dc2c61f1df30d2dd84fbba6d0e8895a62c3b2b5 (patch)
treeca8907b582fb2c1fda197aa1011e5ea5f2725a46 /build.zig
parentca602943e3fc9faad24e51497eeafb0ae7856800 (diff)
downloadsketchbook-5dc2c61f1df30d2dd84fbba6d0e8895a62c3b2b5.tar.gz
sketchbook-5dc2c61f1df30d2dd84fbba6d0e8895a62c3b2b5.zip
Export a session to a file of its own, and import one
export-session [S] FILE writes session S (this run's by default, committed first), with the marks and clips that point into it, as session 0 of a new database: written beside FILE, synced, renamed over it. import FILE appends each session of such a file to this database, from "import <file name>", its marks and clips renamed NAME@<file name> (cut to 32 bytes). The copy is value by value, the same few lines for both, over whatever a session holds; sessions lists where one came from. test-import records test/past.script's session, exports it, imports it into another database and replays it there: the mark it carries is the State half a second in exactly, and two seconds in is frame 120's. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index 809ddb1..d8da703 100644
--- a/build.zig
+++ b/build.zig
@@ -386,6 +386,29 @@ pub fn build(b: *Build) void {
test_step.dependOn(&past.step);
b.step("test-past", "Replay past sessions, to a time and across a code change").dependOn(&past.step);
+ // A session exported from one database and imported into another plays
+ // there to the same State: at the mark it carries, and two seconds in.
+ const moved = b.addSystemCommand(&.{ "sh", "-c",
+ \\set -e
+ \\mkdir -p "$4"; d=$(realpath "$4"); rm -f "$d"/*
+ \\"$0" --headless --script "$1" --state "$d/a.state" "$5"
+ \\"$0" --headless --script "$2" --state "$d/a.state" --define file="$d/one.xitdb" "$5"
+ \\"$0" --headless --script "$3" --state "$d/z.state" --define file="$d/one.xitdb" "$5"
+ \\test "$(stat -c %s "$d/one.xitdb")" -lt 1048576
+ \\rm -f "$d"/*
+ });
+ moved.setName("export and import a session");
+ moved.addArtifactArg(host_exe);
+ moved.addFileArg(b.path("test/past.script"));
+ moved.addFileArg(b.path("test/session_export.script"));
+ moved.addFileArg(b.path("test/session_import.script"));
+ _ = moved.addOutputDirectoryArg("import");
+ moved.addArtifactArg(recorded);
+ moved.has_side_effects = true;
+ moved.expectExitCode(0);
+ test_step.dependOn(&moved.step);
+ b.step("test-import", "Export a session from one database, import it into another, replay it").dependOn(&moved.step);
+
// Where files go. Without --state: the XDG data directory, state and
// sessions. In .sketchbook/ (`zig build run`'s): a .gitignore, and an
// older build's state moved in, once, never over a file there.