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
|
// Build recipe
// Copyright (C) 2021-2023 Nguyễn Gia Phong
//
// This file is part of Black Shades.
//
// Black Shades is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Black Shades is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Black Shades. If not, see <https://www.gnu.org/licenses/>.
const Build = @import("std").Build;
const Compile = Build.Step.Compile;
const InstallDirectoryOptions = Build.InstallDirectoryOptions;
const data = InstallDirectoryOptions{
.source_dir = .{ .path = "data" },
.install_dir = .{ .custom = "share" },
.install_subdir = "blackshades",
};
pub fn build(b: *Build) void {
const bin = b.addExecutable(.{
.name = "blackshades",
.root_source_file = .{ .path = "src/main.zig" },
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
});
bin.addIncludePath(.{ .path = "src" });
bin.addCSourceFiles(&.{
"src/GameDraw.cpp",
"src/GameInitDispose.cpp",
"src/GameLoop.cpp",
"src/GameTick.cpp",
"src/Globals.cpp",
"src/Person.cpp",
"src/Skeleton.cpp",
"src/Sprites.cpp",
}, &.{ "--std=c++17", "-Wall", "-Werror", "-fno-sanitize=undefined" });
for ([_]struct { []const u8, []const u8 }{
.{ "gfz", "lib/gfz/src/gfz.zig" },
.{ "ini", "lib/ini/src/ini.zig" },
.{ "loca", "lib/loca/src/main.zig" },
.{ "qoi", "lib/qoi/src/qoi.zig" },
.{ "zeal", "lib/zeal/src/zeal.zig" },
}) |lib|
bin.addModule(lib[0], b.createModule(.{
.source_file = .{ .path = lib[1] },
}));
@import("lib/gfz/build.zig").link(bin);
@import("lib/zeal/build.zig").link(bin);
bin.linkSystemLibrary("GL");
bin.linkSystemLibrary("GLU");
bin.linkSystemLibrary("c++");
b.installDirectory(data);
const options = b.addOptions();
const data_dir = b.getInstallPath(data.install_dir, data.install_subdir);
options.addOption([]const u8, "data_dir", data_dir);
bin.addOptions("build_options", options);
b.installArtifact(bin);
const run_cmd = b.addRunArtifact(bin);
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);
}
|