From 3a6d0245391b7dd7ea13a9b5b3204cce2fef2d24 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Fri, 10 May 2024 19:31:51 +0200 Subject: [PATCH] add module function --- build.zig | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/build.zig b/build.zig index ca40a07..54bbca0 100644 --- a/build.zig +++ b/build.zig @@ -1,18 +1,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 { - // 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 - // for restricting supported target set are available. const target = b.standardTargetOptions(.{}); - - // Standard optimization options allow the person running `zig build` to select - // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not - // set a preferred release mode, allowing the user to decide how to optimize. const optimize = b.standardOptimizeOption(.{}); // Main executable @@ -68,9 +57,7 @@ pub fn build(b: *std.Build) void { test_step.dependOn(&run_bdf_unit_tests.step); // Module - _ = b.addModule("binfon", .{ - .root_source_file = .{ .path = "src/lib.zig" }, - }); + addModule(b); // Library const libbinfon = buildLibrary(b, .{ @@ -82,6 +69,13 @@ pub fn build(b: *std.Build) void { b.getInstallStep().dependOn(&libzimalloc_install.step); } +/// Module function for depending on the binfon module +pub fn addModule(b: *std.Build) void { + _ = b.addModule("binfon", .{ + .root_source_file = .{ .path = "src/lib.zig" }, + }); +} + const ModuleOptions = struct { target: std.Build.ResolvedTarget, optimize: std.builtin.Mode,