ona/build.zig

46 lines
1.2 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-30 23:06:56 +01:00
const ona = builder.addExecutable("ona", "./src/ona/main.zig");
2022-10-30 23:06:56 +01:00
ona.addPackage(core_pkg);
ona.setTarget(target);
ona.setBuildMode(mode);
ona.install();
ona.addIncludeDir("./ext");
ona.linkSystemLibrary("SDL2");
ona.linkLibC();
2022-08-10 15:52:16 +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();
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,
};
}