diff options
Diffstat (limited to 'build.zig')
-rw-r--r-- | build.zig | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/build.zig b/build.zig index 7294e1a..d43a430 100644 --- a/build.zig +++ b/build.zig @@ -1,6 +1,32 @@ +// Build recipe +// Copyright (C) 2021 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 std = @import("std"); +const InstallDirectoryOptions = std.build.InstallDirectoryOptions; +const Builder = std.build.Builder; + +const data = InstallDirectoryOptions{ + .source_dir = "Data", + .install_dir = .{ .Custom = "share" }, // break in future Zig + .install_subdir = "blackshades", +}; -pub fn build(b: *std.build.Builder) void { +pub fn build(b: *Builder) void { const exe = b.addExecutable("blackshades", "src/main.zig"); exe.addIncludeDir("src"); @@ -22,8 +48,9 @@ pub fn build(b: *std.build.Builder) void { exe.addCSourceFile("src/Sprites.cpp", &cxxflags); exe.addCSourceFile("src/Support.cpp", &cxxflags); exe.addCSourceFile("src/Text.cpp", &cxxflags); - exe.addCSourceFile("src/Textures.cpp", &cxxflags); + exe.addCSourceFile("lib/lodepng/lodepng.c", &.{ "-ansi", "-pedantic" }); + exe.addIncludeDir("lib/lodepng"); exe.addPackage(.{ .name = "gfz", .path = "lib/gfz/src/gfz.zig" }); exe.linkSystemLibrary("glfw"); exe.addPackage(.{ .name = "ini", .path = "lib/ini/src/ini.zig" }); @@ -46,6 +73,9 @@ pub fn build(b: *std.build.Builder) void { // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. exe.setBuildMode(b.standardReleaseOptions()); + const data_dir = b.getInstallPath(data.install_dir, data.install_subdir); + exe.addBuildOption([]const u8, "data_dir", data_dir); + b.installDirectory(data); exe.install(); const run_cmd = exe.run(); |