// 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 std = @import("std"); const InstallDirectoryOptions = std.build.InstallDirectoryOptions; const Builder = std.build.Builder; const data = InstallDirectoryOptions{ .source_dir = "data", .install_dir = .{ .custom = "share" }, .install_subdir = "blackshades", }; pub fn build(b: *Builder) void { 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); const exe = b.addExecutable("blackshades", "src/main.zig"); exe.addIncludeDir("src"); const cxxflags = [_][]const u8{ "--std=c++17" }; exe.addCSourceFile("src/Decals.cpp", &cxxflags); exe.addCSourceFile("src/Fog.cpp", &cxxflags); exe.addCSourceFile("src/Frustum.cpp", &cxxflags); exe.addCSourceFile("src/GameDraw.cpp", &cxxflags); exe.addCSourceFile("src/GameInitDispose.cpp", &cxxflags); exe.addCSourceFile("src/GameLoop.cpp", &cxxflags); exe.addCSourceFile("src/GameTick.cpp", &cxxflags); exe.addCSourceFile("src/Globals.cpp", &cxxflags); exe.addCSourceFile("src/Models.cpp", &cxxflags); exe.addCSourceFile("src/Person.cpp", &cxxflags); exe.addCSourceFile("src/Quaternions.cpp", &cxxflags); exe.addCSourceFile("src/Skeleton.cpp", &cxxflags); exe.addCSourceFile("src/Sprites.cpp", &cxxflags); exe.addCSourceFile("src/Text.cpp", &cxxflags); exe.addCSourceFile("lib/lodepng/lodepng.c", &.{ "-ansi", "-pedantic" }); exe.addIncludeDir("lib/lodepng"); exe.addPackagePath("gfz", "lib/gfz/src/gfz.zig"); @import("lib/gfz/build.zig").link(exe); exe.addPackagePath("ini", "lib/ini/src/ini.zig"); exe.addPackagePath("loca", "lib/loca/src/main.zig"); exe.addPackagePath("zeal", "lib/zeal/src/zeal.zig"); @import("lib/zeal/build.zig").link(exe); exe.linkSystemLibrary("GL"); exe.linkSystemLibrary("GLU"); exe.linkSystemLibrary("c++"); // Standard target options allows the person running `zig build` to choose // what target to build for. Here we do not override the defaults, which // means any target is allowed, and the default is native. Other options // for restricting supported target set are available. exe.setTarget(b.standardTargetOptions(.{})); // Standard release options allow the person running `zig build` to select // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. exe.setBuildMode(b.standardReleaseOptions()); exe.addOptions("build_options", options); exe.install(); const run_cmd = exe.run(); 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); }