diff options
Diffstat (limited to 'build/addons.zig')
| -rw-r--r-- | build/addons.zig | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/build/addons.zig b/build/addons.zig index 195255fd..38b02dff 100644 --- a/build/addons.zig +++ b/build/addons.zig @@ -1,37 +1,37 @@ const std = @import("std"); const mupdf_build = @import("mupdf.zig"); -/// The GPU addons over sketchbook's `gpu_scene`: the snake (addons/snake_shader) -/// and the frame corpus's translucent veil (test/veil.zig). They are the -/// window build's, as sketchbook is: the terminal's configures without -/// sketchbook beside the checkout, and there their steps say so. -pub fn gpu(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang.Optimize, addon_mod: *std.Build.Module, window: bool) ?*std.Build.Step.Compile { +/// The GPU addons over sketchbook's scene format (`gpu_scene`): the snake +/// (addons/snake_shader) and the frame corpus's translucent veil +/// (test/veil.zig). They are the window build's, from the sketchbook it +/// takes (`gui.Window.sketchbook`, null off the window): the terminal's +/// configures without sketchbook beside the checkout, and there their steps +/// say so. +pub fn gpu(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang.Optimize, addon_mod: *std.Build.Module, sketchbook: ?*std.Build.Dependency) ?*std.Build.Step.Compile { const snake_shader_step = b.step("snake-shader", "build the optional GPU snake addon into zig-out/lib"); - var snake_shader_lib: ?*std.Build.Step.Compile = null; const veil_step = b.step("veil", "build the frame corpus's translucent GPU test addon (test/veil.zig) into zig-out/lib"); - if (!window) { + const sb = sketchbook orelse { const fail = b.addFail("the GPU addons are the window's: -Dplatform=gui (sketchbook beside this checkout)"); snake_shader_step.dependOn(&fail.step); veil_step.dependOn(&fail.step); - } else if (b.dependencyLazy("sketchbook", .{ .@"gpu-only" = true })) |sb| { - const files = b.addWriteFiles(); - for ([_][]const u8{ "vert", "frag", "post.frag" }) |stage| { - const compile = b.addSystemCommand(&.{ "glslc", "-O" }); - compile.addFileArg(b.path(b.fmt("addons/snake_shader/snake.{s}", .{stage}))); - compile.addArg("-o"); - _ = files.addCopyFile(compile.addOutputFileArg(b.fmt("snake.{s}.spv", .{stage})), b.fmt("{s}.spv", .{stage})); - } - const shader_module = b.createModule(.{ .root_source_file = files.add("shaders.zig", "const v align(4) = @embedFile(\"vert.spv\").*;\npub const vert: []const u8 = &v;\nconst f align(4) = @embedFile(\"frag.spv\").*;\npub const frag: []const u8 = &f;\nconst p align(4) = @embedFile(\"post.frag.spv\").*;\npub const post: []const u8 = &p;\n") }); - const module = b.createModule(.{ .root_source_file = b.path("addons/snake_shader/snake_shader.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "addon", .module = addon_mod }, .{ .name = "gpu_scene", .module = sb.module("gpu_scene") }, .{ .name = "shaders", .module = shader_module } } }); - const lib = b.addLibrary(.{ .name = "snake_shader", .linkage = .dynamic, .root_module = module }); - snake_shader_lib = lib; - snake_shader_step.dependOn(&b.addInstallArtifact(lib, .{}).step); - snake_shader_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = module })).step); - // The frame corpus's translucent addon (test/veil.zig), into lib/ beside the snake. - const veil = b.addLibrary(.{ .name = "veil", .linkage = .dynamic, .root_module = b.createModule(.{ .root_source_file = b.path("test/veil.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "addon", .module = addon_mod }, .{ .name = "gpu_scene", .module = sb.module("gpu_scene") } } }) }); - veil_step.dependOn(&b.addInstallArtifact(veil, .{}).step); - } else |_| {} - return snake_shader_lib; + return null; + }; + const files = b.addWriteFiles(); + for ([_][]const u8{ "vert", "frag", "post.frag" }) |stage| { + const compile = b.addSystemCommand(&.{ "glslc", "-O" }); + compile.addFileArg(b.path(b.fmt("addons/snake_shader/snake.{s}", .{stage}))); + compile.addArg("-o"); + _ = files.addCopyFile(compile.addOutputFileArg(b.fmt("snake.{s}.spv", .{stage})), b.fmt("{s}.spv", .{stage})); + } + const shader_module = b.createModule(.{ .root_source_file = files.add("shaders.zig", "const v align(4) = @embedFile(\"vert.spv\").*;\npub const vert: []const u8 = &v;\nconst f align(4) = @embedFile(\"frag.spv\").*;\npub const frag: []const u8 = &f;\nconst p align(4) = @embedFile(\"post.frag.spv\").*;\npub const post: []const u8 = &p;\n") }); + const module = b.createModule(.{ .root_source_file = b.path("addons/snake_shader/snake_shader.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "addon", .module = addon_mod }, .{ .name = "gpu_scene", .module = sb.module("gpu_scene") }, .{ .name = "shaders", .module = shader_module } } }); + const lib = b.addLibrary(.{ .name = "snake_shader", .linkage = .dynamic, .root_module = module }); + snake_shader_step.dependOn(&b.addInstallArtifact(lib, .{}).step); + snake_shader_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = module })).step); + // The frame corpus's translucent addon (test/veil.zig), into lib/ beside the snake. + const veil = b.addLibrary(.{ .name = "veil", .linkage = .dynamic, .root_module = b.createModule(.{ .root_source_file = b.path("test/veil.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "addon", .module = addon_mod }, .{ .name = "gpu_scene", .module = sb.module("gpu_scene") } } }) }); + veil_step.dependOn(&b.addInstallArtifact(veil, .{}).step); + return lib; } pub const Pdf = struct { |
