Project template
This commit is contained in:
72
build.zig
Normal file
72
build.zig
Normal file
@@ -0,0 +1,72 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const zaudio = b.dependency("zaudio", .{});
|
||||
const zglfw = b.dependency("zglfw", .{});
|
||||
const zgpu = b.dependency("zgpu", .{});
|
||||
const zgui = b.dependency("zgui", .{
|
||||
.shared = false,
|
||||
.backend = .glfw_wgpu,
|
||||
.with_implot = true,
|
||||
});
|
||||
const zmath = b.dependency("zmath", .{});
|
||||
const znoise = b.dependency("znoise", .{});
|
||||
const zpool = b.dependency("zpool", .{});
|
||||
const zstbi = b.dependency("zstbi", .{});
|
||||
const ztracy = b.dependency("ztracy", .{
|
||||
.enable_ztracy = b.option(bool, "enable_ztracy", "Enable Tracy profile markers") orelse false,
|
||||
.enable_fibers = b.option(bool, "enable_fibers", "Enable Tracy fiber support") orelse false,
|
||||
.on_demand = b.option(bool, "on_demand", "Build Tracy with TRACY_ON_DEMAND") orelse false,
|
||||
});
|
||||
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const exe_mod = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
exe_mod.addImport("zaudio", zaudio.module("root"));
|
||||
exe_mod.addImport("zglfw", zglfw.module("root"));
|
||||
exe_mod.addImport("zgpu", zgpu.module("root"));
|
||||
exe_mod.addImport("zgui", zgui.module("root"));
|
||||
exe_mod.addImport("zmath", zmath.module("root"));
|
||||
exe_mod.addImport("znoise", znoise.module("root"));
|
||||
exe_mod.addImport("zpool", zpool.module("root"));
|
||||
exe_mod.addImport("zstbi", zstbi.module("root"));
|
||||
exe_mod.addImport("ztracy", ztracy.module("root"));
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "voxel-game",
|
||||
.root_module = exe_mod,
|
||||
});
|
||||
|
||||
exe.linkLibrary(zaudio.artifact("miniaudio"));
|
||||
exe.linkLibrary(zgui.artifact("imgui"));
|
||||
exe.linkLibrary(znoise.artifact("FastNoiseLite"));
|
||||
exe.linkLibrary(zstbi.artifact("zstbi"));
|
||||
exe.linkLibrary(ztracy.artifact("tracy"));
|
||||
if (target.result.os.tag != .emscripten) {
|
||||
exe.linkLibrary(zglfw.artifact("glfw"));
|
||||
exe.linkLibrary(zgpu.artifact("zdawn"));
|
||||
}
|
||||
|
||||
if (optimize != .Debug) {
|
||||
exe.subsystem = .Windows;
|
||||
}
|
||||
|
||||
@import("zgpu").addLibraryPathsTo(exe);
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
}
|
||||
|
||||
const run_step = b.step("run", "Run the game");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
}
|
||||
Reference in New Issue
Block a user