Initial commit
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "zig-chess",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
}),
|
||||
});
|
||||
|
||||
const vulkan_headers = b.dependency("vulkan_headers", .{});
|
||||
|
||||
const vulkan = b.dependency("vulkan", .{
|
||||
.registry = vulkan_headers.path("registry/vk.xml"),
|
||||
}).module("vulkan-zig");
|
||||
|
||||
exe.root_module.addImport("vulkan", vulkan);
|
||||
|
||||
const zglfw = b.dependency("zglfw", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.import_vulkan = true,
|
||||
});
|
||||
|
||||
const zglfw_mod = zglfw.module("root");
|
||||
zglfw_mod.addImport("vulkan", vulkan);
|
||||
|
||||
exe.root_module.addImport("zglfw", zglfw_mod);
|
||||
|
||||
if (target.result.os.tag != .emscripten) {
|
||||
exe.root_module.linkLibrary(zglfw.artifact("glfw"));
|
||||
}
|
||||
|
||||
const vert_cmd = b.addSystemCommand(&.{
|
||||
"glslc",
|
||||
"--target-env=vulkan1.2",
|
||||
"-o",
|
||||
});
|
||||
const vert_spv = vert_cmd.addOutputFileArg("square.vert.spv");
|
||||
vert_cmd.addFileArg(b.path("shaders/square.vert"));
|
||||
|
||||
const frag_cmd = b.addSystemCommand(&.{
|
||||
"glslc",
|
||||
"--target-env=vulkan1.2",
|
||||
"-o",
|
||||
});
|
||||
const frag_spv = frag_cmd.addOutputFileArg("square.frag.spv");
|
||||
frag_cmd.addFileArg(b.path("shaders/square.frag"));
|
||||
|
||||
exe.root_module.addAnonymousImport("square_vertex_shader", .{
|
||||
.root_source_file = vert_spv,
|
||||
});
|
||||
|
||||
exe.root_module.addAnonymousImport("square_fragment_shader", .{
|
||||
.root_source_file = frag_spv,
|
||||
});
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
|
||||
const run_step = b.step("run", "Run zig-chess");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
}
|
||||
Reference in New Issue
Block a user