rkgk/crates/haku2/build.zig
リキ萌 5de4f9d7c6 hotwire haku2 into rkgk
really a bodge job right now and it crashes but it's a start
2025-06-04 00:28:43 +02:00

60 lines
1.5 KiB
Zig

const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Library
const mod = b.createModule(.{
.root_source_file = b.path("src/haku2.zig"),
.target = target,
.optimize = optimize,
.pic = true,
});
const lib = b.addStaticLibrary(.{
.name = "haku2",
.root_module = mod,
});
lib.pie = true;
lib.bundle_compiler_rt = true;
b.installArtifact(lib);
const mod_wasm = b.createModule(.{
.root_source_file = b.path("src/haku2.zig"),
.target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
}),
.optimize = optimize,
});
const exe_wasm = b.addExecutable(.{
.linkage = .static,
.name = "haku2",
.root_module = mod_wasm,
});
exe_wasm.entry = .disabled;
exe_wasm.rdynamic = true;
b.installArtifact(exe_wasm);
// Tests
const lib_unit_tests = b.addTest(.{
.root_module = 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);
// Checks
const lib_check = b.addLibrary(.{
.linkage = .static,
.name = "haku2_check",
.root_module = mod,
});
const check_step = b.step("check", "Check if the project compiles");
check_step.dependOn(&lib_check.step);
}