Backlog/engine/core/build.zig

61 lines
1.9 KiB
Zig

const std = @import("std");
pub const bh = @import("bh");
pub const ModLib = bh.ModLib;
pub const MakeModLib = bh.MakeModLib;
const dependencyList = [_][]const u8{
"p2",
"tracy", // usually doesnt have C deps... unless we're compiled with it on, in which case we only support static builds
"zmath",
"packer", // packer no longer has C deps.
};
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 engineMod = MakeModLib(b, .{
.name = "core",
.target = target,
.optimize = optimize,
.static_build = static_build,
});
engineMod.linkModLibs(&dependencyList);
const test_step = b.step("test", "run unit tests for core");
const tests = b.addTest(.{
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("tests/tests.zig"),
}),
});
const sampleGameExtern = b.addLibrary(.{
.root_module = b.createModule(.{
.root_source_file = b.path("tests/externalModule.zig"),
.link_libc = true,
.optimize = optimize,
.target = target,
}),
.linkage = .dynamic,
.name = "external",
});
sampleGameExtern.root_module.addImport("core", engineMod.mod);
const installExtern = b.addInstallArtifact(sampleGameExtern, .{
.dest_dir = .{ .override = .{ .custom = "modules" } },
});
b.getInstallStep().dependOn(&installExtern.step);
tests.root_module.addImport("core", engineMod.mod);
const runArtifact = b.addRunArtifact(tests);
test_step.dependOn(&runArtifact.step);
runArtifact.step.dependOn(b.getInstallStep());
b.installArtifact(tests);
}