improve build.zig; run nu tests
This commit is contained in:
53
build.zig
53
build.zig
@@ -14,12 +14,28 @@ pub fn build(b: *std.Build) void {
|
||||
|
||||
const cimgui = b.dependency("cimgui", .{});
|
||||
|
||||
const nu = b.addModule("nu", .{
|
||||
.root_source_file = b.path("src/nu.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
});
|
||||
nu.addImport("cimgui", cimgui.module("cimgui"));
|
||||
nu.addImport("vk", vkmod);
|
||||
nu.linkSystemLibrary("glfw3", .{
|
||||
.needed = true,
|
||||
.preferred_link_mode = .static,
|
||||
.use_pkg_config = .force,
|
||||
});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "scratchzig",
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
exe.root_module.addImport("nu", nu);
|
||||
exe.root_module.addImport("vk", vkmod);
|
||||
exe.root_module.addImport("cimgui", cimgui.module("cimgui"));
|
||||
|
||||
const shaders = vkgen.ShaderCompileStep.create(
|
||||
@@ -31,14 +47,6 @@ pub fn build(b: *std.Build) void {
|
||||
shaders.add("triangle_frag", "src/shaders/triangle.frag", .{});
|
||||
exe.root_module.addImport("shaders", shaders.getModule());
|
||||
|
||||
exe.linkSystemLibrary2("glfw3", .{
|
||||
.needed = true,
|
||||
.preferred_link_mode = .static,
|
||||
.use_pkg_config = .force,
|
||||
});
|
||||
exe.linkLibC();
|
||||
exe.root_module.addImport("vk", vkmod);
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
@@ -51,19 +59,36 @@ pub fn build(b: *std.Build) void {
|
||||
const run_step = b.step("run", "Run the app");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
|
||||
const exe_unit_tests = b.addTest(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
const nu_unit_tests = b.addTest(.{
|
||||
.root_source_file = b.path("src/nu.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
exe_unit_tests.linkSystemLibrary2("glfw3", .{
|
||||
nu_unit_tests.root_module.addImport("cimgui", cimgui.module("cimgui"));
|
||||
nu_unit_tests.root_module.addImport("vk", vkmod);
|
||||
nu_unit_tests.root_module.linkSystemLibrary("glfw3", .{
|
||||
.needed = true,
|
||||
.preferred_link_mode = .static,
|
||||
.use_pkg_config = .force,
|
||||
});
|
||||
exe_unit_tests.linkLibC();
|
||||
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
|
||||
nu_unit_tests.linkLibC();
|
||||
|
||||
const run_nu_unit_tests = b.addRunArtifact(nu_unit_tests);
|
||||
|
||||
// const exe_unit_tests = b.addTest(.{
|
||||
// .root_source_file = b.path("src/main.zig"),
|
||||
// .target = target,
|
||||
// .optimize = optimize,
|
||||
// });
|
||||
// exe_unit_tests.linkSystemLibrary2("glfw3", .{
|
||||
// .needed = true,
|
||||
// .preferred_link_mode = .static,
|
||||
// .use_pkg_config = .force,
|
||||
// });
|
||||
// exe_unit_tests.linkLibC();
|
||||
// const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
|
||||
|
||||
const test_step = b.step("test", "Run unit tests");
|
||||
test_step.dependOn(&run_exe_unit_tests.step);
|
||||
// test_step.dependOn(&run_exe_unit_tests.step);
|
||||
test_step.dependOn(&run_nu_unit_tests.step);
|
||||
}
|
||||
|
Reference in New Issue
Block a user