// 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 . 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); }