114 lines
4.2 KiB
Zig
114 lines
4.2 KiB
Zig
const std = @import("std");
|
|
const program = @import("build-tooling/programs.zig");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
const target = b.standardTargetOptions(.{});
|
|
|
|
const slugger = b.dependency("slugger", .{ .target = target, .optimize = optimize });
|
|
const p2 = b.dependency("p2", .{ .target = target, .optimize = optimize });
|
|
const xxd = b.dependency("xxd", .{ .target = target, .optimize = optimize });
|
|
|
|
const core = b.addModule("core", .{
|
|
.root_source_file = b.path("src/core/core.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.imports = &.{.{ .name = "slugger", .module = slugger.module("slugger") }},
|
|
});
|
|
core.addImport("p2", p2.module("p2"));
|
|
core.addImport("xxd", xxd.module("xxd"));
|
|
|
|
const core_tests = b.addTest(.{ .root_module = core });
|
|
b.step("test", "Run core tests").dependOn(&b.addRunArtifact(core_tests).step);
|
|
|
|
const parser = b.addExecutable(.{
|
|
.root_module = b.createModule(.{
|
|
.optimize = optimize,
|
|
.target = target,
|
|
.root_source_file = b.path("tools/generate-api.zig"),
|
|
}),
|
|
.name = "parser",
|
|
});
|
|
parser.root_module.addImport("p2", p2.module("p2"));
|
|
const parse_interface_core = b.addRunArtifact(parser);
|
|
parse_interface_core.addFileArg2(b.path("src/core/api.tad"), .{ .prefix = "--input-file=" });
|
|
|
|
const generate_headers_step = b.step("generate-interface", "generates interface information from all core apis");
|
|
|
|
generate_headers_step.dependOn(&parse_interface_core.step);
|
|
|
|
// just rebuilds tools
|
|
const build_tools = b.step("tools", "installs tools");
|
|
b.getInstallStep().dependOn(build_tools);
|
|
|
|
{
|
|
const exe = b.addExecutable(.{
|
|
.name = "rl",
|
|
.root_module = b.createModule(.{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.root_source_file = b.path("tools/log-reader.zig"),
|
|
}),
|
|
});
|
|
exe.root_module.addImport("core", core);
|
|
|
|
const install = b.addInstallArtifact(exe, .{
|
|
.dest_dir = .{ .override = .{ .custom = "tools" } },
|
|
});
|
|
const run = b.addRunArtifact(exe);
|
|
run.addArgs(&.{"lib/slugger/zig-out/logs/test2.slg"});
|
|
|
|
const run_test = b.step("test-rl", "tests the rl cli tool");
|
|
run_test.dependOn(&run.step);
|
|
|
|
build_tools.dependOn(&install.step);
|
|
}
|
|
|
|
// create a small program
|
|
// this will contain two parts
|
|
// 1. the 'engine' once it goes up it creates several engine objects including the engine
|
|
// itself and it constructs api structs for programs to consume
|
|
//
|
|
// 2. the 'program' hot reloadable dynamic library.
|
|
// links nothing but the interfaces provided by the 'engine'
|
|
//
|
|
// and exports it's own interfaces to the engine. engine calls it's 'entry point'
|
|
{
|
|
const exe = b.addExecutable(.{ .name = "testmain", .root_module = b.createModule(.{
|
|
.optimize = optimize,
|
|
.target = target,
|
|
.root_source_file = b.path("src/main.zig"),
|
|
}) });
|
|
b.installArtifact(exe);
|
|
exe.root_module.addImport("core", core);
|
|
|
|
const testmain = b.addRunArtifact(exe);
|
|
testmain.addArg("--cli-test");
|
|
testmain.step.dependOn(b.getInstallStep());
|
|
b.step("run-testmain", "testing the testmain").dependOn(&testmain.step);
|
|
|
|
// now that we've built main it's time to build a hot library
|
|
const hotlib = b.addLibrary(.{
|
|
.name = "game",
|
|
.root_module = b.createModule(.{
|
|
.optimize = optimize,
|
|
.target = target,
|
|
.root_source_file = b.path("programs/sample-program.zig"),
|
|
}),
|
|
.linkage = .dynamic, // todo static builds
|
|
});
|
|
hotlib.bundle_ubsan_rt = false;
|
|
|
|
const inst = b.addInstallArtifact(hotlib, .{
|
|
.dest_sub_path = b.fmt("{s}.pod{s}", .{
|
|
"game",
|
|
target.result.dynamicLibSuffix(),
|
|
}),
|
|
.dest_dir = .{ .override = .{
|
|
.custom = "pods",
|
|
} },
|
|
});
|
|
b.getInstallStep().dependOn(&inst.step);
|
|
}
|
|
}
|