diff options
Diffstat (limited to 'examples/hello-zig/build.zig')
| -rw-r--r-- | examples/hello-zig/build.zig | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/examples/hello-zig/build.zig b/examples/hello-zig/build.zig new file mode 100644 index 0000000..5c56fb0 --- /dev/null +++ b/examples/hello-zig/build.zig | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | pub fn build(b: *std.Build) void { | ||
| 4 | const target = b.standardTargetOptions(.{}); | ||
| 5 | const optimize = b.standardOptimizeOption(.{}); | ||
| 6 | |||
| 7 | const lib_mod = b.addModule("hello_zig", .{ | ||
| 8 | .root_source_file = b.path("src/root.zig"), | ||
| 9 | .target = target, | ||
| 10 | }); | ||
| 11 | |||
| 12 | const exe = b.addExecutable(.{ | ||
| 13 | .name = "hello-zig", | ||
| 14 | .root_module = b.createModule(.{ | ||
| 15 | .root_source_file = b.path("src/main.zig"), | ||
| 16 | .target = target, | ||
| 17 | .optimize = optimize, | ||
| 18 | .imports = &.{ | ||
| 19 | .{ .name = "hello_zig", .module = lib_mod }, | ||
| 20 | }, | ||
| 21 | }), | ||
| 22 | }); | ||
| 23 | |||
| 24 | b.installArtifact(exe); | ||
| 25 | |||
| 26 | const run_step = b.step("run", "Run the sample app"); | ||
| 27 | const run_cmd = b.addRunArtifact(exe); | ||
| 28 | run_step.dependOn(&run_cmd.step); | ||
| 29 | |||
| 30 | if (b.args) |args| { | ||
| 31 | run_cmd.addArgs(args); | ||
| 32 | } | ||
| 33 | |||
| 34 | const lib_tests = b.addTest(.{ | ||
| 35 | .root_module = lib_mod, | ||
| 36 | }); | ||
| 37 | const exe_tests = b.addTest(.{ | ||
| 38 | .root_module = exe.root_module, | ||
| 39 | }); | ||
| 40 | |||
| 41 | const run_lib_tests = b.addRunArtifact(lib_tests); | ||
| 42 | const run_exe_tests = b.addRunArtifact(exe_tests); | ||
| 43 | |||
| 44 | const test_step = b.step("test", "Run the sample tests"); | ||
| 45 | test_step.dependOn(&run_lib_tests.step); | ||
| 46 | test_step.dependOn(&run_exe_tests.step); | ||
| 47 | } | ||
