adding option to disable example building
This commit is contained in:
@@ -23,7 +23,7 @@ jobs:
|
||||
node-version: 24
|
||||
|
||||
- name: Building
|
||||
run: zig build
|
||||
run: zig build -Dno-example=true
|
||||
|
||||
- name: Generating docs
|
||||
run: zig build docs
|
||||
|
||||
@@ -20,4 +20,8 @@ jobs:
|
||||
- uses: mlugg/setup-zig@v2
|
||||
|
||||
- name: Test
|
||||
run: zig build test
|
||||
run: |
|
||||
zig build test -Dno-example=true
|
||||
zig build test -Dno-example=true --release=fast
|
||||
zig build test -Dno-example=true --release=safe
|
||||
zig build test -Dno-example=true --release=small
|
||||
|
||||
24
build.zig
24
build.zig
@@ -13,6 +13,11 @@ pub fn build(b: *std.Build) void {
|
||||
const pretty = b.dependency("pretty", .{ .target = target, .optimize = optimize });
|
||||
mod.addImport("pretty", pretty.module("pretty"));
|
||||
|
||||
var it = b.user_input_options.iterator();
|
||||
while (it.next()) |entry| {
|
||||
std.debug.print("{s} - {s} {any}", .{ entry.key_ptr.*, entry.value_ptr.name, entry.value_ptr.used });
|
||||
}
|
||||
|
||||
const lib = b.addLibrary(.{
|
||||
.name = "spirv_interpreter",
|
||||
.root_module = mod,
|
||||
@@ -23,11 +28,10 @@ pub fn build(b: *std.Build) void {
|
||||
|
||||
// Zig example setup
|
||||
|
||||
const sdl3 = b.lazyDependency("sdl3", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
}) orelse return;
|
||||
const no_example = b.option(bool, "no-example", "skips example dependencies fetch") orelse false;
|
||||
|
||||
if (!no_example) {
|
||||
const sdl3 = b.lazyDependency("sdl3", .{ .target = target, .optimize = optimize }) orelse return;
|
||||
const example_exe = b.addExecutable(.{
|
||||
.name = "spirv_interpreter_example",
|
||||
.root_module = b.createModule(.{
|
||||
@@ -52,13 +56,15 @@ pub fn build(b: *std.Build) void {
|
||||
run_example_step.dependOn(&run_example.step);
|
||||
|
||||
const compile_shader_cmd = b.addSystemCommand(&[_][]const u8{ "nzslc", "example/shader.nzsl", "--compile=spv,spv-dis", "-o", "example" });
|
||||
const compile_shader_step = b.step("example-shader", "Compiles example's shader");
|
||||
const compile_shader_step = b.step("example-shader", "Compiles example's shader (needs nzslc installed)");
|
||||
compile_shader_step.dependOn(&compile_shader_cmd.step);
|
||||
}
|
||||
|
||||
// Zig unit tests setup
|
||||
|
||||
const nzsl = b.lazyDependency("NZSL", .{}) orelse return;
|
||||
const test_mod = b.createModule(.{
|
||||
const nzsl = b.lazyDependency("NZSL", .{ .target = target, .optimize = optimize }) orelse return;
|
||||
const lib_tests = b.addTest(.{
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("test/root.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
@@ -66,9 +72,7 @@ pub fn build(b: *std.Build) void {
|
||||
.{ .name = "spv", .module = mod },
|
||||
.{ .name = "nzsl", .module = nzsl.module("nzigsl") },
|
||||
},
|
||||
});
|
||||
const lib_tests = b.addTest(.{
|
||||
.root_module = test_mod,
|
||||
}),
|
||||
.test_runner = .{ .path = b.path("test/test_runner.zig"), .mode = .simple },
|
||||
});
|
||||
const run_tests = b.addRunArtifact(lib_tests);
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
.lazy = true,
|
||||
},
|
||||
.sdl3 = .{
|
||||
.url = "git+https://codeberg.org/7Games/zig-sdl3?ref=master#eefd1b86205ed4fbc5f5274b5ba34aa97798d693",
|
||||
.hash = "sdl3-0.1.6-NmT1Q8kQJgCrbdH9Z3ZmLo5uJ1et3oxhfYazrNTtfsgv",
|
||||
.url = "git+https://codeberg.org/7Games/zig-sdl3?ref=v0.1.6#9c1842246c59f03f87ba59b160ca7e3d5e5ce972",
|
||||
.hash = "sdl3-0.1.6-NmT1Q5sQJgCzT6hLj7WOSrwxE0Qsef1wIkDopbOOFru0",
|
||||
.lazy = true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -19,7 +19,7 @@ pub fn init(buffer: []const SpvWord) Self {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn nextOrNull(self: *Self) ?SpvWord {
|
||||
pub inline fn nextOrNull(self: *Self) ?SpvWord {
|
||||
const word = self.peek() orelse return null;
|
||||
self.index += 1;
|
||||
return word;
|
||||
@@ -33,15 +33,15 @@ pub inline fn next(self: *Self) RuntimeError!SpvWord {
|
||||
return self.nextOrNull() orelse return RuntimeError.InvalidSpirV;
|
||||
}
|
||||
|
||||
pub fn nextAs(self: *Self, comptime E: type) RuntimeError!E {
|
||||
pub inline fn nextAs(self: *Self, comptime E: type) RuntimeError!E {
|
||||
return self.nextAsOrNull(E) orelse return RuntimeError.InvalidSpirV;
|
||||
}
|
||||
|
||||
pub fn peek(self: *const Self) ?SpvWord {
|
||||
pub inline fn peek(self: *const Self) ?SpvWord {
|
||||
return if (self.index >= self.buffer.len) null else self.buffer[self.index];
|
||||
}
|
||||
|
||||
pub fn skip(self: *Self) bool {
|
||||
pub inline fn skip(self: *Self) bool {
|
||||
if (self.index >= self.buffer.len) {
|
||||
return false;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ pub fn skip(self: *Self) bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn skipN(self: *Self, count: usize) bool {
|
||||
pub inline fn skipN(self: *Self, count: usize) bool {
|
||||
if (self.index >= self.buffer.len) {
|
||||
return false;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ pub fn skipN(self: *Self, count: usize) bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn skipToEnd(self: *Self) void {
|
||||
pub inline fn skipToEnd(self: *Self) void {
|
||||
self.index = self.buffer.len;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user