// Build recipe // Copyright (C) 2021-2022 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 . 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/Decals.cpp", "src/GameDraw.cpp", "src/GameInitDispose.cpp", "src/GameLoop.cpp", "src/GameTick.cpp", "src/Globals.cpp", "src/Models.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); }