Backlog/engine/core/build.zig

58 lines
1.8 KiB
Zig

const std = @import("std");
const dependencyList = [_][]const u8{
"p2",
"tracy",
"zmath",
"packer", // packer might need to be split into another setup that doesn't have C deps.
// these ones use c deps, but if i move them out to platform... then core will have zero c dependencies.
// "lua",
"spng",
// "nfd",
};
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
const mod = b.addModule("core", .{
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/core.zig"),
});
for (dependencyList) |depName| {
const dep = b.dependency(depName, .{ .target = target, .optimize = optimize, .static_build = static_build });
mod.addImport(depName, dep.module(depName));
}
const test_step = b.step("test", "run unit tests for core");
const tests = b.addTest(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("tests/tests.zig"),
});
const sampleGameExtern = b.addSharedLibrary(.{
.root_source_file = b.path("tests/externalModule.zig"),
.link_libc = true,
.optimize = optimize,
.target = target,
.name = "external",
});
const installExtern = b.addInstallArtifact(sampleGameExtern, .{
.dest_dir = .{ .override = .{ .custom = "modules" } },
});
b.getInstallStep().dependOn(&installExtern.step);
tests.root_module.addImport("core", mod);
const runArtifact = b.addRunArtifact(tests);
test_step.dependOn(&runArtifact.step);
runArtifact.step.dependOn(b.getInstallStep());
b.installArtifact(tests);
}