diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 42 |
1 files changed, 39 insertions, 3 deletions
@@ -81,6 +81,7 @@ pub fn build(b: *Build) void { // No optimize mode of its own: the host's Zig code builds in the mode // of the executable it is part of (`script_optimize` makes use of it). const cloud9 = b.dependency("cloud9", .{ .target = target, .optimize = optimize }).module("cloud9"); + b.modules.put(b.graph.arena, "cloud9", cloud9) catch @panic("OOM"); const host = b.addModule("host", .{ .root_source_file = b.path("src/host/root.zig"), .target = target, @@ -110,7 +111,7 @@ pub fn build(b: *Build) void { }); b.installArtifact(host_exe); - var sb: Sketchbook = .{ .b = b, .target = target, .optimize = optimize, .modules = .{ .abi = abi, .sketch = sketch, .host = host, .tracy = tracy, .vector = undefined, .scope = undefined, .anim = undefined, .gltf = gltf }, .host_exe = host_exe, .gltf_generator = gltf_generator, .web = b.path("web"), .glsl = b.path("src/glsl.zig"), .tools = b.path("tools"), .anim_dir = b.path("src/anim"), .gltf_render_dir = b.path("src/gltf_render"), .script_optimize = optimize, .shared = .create(b) }; + var sb: Sketchbook = .{ .b = b, .target = target, .optimize = optimize, .modules = .{ .abi = abi, .sketch = sketch, .host = host, .tracy = tracy, .vector = undefined, .scope = undefined, .anim = undefined, .gltf = gltf, .cloud9 = cloud9 }, .host_exe = host_exe, .gltf_generator = gltf_generator, .web = b.path("web"), .glsl = b.path("src/glsl.zig"), .tools = b.path("tools"), .anim_dir = b.path("src/anim"), .gltf_render_dir = b.path("src/gltf_render"), .script_optimize = optimize, .shared = .create(b) }; // Vector graphics: built with the same shader step apps use. Both forms // of its shaders are exported, so apps' web builds can swap them too. @@ -549,6 +550,39 @@ pub fn build(b: *Build) void { test_step.dependOn(&paths.step); b.step("test-paths", "Check where the save goes").dependOn(&paths.step); + // The tree by name and the fs verbs, live and with the sketch closed. + const tree = b.addSystemCommand(&.{ "sh", "-c", + \\set -e + \\exe=$(realpath "$0"); lib=$(realpath "$1"); mkdir -p "$2"; d=$(realpath "$2") + \\rm -rf "$d"/*; cd "$d"; rt=$(mktemp -d /tmp/sketchbook-fs.XXXXXX) + \\unset PARDES_PID PARDES_9P PARDES_PANE PARDES_MOUNT NINE_MOUNT NINE_MNTGEN + \\export XDG_RUNTIME_DIR="$rt" XDG_DATA_HOME="$d/data" + \\fs() { "$exe" --9p fstest "$lib" fs "$@"; } + \\"$exe" --headless --fresh --state live.xitdb --9p fstest "$lib" & pid=$! + \\trap 'kill $pid 2>/dev/null || true; rm -rf "$rt"' EXIT + \\i=0; while ! test -S "$rt"/9p/sketchbook/fstest; do i=$((i+1)); test $i -lt 500; sleep 0.01; done + \\fs ls | grep -qx 'state/' + \\fs write state/dots/buffer/2/kind big; test "$(fs read state/dots/buffer/2/kind)" = .big + \\! fs write state/dots/buffer/2/kind huge 2>err; grep -q InvalidValue err + \\fs write ctl 'click 30 40' + \\test "$(fs read screen.png | head -c 4 | tail -c 3)" = PNG + \\fs help state/dots | grep -q '^state/dots/len ' + \\fs help ctl | grep -q '^ click X Y ' + \\fs write ctl quit; wait $pid + \\test ! -e "$rt"/9p/sketchbook/fstest + \\test "$(fs read state/dots/buffer/2/kind)" = .small + \\! fs read status 2>err; grep -q 'replay is not running' err + \\rm -rf "$d"/* + }); + tree.setName("the tree by name, live and closed"); + tree.addArtifactArg(host_exe); + tree.addArtifactArg(recorded); + _ = tree.addOutputDirectoryArg("tree"); + tree.has_side_effects = true; + tree.expectExitCode(0); + test_step.dependOn(&tree.step); + b.step("test-fs", "Drive a sketch's tree by name with the fs verbs, running and closed").dependOn(&tree.step); + // Recorded input replays to the same state: played, seeked, stepped, // and after a live pointer move (core host behaviour, not an API). const replay = b.addRunArtifact(host_exe); @@ -741,7 +775,7 @@ pub fn init(b: *Build, options: Options) Sketchbook { .b = b, .target = options.target, .optimize = options.optimize, - .modules = .{ .abi = dep.module("abi"), .sketch = dep.module("sketch"), .host = dep.module("host"), .tracy = dep.module("tracy"), .vector = dep.module("vector"), .scope = dep.module("scope"), .anim = dep.module("anim"), .gltf = dep.module("gltf") }, + .modules = .{ .abi = dep.module("abi"), .sketch = dep.module("sketch"), .host = dep.module("host"), .tracy = dep.module("tracy"), .vector = dep.module("vector"), .scope = dep.module("scope"), .anim = dep.module("anim"), .gltf = dep.module("gltf"), .cloud9 = dep.module("cloud9") }, .host_exe = dep.artifact("sketchbook"), .gltf_generator = dep.artifact("gltf-bindings"), .web = dep.path("web"), @@ -791,7 +825,9 @@ pub const Sketchbook = struct { /// waveform, spectrogram, spectrum and oscilloscope views of a sound. /// `anim`: manim-style scenes as code (see `addScene`). /// `gltf`: native glTF/GLB documents, accessors and extras through cgltf. - modules: struct { abi: *Build.Module, sketch: *Build.Module, host: *Build.Module, tracy: *Build.Module, vector: *Build.Module, scope: *Build.Module, anim: *Build.Module, gltf: *Build.Module }, + /// `cloud9` is the 9P library the host serves its tree with: its `Fsys` + /// dials a sketch's executable from the app's own tests. + modules: struct { abi: *Build.Module, sketch: *Build.Module, host: *Build.Module, tracy: *Build.Module, vector: *Build.Module, scope: *Build.Module, anim: *Build.Module, gltf: *Build.Module, cloud9: *Build.Module }, /// The generic host: loads and hot-reloads a sketch library. host_exe: *Build.Step.Compile, /// `host.js` and the `index.html` template. |
