rkgk/crates/haku2/build.zig

54 lines
1.3 KiB
Zig
Raw Normal View History

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 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);
}