ona/build.zig

56 lines
1.5 KiB
Zig
Raw Normal View History

2022-08-10 15:52:16 +02:00
const std = @import("std");
2022-10-17 11:34:04 +02:00
///
/// Builds the engine, tools, and dependencies of all.
///
2022-08-10 15:52:16 +02:00
pub fn build(builder: *std.build.Builder) void {
const target = builder.standardTargetOptions(.{});
const mode = builder.standardReleaseOptions();
2022-10-17 11:34:04 +02:00
const ona_pkg = projectPkg("ona", &.{});
2022-08-10 15:52:16 +02:00
2022-10-17 11:34:04 +02:00
// Engine executable.
2022-08-10 15:52:16 +02:00
{
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();
2022-08-10 15:52:16 +02:00
}
2022-10-17 11:34:04 +02:00
// Oar executable.
{
const exe = builder.addExecutable("oar", "./src/oar/main.zig");
2022-10-17 11:34:04 +02:00
exe.addPackage(ona_pkg);
exe.setTarget(target);
exe.setBuildMode(mode);
exe.install();
2022-10-17 11:34:04 +02:00
}
// Tests executable.
2022-08-10 15:52:16 +02:00
{
const tests = builder.addTestExe("test", "./src/tests.zig");
2022-08-10 15:52:16 +02:00
tests.setTarget(target);
tests.setBuildMode(mode);
builder.step("test", "Run unit tests").dependOn(&tests.step);
2022-08-10 15:52:16 +02:00
}
}
2022-10-17 11:34:04 +02:00
///
/// 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,
};
}