From ce9d6902d8bf68395e71fddde7cce96ede74655d Mon Sep 17 00:00:00 2001 From: Cameron Reed Date: Fri, 1 Nov 2024 14:43:31 -0600 Subject: [PATCH] Make it possible to use as a dependency --- build.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 8a4992d..17144e6 100644 --- a/build.zig +++ b/build.zig @@ -3,7 +3,7 @@ const std = @import("std"); // Although this function looks imperative, note that its job is to // declaratively construct a build graph that will be executed by an external // runner. -pub fn build(b: *std.Build) void { +pub fn build(b: *std.Build) !void { // Standard target options allows the person running `zig build` to choose // what target to build for. Here we do not override the defaults, which // means any target is allowed, and the default is native. Other options @@ -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 zigjson_module = b.createModule(.{ + .root_source_file = b.path("src/root.zig"), + }); + + try b.modules.put(b.dupe("zigjson"), zigjson_module); + const lib = b.addStaticLibrary(.{ .name = "zigjson", // In this case the main source file is merely a path, however, in more