60 lines
1.6 KiB
Zig
60 lines
1.6 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 engine_exe = builder.addExecutable("ona", "./src/engine/main.zig");
|
|
const oar_pkg = projectPkg("oar", &.{ona_pkg});
|
|
|
|
engine_exe.addPackage(oar_pkg);
|
|
engine_exe.addPackage(ona_pkg);
|
|
engine_exe.setTarget(target);
|
|
engine_exe.setBuildMode(mode);
|
|
engine_exe.install();
|
|
engine_exe.addIncludeDir("./ext");
|
|
engine_exe.linkSystemLibrary("SDL2");
|
|
engine_exe.linkLibC();
|
|
|
|
const run_cmd = engine_exe.run();
|
|
|
|
run_cmd.step.dependOn(builder.getInstallStep());
|
|
|
|
if (builder.args) |args| run_cmd.addArgs(args);
|
|
|
|
builder.step("run", "Run Ona application").dependOn(&run_cmd.step);
|
|
}
|
|
|
|
// Oar executable.
|
|
{
|
|
|
|
}
|
|
|
|
// Ona tests.
|
|
{
|
|
const ona_tests = builder.addTestExe("test", "./src/main.zig");
|
|
|
|
ona_tests.setTarget(target);
|
|
ona_tests.setBuildMode(mode);
|
|
builder.step("test", "Run Ona unit tests").dependOn(&ona_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,
|
|
};
|
|
}
|