ona/build.zig

56 lines
1.5 KiB
Zig

const std = @import("std");
///
/// Builds the engine, tools, and dependencies of all.
///
pub fn build(builder: *std.build.Builder) void {
const target = builder.standardTargetOptions(.{});
const mode = builder.standardReleaseOptions();
const ona_pkg = projectPkg("ona", &.{});
// Engine executable.
{
const exe = builder.addExecutable("engine", "./src/engine/main.zig");
exe.addPackage(projectPkg("oar", &.{ona_pkg}));
exe.addPackage(ona_pkg);
exe.setTarget(target);
exe.setBuildMode(mode);
exe.install();
exe.addIncludeDir("./ext");
exe.linkSystemLibrary("SDL2");
exe.linkLibC();
}
// Oar executable.
{
const exe = builder.addExecutable("oar", "./src/oar/main.zig");
exe.addPackage(ona_pkg);
exe.setTarget(target);
exe.setBuildMode(mode);
exe.install();
}
// Tests executable.
{
const tests = builder.addTestExe("test", "./src/tests.zig");
tests.setTarget(target);
tests.setBuildMode(mode);
builder.step("test", "Run unit tests").dependOn(&tests.step);
}
}
///
/// Returns a [std.build.Pkg] within the project codebase path at `name` with `dependencies` as its
/// dependencies.
///
fn projectPkg(comptime name: []const u8, dependencies: []const std.build.Pkg) std.build.Pkg {
return std.build.Pkg{
.name = name,
.path = .{.path = "./src/" ++ name ++ "/main.zig"},
.dependencies = dependencies,
};
}