From 43b3ca386d63cc274805bbd2a0bd8622684a1bb6 Mon Sep 17 00:00:00 2001 From: "Gu://em_" Date: Tue, 9 Jun 2026 21:38:13 +0200 Subject: [PATCH] Added an option to compile as a dynamic library --- build.zig | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 21d62ec..a4a0a64 100644 --- a/build.zig +++ b/build.zig @@ -1,6 +1,20 @@ const std = @import("std"); pub fn build(b: *std.Build) void { + + // Compilation options + const opt_shared = b.option( + bool, + "shared", + "Build as a dynamic (shared) library", + ) orelse false; + + const linkage: std.builtin.LinkMode = if (opt_shared) + .static + else + .dynamic; + + // Configuration const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); @@ -14,7 +28,7 @@ pub fn build(b: *std.Build) void { // Create library const lib = b.addLibrary(.{ .name = "reticulum-zero", - .linkage = .static, + .linkage = linkage, .root_module = root_module, });