about summary refs log tree commit diff
path: root/build.zig
blob: 97957bd5bca9cda6497ad39c5a9b5fc24facce5a (plain) (blame)
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
// Build recipe
// Copyright (C) 2021-2023, 2025  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;

pub fn build(b: *Build) void {
    const mod = b.createModule(.{
        .root_source_file = b.path("src/main.zig"),
        .target = b.standardTargetOptions(.{}),
        .optimize = b.standardOptimizeOption(.{}),
    });
    mod.addIncludePath(b.path("src"));
    mod.addCSourceFiles(.{
        .files = &.{
            "src/GameDraw.cpp",
            "src/GameInitDispose.cpp",
            "src/GameLoop.cpp",
            "src/GameTick.cpp",
            "src/Globals.cpp",
            "src/Person.cpp",
            "src/Skeleton.cpp",
            "src/Sprites.cpp",
        },
        .flags = &.{ "--std=c++17", "-Wall", "-Werror" },
    });
    mod.linkSystemLibrary("GL", .{});
    mod.linkSystemLibrary("GLU", .{});
    mod.linkSystemLibrary("c++", .{});

    inline for (.{ "gfz", "ini", "known-folders", "qoi", "zeal" }) |lib|
        mod.addImport(lib, b.dependency(lib, .{}).module(lib));
    const data = Build.Step.InstallDir.Options{
        .source_dir = b.path("data"),
        .install_dir = .{ .custom = "share" },
        .install_subdir = "blackshades",
    };
    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);
    mod.addOptions("build_options", options);

    const bin = b.addExecutable(.{ .name = "blackshades", .root_module = mod });
    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 game");
    run_step.dependOn(&run_cmd.step);
}