heavens-net/build.zig
2025-03-30 02:19:52 +09:00

63 lines
1.6 KiB
Zig

const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// ---- deps
const dvui_dep = b.dependency("dvui", .{
.target = target,
.optimize = optimize,
.backend = .sdl,
.sdl3 = true,
});
// ---- library
const lib_mod = b.createModule(.{
.root_source_file = b.path("src/hncore/root.zig"),
.target = target,
.optimize = optimize,
});
const lib = b.addLibrary(.{
.linkage = .static,
.name = "hncore",
.root_module = lib_mod,
});
b.installArtifact(lib);
// ---- executable
const exe_mod = b.createModule(.{
.root_source_file = b.path("src/hnet/main.zig"),
.target = target,
.optimize = optimize,
});
exe_mod.addImport("hncore", lib_mod);
exe_mod.addImport("dvui", dvui_dep.module("dvui_sdl"));
const exe = b.addExecutable(.{
.name = "hnet",
.root_module = exe_mod,
});
b.installArtifact(exe);
// ---- running
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// ---- testing
const lib_unit_tests = b.addTest(.{
.root_module = lib_mod,
});
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
}