add module function

This commit is contained in:
Hamcha 2024-05-10 19:31:51 +02:00
parent af2f9fe9c6
commit 3a6d024539
Signed by: hamcha
GPG key ID: 1669C533B8CF6D89

View file

@ -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,