ona/build.zig

46 lines
1.2 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 core_pkg = projectPkg("core", &.{});
// Ona executable.
{
const ona = builder.addExecutable("ona", "./src/ona/main.zig");
ona.addPackage(core_pkg);
ona.setTarget(target);
ona.setBuildMode(mode);
ona.install();
ona.addIncludeDir("./ext");
ona.linkSystemLibrary("SDL2");
ona.linkLibC();
}
// Tests executable.
{
const tests = builder.addTestExe("test", "./src/tests.zig");
tests.addPackage(core_pkg);
tests.setTarget(target);
tests.setBuildMode(mode);
tests.install();
}
}
///
/// 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,
};
}