This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.zig
154 lines (126 loc) · 4.61 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
const Builder = @import("std").build.Builder;
const Build = @import("std").build;
const lib = @import("libbuild.zig");
pub fn build(b: *Builder) void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const engine_path = "./";
lib.strip = b.option(bool, "strip", "Strip the exe?") orelse false;
const examples = b.option(bool, "examples", "Compile the examples?") orelse false;
const main = b.option(bool, "main", "Compile the main source?") orelse false;
if (examples) {
{
const exe = lib.setup(b, target, "basic_setup", "examples/basic_setup.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
{
const exe = lib.setup(b, target, "input", "examples/input.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
{
const exe = lib.setup(b, target, "shape_drawing", "examples/shape_drawing.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
{
const exe = lib.setup(b, target, "texture_drawing", "examples/texture_drawing.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
{
const exe = lib.setup(b, target, "text_rendering", "examples/text_rendering.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
{
const exe = lib.setup(b, target, "ecs", "examples/ecs.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
{
const exe = lib.setup(b, target, "ecs_benchmark", "examples/ecs_benchmark.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
{
const exe = lib.setup(b, target, "camera2d", "examples/camera2d.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
{
const exe = lib.setup(b, target, "camera2d_advanced", "examples/camera2d_advanced.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
{
const exe = lib.setup(b, target, "gui", "examples/gui.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
{
const exe = lib.setup(b, target, "custombatch", "examples/custombatch.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
{
const exe = lib.setup(b, target, "customshaders", "examples/customshaders.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
{
const exe = lib.setup(b, target, "shooter", "examples/shooter.zig", engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
}
}
if (main) {
const exe = b.addExecutable("main", "src/main.zig");
exe.strip = lib.strip;
exe.linkSystemLibrary("c");
exe.addIncludeDir(engine_path ++ "include/onefile/");
lib.include(exe, engine_path);
lib.compileOneFile(exe, engine_path);
const target_os = target.getOsTag();
switch (target_os) {
.windows => {
exe.setTarget(target);
exe.linkSystemLibrary("gdi32");
exe.linkSystemLibrary("opengl32");
exe.subsystem = .Console;
lib.compileGLFWWin32(exe, engine_path);
},
.linux => {
exe.setTarget(target);
exe.linkSystemLibrary("X11");
lib.compileGLFWLinux(exe, engine_path);
},
else => {},
}
lib.compileGLFWShared(exe, engine_path);
exe.setOutputDir("build");
exe.setBuildMode(mode);
exe.install();
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);
}
}