|
1 | 1 | const std = @import("std");
|
2 | 2 |
|
3 |
| -// Although this function looks imperative, note that its job is to |
4 |
| -// declaratively construct a build graph that will be executed by an external |
5 |
| -// runner. |
6 | 3 | pub fn build(b: *std.Build) void {
|
7 |
| - // Standard target options allows the person running `zig build` to choose |
8 |
| - // what target to build for. Here we do not override the defaults, which |
9 |
| - // means any target is allowed, and the default is native. Other options |
10 |
| - // for restricting supported target set are available. |
11 | 4 | const target = b.standardTargetOptions(.{});
|
12 |
| - |
13 |
| - // Standard optimization options allow the person running `zig build` to select |
14 |
| - // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not |
15 |
| - // set a preferred release mode, allowing the user to decide how to optimize. |
16 | 5 | const optimize = b.standardOptimizeOption(.{});
|
17 | 6 |
|
18 | 7 | const lib = b.addStaticLibrary(.{
|
19 | 8 | .name = "Fluent",
|
20 |
| - // In this case the main source file is merely a path, however, in more |
21 |
| - // complicated build scripts, this could be a generated file. |
22 | 9 | .root_source_file = b.path("fluent.zig"),
|
23 | 10 | .target = target,
|
24 | 11 | .optimize = optimize,
|
25 | 12 | });
|
26 | 13 |
|
27 |
| - // This declares intent for the library to be installed into the standard |
28 |
| - // location when the user invokes the "install" step (the default step when |
29 |
| - // running `zig build`). |
30 | 14 | b.installArtifact(lib);
|
31 | 15 |
|
32 |
| - // Export as module to be available for @import("Fluent") on user site |
| 16 | + const check = b.addStaticLibrary(.{ |
| 17 | + .name = "Fluent", |
| 18 | + .root_source_file = b.path("fluent.zig"), |
| 19 | + .target = target, |
| 20 | + .optimize = optimize, |
| 21 | + .use_llvm = false, |
| 22 | + .use_lld = false, |
| 23 | + }); |
| 24 | + const check_step = b.step("check", "check if the code compiles"); |
| 25 | + check_step.dependOn(&check.step); |
| 26 | + |
| 27 | + const lib_unit_tests = b.addTest(.{ |
| 28 | + .root_source_file = b.path("fluent.zig"), |
| 29 | + .target = target, |
| 30 | + .optimize = optimize, |
| 31 | + }); |
| 32 | + |
| 33 | + const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests); |
| 34 | + const test_step = b.step("test", "Run unit tests"); |
| 35 | + test_step.dependOn(&run_lib_unit_tests.step); |
| 36 | + |
33 | 37 | _ = b.addModule("Fluent", .{
|
34 | 38 | .root_source_file = b.path("fluent.zig"),
|
35 | 39 | .target = target,
|
|
0 commit comments