2023-09-20 10:49:38 +00:00
|
|
|
const std = @import("std");
|
|
|
|
|
|
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
|
|
|
const target = b.standardTargetOptions(.{});
|
|
|
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
|
|
2024-01-14 10:07:26 +00:00
|
|
|
const cli_mod = b.addModule("cli", .{ .root_source_file = .{ .path = "cli.zig" } });
|
|
|
|
|
const demo_exe = b.addExecutable(.{
|
|
|
|
|
.name = "cli-demo",
|
|
|
|
|
.root_source_file = .{ .path = "demo.zig" },
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
.target = target,
|
|
|
|
|
.link_libc = true,
|
|
|
|
|
});
|
|
|
|
|
demo_exe.root_module.addImport("cli", cli_mod);
|
|
|
|
|
|
|
|
|
|
// compile
|
|
|
|
|
const compile_step = b.step("compile", "Compile demo executable");
|
|
|
|
|
compile_step.dependOn(&demo_exe.step);
|
|
|
|
|
|
|
|
|
|
// install
|
|
|
|
|
b.installArtifact(demo_exe);
|
|
|
|
|
|
|
|
|
|
// run test
|
|
|
|
|
const run_demo_exe1 = b.addRunArtifact(demo_exe);
|
|
|
|
|
run_demo_exe1.addArgs(&[_][]const u8{ "-e", "4" });
|
|
|
|
|
const run_demo_exe2 = b.addRunArtifact(demo_exe);
|
|
|
|
|
run_demo_exe2.addArgs(&[_][]const u8{"subexample"});
|
2023-09-20 10:49:38 +00:00
|
|
|
const unit_tests = b.addTest(.{
|
|
|
|
|
.root_source_file = .{ .path = "cli.zig" },
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
});
|
|
|
|
|
const run_unit_tests = b.addRunArtifact(unit_tests);
|
|
|
|
|
const test_step = b.step("test", "Run unit tests");
|
|
|
|
|
test_step.dependOn(&run_unit_tests.step);
|
2024-01-14 10:07:26 +00:00
|
|
|
test_step.dependOn(&run_demo_exe1.step);
|
|
|
|
|
test_step.dependOn(&run_demo_exe2.step);
|
2023-09-20 10:49:38 +00:00
|
|
|
}
|