summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2025-04-13 16:50:52 -0400
committerRobby Zambito <contact@robbyzambito.me>2025-04-13 17:14:18 -0400
commit23f7ad8f94d6e0a260a9fd6e78b55e5c9e18bec8 (patch)
tree29398bff317af73597a1d538b9ebeab79a46dbb9 /build.zig
parent8779b2914948f0c8e0b1e420cc44ffa46294752f (diff)
Break out the impl to a lib
This will make it easier to make a C library.
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig18
1 files changed, 17 insertions, 1 deletions
diff --git a/build.zig b/build.zig
index b6d15a4..a45ac7c 100644
--- a/build.zig
+++ b/build.zig
@@ -15,6 +15,12 @@ pub fn build(b: *std.Build) void {
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
+ const lib_mod = b.createModule(.{
+ .root_source_file = b.path("src/root.zig"),
+ .target = target,
+ .optimize = optimize,
+ });
+
// We will also create a module for our other entry point, 'main.zig'.
const exe_mod = b.createModule(.{
// `root_source_file` is the Zig "entry point" of the module. If a module
@@ -26,9 +32,19 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
- exe_mod.addImport("network", b.dependency("network", .{}).module("network"));
+ lib_mod.addImport("network", b.dependency("network", .{}).module("network"));
+
+ exe_mod.addImport("zaprus", lib_mod);
exe_mod.addImport("clap", b.dependency("clap", .{}).module("clap"));
+ const lib = b.addLibrary(.{
+ .linkage = .static,
+ .name = "zaprus",
+ .root_module = lib_mod,
+ });
+
+ b.installArtifact(lib);
+
// This creates another `std.Build.Step.Compile`, but this one builds an executable
// rather than a static library.
const exe = b.addExecutable(.{