|
1 | 1 | const std = @import("std"); |
2 | 2 |
|
3 | 3 | pub fn build(b: *std.Build) void { |
| 4 | + const install_step = b.getInstallStep(); |
4 | 5 | const target = b.standardTargetOptions(.{}); |
5 | 6 | const optimize = b.standardOptimizeOption(.{}); |
6 | | - const root_source_file = b.path("src/lib.zig"); |
7 | | - const version = std.SemanticVersion{ .major = 0, .minor = 2, .patch = 1 }; |
| 7 | + const root_source_file = b.path("src/root.zig"); |
| 8 | + const version = std.SemanticVersion{ .major = 0, .minor = 2, .patch = 2 }; |
8 | 9 |
|
9 | 10 | // Module |
10 | | - _ = b.addModule("cookie", .{ .root_source_file = root_source_file }); |
| 11 | + const mod = b.addModule("cookie", .{ |
| 12 | + .target = target, |
| 13 | + .optimize = optimize, |
| 14 | + .root_source_file = root_source_file, |
| 15 | + }); |
11 | 16 |
|
12 | 17 | // Library |
13 | 18 | const lib_step = b.step("lib", "Install library"); |
14 | 19 |
|
15 | | - const lib = b.addStaticLibrary(.{ |
| 20 | + const lib = b.addLibrary(.{ |
16 | 21 | .name = "cookie", |
17 | | - .target = target, |
18 | 22 | .version = version, |
19 | | - .optimize = optimize, |
20 | | - .root_source_file = root_source_file, |
| 23 | + .root_module = mod, |
21 | 24 | }); |
22 | 25 |
|
23 | 26 | const lib_install = b.addInstallArtifact(lib, .{}); |
24 | 27 | lib_step.dependOn(&lib_install.step); |
25 | | - b.default_step.dependOn(lib_step); |
| 28 | + install_step.dependOn(lib_step); |
26 | 29 |
|
27 | 30 | // Documentation |
28 | | - const doc_step = b.step("doc", "Emit documentation"); |
29 | | - |
30 | | - const doc_install = b.addInstallDirectory(.{ |
| 31 | + const docs_step = b.step("doc", "Emit documentation"); |
| 32 | + const docs_install = b.addInstallDirectory(.{ |
31 | 33 | .install_dir = .prefix, |
32 | | - .install_subdir = "doc", |
| 34 | + .install_subdir = "docs", |
33 | 35 | .source_dir = lib.getEmittedDocs(), |
34 | 36 | }); |
35 | | - doc_step.dependOn(&doc_install.step); |
36 | | - b.default_step.dependOn(doc_step); |
| 37 | + docs_step.dependOn(&docs_install.step); |
| 38 | + install_step.dependOn(docs_step); |
37 | 39 |
|
38 | 40 | // Test suite |
39 | 41 | const tests_step = b.step("test", "Run test suite"); |
40 | 42 |
|
41 | 43 | const tests = b.addTest(.{ |
42 | | - .target = target, |
43 | 44 | .version = version, |
44 | | - .root_source_file = root_source_file, |
| 45 | + .root_module = b.createModule(.{ |
| 46 | + .target = target, |
| 47 | + .root_source_file = root_source_file, |
| 48 | + }), |
45 | 49 | }); |
46 | 50 |
|
47 | 51 | const tests_run = b.addRunArtifact(tests); |
48 | 52 | tests_step.dependOn(&tests_run.step); |
49 | | - b.default_step.dependOn(tests_step); |
| 53 | + install_step.dependOn(tests_step); |
50 | 54 |
|
51 | | - // Formatting checks |
52 | | - const fmt_step = b.step("fmt", "Run formatting checks"); |
| 55 | + // Formatting check |
| 56 | + const fmt_step = b.step("fmt", "Check formatting"); |
53 | 57 |
|
54 | 58 | const fmt = b.addFmt(.{ |
55 | 59 | .paths = &.{ |
56 | 60 | "src/", |
57 | 61 | "build.zig", |
| 62 | + "build.zig.zon", |
58 | 63 | }, |
59 | 64 | .check = true, |
60 | 65 | }); |
61 | 66 | fmt_step.dependOn(&fmt.step); |
62 | | - b.default_step.dependOn(fmt_step); |
| 67 | + install_step.dependOn(fmt_step); |
63 | 68 | } |
0 commit comments