-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
70 lines (56 loc) · 2.62 KB
/
build.zig
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
const std = @import("std");
const Arch = std.Target.Cpu.Arch;
const glfw = @import("libs/mach-glfw/build.zig");
const vkgen = @import("libs/vulkan-zig/generator/index.zig");
const zigvulkan = @import("libs/vulkan-zig/build.zig");
pub fn build(b: *std.build.Builder) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
var target = b.standardTargetOptions(.{});
// I cannot get things to work on macbook M1 without doing this. Also,
// initializing threadlocal doesn't really work on MacOS it seems.
target.cpu_arch = Arch.x86_64;
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("idk", "src/main.zig");
exe.setTarget(target);
exe.setBuildMode(mode);
exe.install();
// TODO not currently used right now
// vulkan-zig: Create a step that generates vk.zig (stored in zig-cache) from the provided vulkan registry.
// const gen = vkgen.VkGenerateStep.init(b, "libs/vulkan-zig/examples/vk.xml", "vk.zig");
// exe.addPackage(gen.package);
// mach-glfw
exe.addPackagePath("glfw", "libs/mach-glfw/src/main.zig");
glfw.link(b, exe, .{});
exe.addPackagePath("liu", "liu/lib.zig");
// shader resources, to be compiled using glslc
const res = zigvulkan.ResourceGenStep.init(b, "shaders.zig");
res.addShader("triangle_vert", "shaders/shader.vert");
res.addShader("triangle_frag", "shaders/shader.frag");
exe.addPackage(res.package);
exe.linkLibCpp();
exe.linkSystemLibrary("vulkan");
exe.addIncludeDir("libs/imgui/include");
const files = .{
"libs/imgui/cimgui.cpp", "libs/imgui/imgui.cpp",
"libs/imgui/imgui_draw.cpp", "libs/imgui/imgui_widgets.cpp",
"libs/imgui/imgui_tables.cpp", "libs/imgui/imgui_demo.cpp",
"libs/imgui/imgui_impl_render.cpp", "libs/imgui/imgui_impl_platform.cpp",
};
const flags = .{
"-fno-exceptions", "-fno-rtti", "-Wno-return-type-c-linkage",
"-nostdlib", "-nostdlib++",
};
exe.addCSourceFiles(&files, &flags);
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}