-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
154 lines (127 loc) · 5.42 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 std = @import("std");
//const raylib_dep = @import("raylib");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "dev",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
const exe_check = b.addExecutable(.{
.name = "dev",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
const exe_test = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
//================ADD PROFILER=====================
const profiler = b.dependency("profiler", .{
.target = target,
.optimize = optimize,
.enable_profiling = b.option(bool, "enable_profiling", "enable the profiler") orelse false,
});
exe.root_module.addImport("profiler", profiler.module("profiler"));
exe_check.root_module.addImport("profiler", profiler.module("profiler"));
exe_test.root_module.addImport("profiler", profiler.module("profiler"));
//================ADD DVUI======================
const dvui = b.dependency("dvui", .{
.target = target,
.optimize = optimize,
.link_backend = true,
});
exe.root_module.addImport("dvui", dvui.module("dvui_raylib"));
exe_check.root_module.addImport("dvui", dvui.module("dvui_raylib"));
exe_test.root_module.addImport("dvui", dvui.module("dvui_raylib"));
//================ADD ZIGLUA====================
const ziglua = b.dependency("ziglua", .{ .target = target, .optimize = optimize });
exe.root_module.addImport("ziglua", ziglua.module("ziglua"));
exe_check.root_module.addImport("ziglua", ziglua.module("ziglua"));
exe_test.root_module.addImport("ziglua", ziglua.module("ziglua"));
//===============DEFINE LUA TYPES=====================
const exe_define = b.addExecutable(.{
.name = "define",
.root_source_file = b.path("src/define_exe.zig"),
.target = target,
});
exe_define.root_module.addImport("ziglua", ziglua.module("ziglua"));
var run_exe_define = b.addRunArtifact(exe_define);
run_exe_define.addFileArg(b.path("data/lua/definitions.lua"));
const define_step = b.step("define", "");
define_step.dependOn(&run_exe_define.step);
//===============LINT LUA===========================
const lua_files_path = "data/lua";
const lint_commands: []const []const u8 = &.{
"lua-language-server",
"--check",
b.path(lua_files_path).getPath(b),
"--logpath",
"--checklevel=Hint",
"--logpath",
b.path(".zig-cache").getPath(b),
};
var lint = b.addSystemCommand(lint_commands);
const log_commands: []const []const u8 = &.{
"cat",
b.path(".zig-cache/check.json").getPath(b),
};
var log = b.addSystemCommand(log_commands);
log.step.dependOn(&lint.step);
var lint_step = b.step("lint", "lint lua");
lint_step.dependOn(&log.step);
//================LINK RAYLIB===================
//const ray = b.dependency("raylib", .{
// .target = target,
// .optimize = optimize,
// .config = @as([]const u8, "-DSUPPORT_CUSTOM_FRAME_CONTROL"),
//});
//exe.linkLibrary(ray.artifact("raylib"));
//exe_check.linkLibrary(ray.artifact("raylib"));
//exe_test.linkLibrary(ray.artifact("raylib"));
//exe_define.linkLibrary(ray.artifact("raylib"));
//const glad_path = ray.path("src/external");
//exe.addIncludePath(glad_path);
//exe_test.addIncludePath(glad_path);
//exe_check.addIncludePath(glad_path);
//exe_define.addIncludePath(glad_path);
//const ray_path = ray.path("src");
//exe.addIncludePath(ray_path);
//exe_test.addIncludePath(ray_path);
//exe_check.addIncludePath(ray_path);
//exe_define.addIncludePath(ray_path);
//dvui.module("backend_raylib").linkLibrary(ray.artifact("raylib"));
//if (dvui.builder.lazyDependency("raygui", .{})) |raygui_dep| {
// @import("raylib").addRaygui(b, ray.artifact("raylib"), raygui_dep);
//}
//const maybe_raygui = dvui.builder.lazyDependency("raygui", .{ .target = target, .optimize = optimize });
//if (maybe_raygui) |raygui| {
// const raygui_path = raygui.path("src");
// exe.addIncludePath(raygui_path);
// exe_test.addIncludePath(raygui_path);
// exe_check.addIncludePath(raygui_path);
// exe_define.addIncludePath(raygui_path);
//}
//=============INSTALL TO OUTPUT DIR===========
b.installArtifact(exe);
b.installDirectory(.{ .source_dir = b.path("data"), .install_dir = .bin, .install_subdir = "data" });
//=============TRIGGER EXECUTION================
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
const run_exe_test = b.addRunArtifact(exe_test);
run_exe_test.step.dependOn((b.getInstallStep()));
//================TYPES OF BUILD STEPS=============
const run_step = b.step("run", "Run the game");
run_step.dependOn(&run_cmd.step);
const check_step = b.step("check", "Check if the game compiles");
check_step.dependOn(&exe_check.step);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_exe_test.step);
}