tins2023/allegro/build.zig
Sander Schobers 93d9fe6c12 Updated to Zig 0.12.0.
Moved allegro as a local package.
2024-05-01 09:15:30 +02:00

96 lines
3.8 KiB
Zig

const std = @import("std");
fn current_file() []const u8 {
return @src().file;
}
const cwd = std.fs.path.dirname(current_file()).?;
const path_separator = std.fs.path.sep_str;
/// add this package to exe
pub fn addModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) void {
// _ = b.addStaticLibrary(.{
// .name = "allegro",
// .root_source_file = .{ .path = cwd ++ path_separator ++ "allegro.zig" },
// .target = target,
// .optimize = optimize,
// });
_ = b.addModule("allegro", .{
.root_source_file = .{ .path = cwd ++ path_separator ++ "allegro.zig" },
.target = target,
.optimize = optimize,
});
}
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const static = false;
// Expose this as a module that others can import
var module = b.addModule("allegro", .{
.root_source_file = .{ .path = "src/allegro.zig" },
.target = target,
.optimize = optimize,
});
const allegro_dir = b.option([]const u8, "allegro-dir", "path to a directory that contains the Allegro `lib`, `bin` and `include` folders") orelse "";
if (allegro_dir.len != 0) {
module.addIncludePath(.{ .path = b.pathJoin(&[_][]const u8{ allegro_dir, "include" }) });
module.addLibraryPath(.{ .path = b.pathJoin(&[_][]const u8{ allegro_dir, "lib" }) });
}
module.link_libc = true;
if (static) {
module.linkSystemLibrary("allegro-static", .{});
module.linkSystemLibrary("allegro_font-static", .{});
module.linkSystemLibrary("allegro_image-static", .{});
module.linkSystemLibrary("allegro_memfile-static", .{});
module.linkSystemLibrary("allegro_ttf-static", .{});
module.linkSystemLibrary("dumb", .{});
module.linkSystemLibrary("FLAC", .{});
module.linkSystemLibrary("freetype", .{});
module.linkSystemLibrary("jpeg", .{});
module.linkSystemLibrary("ogg", .{});
module.linkSystemLibrary("opus", .{});
module.linkSystemLibrary("opusfile", .{});
module.linkSystemLibrary("physfs", .{});
module.linkSystemLibrary("png16", .{});
// module.linkSystemLibrary("theoradec", .{});
module.linkSystemLibrary("vorbis", .{});
module.linkSystemLibrary("vorbisfile", .{});
module.linkSystemLibrary("webp", .{});
module.linkSystemLibrary("webpdecoder", .{});
module.linkSystemLibrary("webpdemux", .{});
module.linkSystemLibrary("zlib", .{});
module.linkSystemLibrary("opengl32", .{});
// module.linkSystemLibrary("", .{});
// module.linkSystemLibrary("", .{});
// module.linkSystemLibrary("", .{});
// module.linkSystemLibrary("", .{});
// module.linkSystemLibrary("", .{});
if (target.result.os.tag == .windows) {
module.linkSystemLibrary("gdi32", .{});
module.linkSystemLibrary("ole32", .{});
module.linkSystemLibrary("shlwapi", .{});
module.linkSystemLibrary("winmm", .{});
// module.linkSystemLibrary("", .{});
// module.linkSystemLibrary("", .{});
// module.linkSystemLibrary("", .{});
// module.linkSystemLibrary("", .{});
// module.linkSystemLibrary("", .{});
if (target.result.isGnu()) {
// module.linkSystemLibrary("stdc++", .{});
}
}
} else {
module.linkSystemLibrary("allegro.dll", .{});
module.linkSystemLibrary("allegro_font.dll", .{});
module.linkSystemLibrary("allegro_image.dll", .{});
module.linkSystemLibrary("allegro_memfile.dll", .{});
module.linkSystemLibrary("allegro_ttf.dll", .{});
}
}