diff --git a/build.zig b/build.zig index b8ad6db..7823249 100644 --- a/build.zig +++ b/build.zig @@ -21,7 +21,7 @@ pub const ResourceGenStep = struct { self.* = .{ .step = Step.init(.custom, "resources", builder.allocator, make), - .shader_step = vkgen.ShaderCompileStep.init(builder, &[_][]const u8{ "glslc", "--target-env=vulkan1.2" }), + .shader_step = vkgen.ShaderCompileStep.init(builder, &[_][]const u8{ "glslc", "--target-env=vulkan1.2" }, "shaders"), .builder = builder, .package = .{ .name = "resources", diff --git a/generator/build_integration.zig b/generator/build_integration.zig index 8423709..1220a95 100644 --- a/generator/build_integration.zig +++ b/generator/build_integration.zig @@ -22,16 +22,20 @@ pub const ShaderCompileStep = struct { /// The command and optional arguments used to invoke the shader compiler. glslc_cmd: []const []const u8, + /// The directory within `zig-cache/` that the compiled shaders are placed in. + output_dir: []const u8, + /// List of shaders that are to be compiled. shaders: std.ArrayList(Shader), /// Create a ShaderCompilerStep for `builder`. When this step is invoked by the build /// system, ` -o ` is invoked for each shader. - pub fn init(builder: *Builder, glslc_cmd: []const []const u8) *ShaderCompileStep { + pub fn init(builder: *Builder, glslc_cmd: []const []const u8, output_dir: []const u8) *ShaderCompileStep { const self = builder.allocator.create(ShaderCompileStep) catch unreachable; self.* = .{ .step = Step.init(.custom, "shader-compile", builder.allocator, make), .builder = builder, + .output_dir = output_dir, .glslc_cmd = builder.dupeStrings(glslc_cmd), .shaders = std.ArrayList(Shader).init(builder.allocator), }; @@ -46,7 +50,7 @@ pub const ShaderCompileStep = struct { const full_out_path = path.join(self.builder.allocator, &[_][]const u8{ self.builder.build_root, self.builder.cache_root, - "shaders", + self.output_dir, src, }) catch unreachable; self.shaders.append(.{ .source_path = src, .full_out_path = full_out_path }) catch unreachable;