Skip to content

Commit ba07c58

Browse files
Merge pull request #18 from mnemnion/zig-build-zon
Zig build system
2 parents 441e39d + ce818cf commit ba07c58

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

build.zig

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

build.zig.zon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.{
2+
.name = "Fluent",
3+
.version = "2.1.0",
4+
.paths = .{
5+
"fluent.zig",
6+
"LICENSE",
7+
"README.md",
8+
"build.zig.zon",
9+
"build.zig",
10+
},
11+
}

0 commit comments

Comments
 (0)