Initial Commit

This commit is contained in:
David Allemang
2025-01-15 16:47:59 -05:00
commit 2b3734a087
7 changed files with 157 additions and 0 deletions

70
build.zig Normal file
View File

@@ -0,0 +1,70 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const lib_mod = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
const exe_mod = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe_mod.addImport("zig-shape-lib", lib_mod);
const lib = b.addStaticLibrary(.{
.name = "zig-shape",
.root_module = lib_mod,
});
b.installArtifact(lib);
const exe = b.addExecutable(.{
.name = "zig-shape",
.root_module = exe_mod,
});
b.installArtifact(exe);
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);
const lib_unit_tests = b.addTest(.{
.root_module = lib_mod,
.name = "lib-unit-tests",
});
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
const exe_unit_tests = b.addTest(.{
.root_module = exe_mod,
.name = "exe-unit-tests",
});
const build_test_step = b.step("build-test", "Build unit tests");
const install_lib_test = b.addInstallArtifact(lib_unit_tests, .{ .dest_dir = .{ .override = .{ .custom = "dev" } } });
build_test_step.dependOn(&install_lib_test.step);
const install_exe_test = b.addInstallArtifact(exe_unit_tests, .{ .dest_dir = .{ .override = .{ .custom = "dev" } } });
build_test_step.dependOn(&install_exe_test.step);
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
test_step.dependOn(&run_exe_unit_tests.step);
}