summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig29
1 files changed, 15 insertions, 14 deletions
diff --git a/build.zig b/build.zig
index 7e3c812d..12b7b35c 100644
--- a/build.zig
+++ b/build.zig
@@ -161,18 +161,12 @@ pub fn build(b: *std.Build) void {
const tracy = b.option([]const u8, "tracy", "enable Tracy profiling; supply the path to a Tracy source checkout");
const macos_sdk = b.option([]const u8, "macos-sdk", "the macOS SDK a gui built for macOS from another system takes SDL's headers and frameworks from");
const macos_identity = b.option([]const u8, "macos-identity", "codesigning identity for pardes.app (default: ad-hoc)") orelse "-";
- const prebuilt_shaders = b.option(bool, "prebuilt-shaders", "embed the committed shaders/prebuilt/*.spv instead of running glslc (default: on for a bare `zig build`, off when -Dplatform names a shell)") orelse also_gui;
+ const prebuilt_shaders = b.option(bool, "prebuilt-shaders", "embed sketchbook's committed src/gpu/shaders/prebuilt/*.spv instead of running glslc over its GLSL (default: on for a bare `zig build`, off when -Dplatform names a shell)") orelse also_gui;
const mupdf_check = b.step("mupdf-check", "the pdf addon's check: MuPDF compiles, links, renders and searches docs/design.pdf, and its script runs");
const pdf_pointer_bench_step = b.step("pdf-pointer-bench", "time PDF hover and selection gestures and prove their pixels (-Doptimize=ReleaseFast -- [--label L] [--reps N] [--path FILE] [--cell WxH])");
const pdf_scroll_bench_step = b.step("pdf-scroll-bench", "benchmark fast continuous-strip PDF scrolling in ReleaseFast (-Doptimize=ReleaseFast -- [--json] [--reps N] [--warmup N] [--path FILE])");
- const shaders_step = b.step("shaders", "refresh the committed shaders/prebuilt/*.spv (glslc)");
- const update_shaders = b.addUpdateSourceFiles();
- for (gui_shaders) |name| {
- update_shaders.addCopyFileToSource(compileGlsl(b, name), b.fmt("shaders/prebuilt/{s}.spv", .{name}));
- }
- shaders_step.dependOn(&update_shaders.step);
// build-time IO: slurps the grammars' highlights.scm queries, and reads
// vendor/themes to find the theme sources
@@ -899,6 +893,8 @@ pub fn build(b: *std.Build) void {
const gui_shell_mods: [2]?*std.Build.Module = .{ gui_shell_mod, if (platform == .gui) static_mod else null };
// SDL's headers, for the macOS trackpad adapter's test after the loop.
var sdl_include: ?std.Build.LazyPath = null;
+ // sketchbook's Cells.zig's own tests (the instance ABI), for unit-test.
+ var cells_test: ?*std.Build.Step.Compile = null;
for (gui_shell_mods) |gui_shell_entry| if (gui_shell_entry) |gm| {
// SDL's build asks a cross build for macOS for the SDK's paths.
const sdk: ?std.Build.LazyPath = if (macos_sdk) |p| .{ .cwd_relative = p } else null;
@@ -927,6 +923,10 @@ pub fn build(b: *std.Build) void {
if (b.lazyDependency("sketchbook", .{ .@"gpu-only" = true })) |sb| {
const gpu = b.createModule(.{ .root_source_file = sb.path("src/gpu/Executor.zig"), .imports = &.{ .{ .name = "abi", .module = sb.module("abi") }, .{ .name = "c", .module = gui_c_mod } } });
gm.addImport("sketch_gpu", gpu);
+ // pardes's renderer, moved to sketchbook (src/gpu/), compiled
+ // against pardes's SDL; its tests run with unit-test.
+ gm.addImport("gpu_cells", b.createModule(.{ .root_source_file = sb.path("src/gpu/Cells.zig"), .imports = &.{.{ .name = "c", .module = gui_c_mod }} }));
+ if (cells_test == null) cells_test = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = sb.path("src/gpu/Cells.zig"), .target = target, .optimize = optimize, .imports = &.{.{ .name = "c", .module = gui_c_mod }} }), .filters = test_filters });
gm.addImport("gpu_scene", sb.module("gpu_scene"));
}
sdl_include = dep.path("include");
@@ -993,11 +993,11 @@ pub fn build(b: *std.Build) void {
gm.addAnonymousImport("AdwaitaMono-Regular.ttf", .{
.root_source_file = b.path("assets/AdwaitaMono-Regular.ttf"),
});
- for (gui_shaders) |name| gm.addAnonymousImport(b.fmt("{s}.spv", .{name}), .{
+ if (b.lazyDependency("sketchbook", .{ .@"gpu-only" = true })) |sb| for (gui_shaders) |name| gm.addAnonymousImport(b.fmt("{s}.spv", .{name}), .{
.root_source_file = if (prebuilt_shaders)
- b.path(b.fmt("shaders/prebuilt/{s}.spv", .{name}))
+ sb.path(b.fmt("src/gpu/shaders/prebuilt/{s}.spv", .{name}))
else
- compileGlsl(b, name),
+ compileGlsl(b, sb.path(b.fmt("src/gpu/shaders/{s}.glsl", .{name})), name),
});
};
if (target.result.os.tag == .macos) if (sdl_include) |include| {
@@ -1588,6 +1588,7 @@ pub fn build(b: *std.Build) void {
// The perf and fs bench programs' own tests: they compile no editor.
_ = units.add(b, perf_tests, null);
_ = units.add(b, fs_bench_test, null);
+ if (cells_test) |t| _ = units.add(b, t, null);
const core_test = b.addTest(.{ .root_module = core_module, .filters = test_filters });
const run_core_test = b.addRunArtifact(core_test);
run_core_test.has_side_effects = true;
@@ -2032,12 +2033,12 @@ fn reindexed(b: *std.Build, archive: std.Build.LazyPath, index: usize) std.Build
return run.addOutputFileArg(b.fmt("{d}.a", .{index}));
}
-/// glslc shaders/<name>.glsl -fshader-stage=<vertex|fragment> -o <name>.spv,
-/// returned as a LazyPath for @embedFile. The stage is the name's own suffix.
-fn compileGlsl(b: *std.Build, name: []const u8) std.Build.LazyPath {
+/// glslc <glsl> -fshader-stage=<vertex|fragment> -o <name>.spv, returned as
+/// a LazyPath for @embedFile. The stage is the name's own suffix.
+fn compileGlsl(b: *std.Build, glsl: std.Build.LazyPath, name: []const u8) std.Build.LazyPath {
const stage = if (std.mem.endsWith(u8, name, ".vert")) "vertex" else "fragment";
const cmd = b.addSystemCommand(&.{ "glslc", b.fmt("-fshader-stage={s}", .{stage}) });
- cmd.addFileArg(b.path(b.fmt("shaders/{s}.glsl", .{name})));
+ cmd.addFileArg(glsl);
cmd.addArg("-o");
return cmd.addOutputFileArg(b.fmt("{s}.spv", .{name}));
}