-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
83 lines (73 loc) · 2.83 KB
/
build.zig
File metadata and controls
83 lines (73 loc) · 2.83 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const std = @import("std");
const sokol = @import("sokol");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimization = b.standardOptimizeOption(.{});
const sokol_dep = b.dependency("sokol", .{
.target = target,
.optimize = optimization,
});
const sokol_module = sokol_dep.module("sokol");
const zigimg_dep = b.dependency("zigimg", .{
.target = target,
.optimize = optimization,
});
const zigimg_module = zigimg_dep.module("zigimg");
const zgltf = b.dependency("zgltf", .{});
const zgltf_module = zgltf.module("zgltf");
const clap = b.dependency("clap", .{});
const clap_module = clap.module("clap");
const exe = b.addExecutable(.{
.name = "ZigCPURasterizer",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.imports = &.{
.{ .name = "sokol", .module = sokol_module },
.{ .name = "zigimg", .module = zigimg_module },
.{ .name = "shader", .module = try createShaderModule(b, sokol_dep, sokol_module) },
.{ .name = "zgltf", .module = zgltf_module },
.{ .name = "clap", .module = clap_module },
},
.target = target,
.optimize = optimization,
}),
});
b.installArtifact(exe);
const run = b.addRunArtifact(exe);
if (b.args) |args| {
run.addArgs(args);
}
b.step("run", "Run pacman").dependOn(&run.step);
const tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/tests.zig"),
.imports = &.{
// .{ .name = "sokol", .module = sokol_module },
.{ .name = "zigimg", .module = zigimg_module },
// .{ .name = "shader", .module = try createShaderModule(b, sokol_dep, sokol_module) },
.{ .name = "zgltf", .module = zgltf_module },
// .{ .name = "clap", .module = clap_module },
},
.target = target,
.optimize = optimization,
}),
});
const run_unit_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_unit_tests.step);
}
fn createShaderModule(b: *std.Build, dep_sokol: *std.Build.Dependency, mod_sokol: *std.Build.Module) !*std.Build.Module {
const dep_shdc = dep_sokol.builder.dependency("shdc", .{});
return sokol.shdc.createModule(b, "shader", mod_sokol, .{
.shdc_dep = dep_shdc,
.input = "src/shaders/shader.glsl",
.output = "src/shaders/shader.glsl.zig",
.slang = .{
.glsl410 = false,
.glsl300es = false,
.hlsl4 = false,
.metal_macos = true,
.wgsl = false,
},
});
}