ona/build.zig

58 lines
1.6 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-23 19:11:02 +02:00
const core_pkg = projectPkg("core", &.{});
2022-08-10 15:52:16 +02:00
2022-10-23 19:11:02 +02:00
// Ona executable.
2022-08-10 15:52:16 +02:00
{
2022-10-23 19:11:02 +02:00
const exe = builder.addExecutable("ona", "./src/ona/main.zig");
2022-10-23 19:11:02 +02:00
exe.addPackage(projectPkg("oar", &.{core_pkg}));
exe.addPackage(core_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
2022-10-23 19:11:02 +02:00
exe.addPackage(core_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.addPackage(core_pkg);
tests.setTarget(target);
tests.setBuildMode(mode);
tests.install();
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,
};
}