Backlog/engine/physics/build.zig

43 lines
1.5 KiB
Zig

const std = @import("std");
// very tiny, not intended to build anything just to run tests linked with libc
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("physics", .{
.target = target,
.optimize = optimize,
.link_libc = true,
.root_source_file = b.path("src/physics.zig"),
});
const core_dep = b.dependency("core", .{ .target = target, .optimize = optimize, .static_build = static_build });
const zphysics_dep = b.dependency("zphysics", .{
.target = target,
.optimize = optimize,
.enable_cross_platform_determinism = false,
.static_build = static_build,
});
mod.addImport("core", core_dep.module("core"));
mod.addImport("zphysics", zphysics_dep.module("root"));
mod.linkLibrary(zphysics_dep.artifact("joltc"));
const test_step = b.step("test", "run unit tests for physics");
const tests = b.addTest(.{
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path("tests/tests.zig"),
}),
});
tests.root_module.addImport("physics", mod);
const runArtifact = b.addRunArtifact(tests);
test_step.dependOn(&runArtifact.step);
b.installArtifact(tests);
}