1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
const std = @import("std");
const sketchbook = @import("sketchbook");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const sb = sketchbook.init(b, .{ .target = target, .optimize = optimize });
const canim = b.dependency("canim", .{ .target = target, .optimize = optimize });
const zt = b.dependency("ztrace", .{ .target = target, .optimize = optimize });
const app = sb.app(.{ .name = "ztrace-gui", .root_source_file = b.path("src/app.zig"), .imports = &.{
.{ .name = "canim", .module = canim.module("canim") },
.{ .name = "ztrace", .module = zt.module("ztrace") },
} });
b.installArtifact(zt.artifact("ztrace"));
const exe = b.addExecutable(.{ .name = "ztrace-gui", .root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{ .{ .name = "app", .module = app.module }, .{ .name = "host", .module = sb.modules.host }, .{ .name = "sketch", .module = sb.modules.sketch } },
}) });
b.installArtifact(exe);
const run = std.Build.Step.Run.create(b, "ztrace-gui");
run.addFileArg(b.graph.path(.install_bin, "ztrace-gui"));
run.step.dependOn(b.getInstallStep());
run.addPassthruArgs();
b.step("run", "Run the graphical debugger").dependOn(&run.step);
const test_run = std.Build.Step.Run.create(b, "GUI interactions");
test_run.addFileArg(b.graph.path(.install_bin, "ztrace-gui"));
test_run.step.dependOn(b.getInstallStep());
test_run.addArgs(&.{ "--headless", "--fresh", "--state" });
_ = test_run.addOutputFileArg("gui.state");
test_run.addArg("--script");
test_run.addFileArg(b.path("test/basic.script"));
const small = b.addExecutable(.{ .name = "gui-target", .root_module = b.createModule(.{ .target = target, .optimize = .Debug, .link_libc = true, .sanitize_c = .off }) });
small.root_module.addCSourceFile(.{ .file = b.path("targets/loop.c"), .flags = &.{ "-g", "-O0" } });
test_run.addArg("--define");
test_run.addPrefixedFileArg("TARGET=", small.getEmittedBin());
test_run.addArg("--define");
_ = test_run.addPrefixedOutputFileArg("STRIKE=", "strike.png");
test_run.addArg("--define");
_ = test_run.addPrefixedOutputFileArg("SETTLED=", "settled.png");
test_run.addArg("--define");
_ = test_run.addPrefixedOutputFileArg("LENS=", "lens.png");
test_run.addArg("--define");
_ = test_run.addPrefixedOutputFileArg("LENS_SETTLED=", "lens-settled.png");
test_run.addArg("--define");
_ = test_run.addPrefixedOutputFileArg("FRAME_LENS=", "frame-lens.png");
test_run.expectExitCode(0);
const tests = b.step("test", "Test real debugger interactions through the GUI");
tests.dependOn(&test_run.step);
const navigation = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/Navigation.zig"), .target = target, .optimize = optimize }) });
tests.dependOn(&b.addRunArtifact(navigation).step);
const geometry = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/Geometry.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "sketch", .module = sb.modules.sketch }} }) });
tests.dependOn(&b.addRunArtifact(geometry).step);
const inspection = b.addSystemCommand(&.{"python3"});
inspection.addFileArg(b.path("test/inspection.py"));
inspection.addArg("--ztrace");
inspection.addFileArg(b.graph.path(.install_bin, "ztrace"));
inspection.step.dependOn(b.getInstallStep());
tests.dependOn(&inspection.step);
const adaptive = b.addSystemCommand(&.{"python3"});
adaptive.addFileArg(b.path("test/adaptive.py"));
adaptive.addArg("--gui");
adaptive.addFileArg(b.graph.path(.install_bin, "ztrace-gui"));
adaptive.step.dependOn(b.getInstallStep());
tests.dependOn(&adaptive.step);
}
|