|
| 1 | +const std = @import("std"); |
| 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 | +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 | + 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 | + const optimize = b.standardOptimizeOption(.{}); |
| 17 | + |
| 18 | + const lib = b.addStaticLibrary(.{ |
| 19 | + .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 | + .root_source_file = b.path("fluent.zig"), |
| 23 | + .target = target, |
| 24 | + .optimize = optimize, |
| 25 | + }); |
| 26 | + |
| 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 | + b.installArtifact(lib); |
| 31 | + |
| 32 | + // Export as module to be available for @import("Fluent") on user site |
| 33 | + _ = b.addModule("Fluent", .{ |
| 34 | + .root_source_file = b.path("fluent.zig"), |
| 35 | + .target = target, |
| 36 | + .optimize = optimize, |
| 37 | + }); |
| 38 | +} |
0 commit comments