summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.zig27
1 files changed, 15 insertions, 12 deletions
diff --git a/build.zig b/build.zig
index 8362715..0167d79 100644
--- a/build.zig
+++ b/build.zig
@@ -1,15 +1,15 @@
1const std = @import("std"); 1const std = @import("std");
2 2
3const Builder = std.build.Builder; 3pub fn build(b: *std.Build) void {
4 4 const optimize = b.standardOptimizeOption(.{});
5pub fn build(b: *Builder) void {
6 const mode = b.standardReleaseOptions();
7 const target = b.standardTargetOptions(.{}); 5 const target = b.standardTargetOptions(.{});
8 6
9 const test_step = b.step("test", "Run all tests in all modes."); 7 const test_step = b.step("test", "Run all tests in all modes.");
10 const tests = b.addTest("clap.zig"); 8 const tests = b.addTest(.{
11 tests.setBuildMode(mode); 9 .root_source_file = .{ .path = "clap.zig" },
12 tests.setTarget(target); 10 .target = target,
11 .optimize = optimize,
12 });
13 test_step.dependOn(&tests.step); 13 test_step.dependOn(&tests.step);
14 14
15 const example_step = b.step("examples", "Build examples"); 15 const example_step = b.step("examples", "Build examples");
@@ -20,10 +20,13 @@ pub fn build(b: *Builder) void {
20 "help", 20 "help",
21 "usage", 21 "usage",
22 }) |example_name| { 22 }) |example_name| {
23 const example = b.addExecutable(example_name, "example/" ++ example_name ++ ".zig"); 23 const example = b.addExecutable(.{
24 example.addPackagePath("clap", "clap.zig"); 24 .name = example_name,
25 example.setBuildMode(mode); 25 .root_source_file = .{ .path = "example/" ++ example_name ++ ".zig" },
26 example.setTarget(target); 26 .target = target,
27 .optimize = optimize,
28 });
29 example.addAnonymousModule("clap", .{ .source_file = .{ .path = "clap.zig" } });
27 example.install(); 30 example.install();
28 example_step.dependOn(&example.step); 31 example_step.dependOn(&example.step);
29 } 32 }
@@ -41,7 +44,7 @@ pub fn build(b: *Builder) void {
41 b.default_step.dependOn(all_step); 44 b.default_step.dependOn(all_step);
42} 45}
43 46
44fn readMeStep(b: *Builder) *std.build.Step { 47fn readMeStep(b: *std.Build) *std.Build.Step {
45 const s = b.allocator.create(std.build.Step) catch unreachable; 48 const s = b.allocator.create(std.build.Step) catch unreachable;
46 s.* = std.build.Step.init(.custom, "ReadMeStep", b.allocator, struct { 49 s.* = std.build.Step.init(.custom, "ReadMeStep", b.allocator, struct {
47 fn make(step: *std.build.Step) anyerror!void { 50 fn make(step: *std.build.Step) anyerror!void {