-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
57 lines (48 loc) · 1.71 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Compile shaders
const compileShaders = b.addSystemCommand(&.{"bash","compile.sh"});
compileShaders.setCwd(b.path("shaders"));
compileShaders.step.name = "compile shaders";
// Create the game executable.
const exe = b.addExecutable(.{
.name = "CGProject",
.target = target,
.optimize = optimize,
});
// Add extra source files
const sources = .{
"src/Project.cpp",
"src/gameObjects/Object.cpp",
"src/gameObjects/Truck.cpp",
"src/utils/definitions.cpp",
"src/utils/MatrixUtils.cpp",
"src/physics/PhysicsEngine.cpp",
"src/worldgen/Terrain.cpp",
"src/worldgen/Tree.cpp",
};
exe.addCSourceFiles(.{
.files = &sources,
.flags = &.{ "-std=c++20", "-O3" },
});
// Add include directories
exe.addIncludePath(.{ .cwd_relative = "headers" });
exe.addIncludePath(.{ .cwd_relative = "shaders" });
// Add pkg-config packages for Wayland and EGL.
exe.linkLibCpp();
exe.linkSystemLibrary("wayland-egl");
exe.linkSystemLibrary("glfw");
exe.linkSystemLibrary("vulkan");
exe.linkSystemLibrary("dl");
exe.linkSystemLibrary("pthread");
exe.linkSystemLibrary("Xrandr");
exe.linkSystemLibrary("Xi");
exe.step.dependOn(&compileShaders.step);
b.installArtifact(exe);
// Add a run step to run the executable. Can be called with `zig build run`
const run_exe = b.addRunArtifact(exe);
const run_step = b.step("run", "Run the application");
run_step.dependOn(&run_exe.step);
}