feat: allow lib use as git-submodule

This commit is contained in:
Rekai Nyangadzayi Musuka 2023-07-17 23:15:59 -05:00
parent 6c81608c59
commit 2af9c351bc
1 changed files with 24 additions and 0 deletions

View File

@ -51,3 +51,27 @@ pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Run library tests"); const test_step = b.step("test", "Run library tests");
test_step.dependOn(&run_lib_tests.step); test_step.dependOn(&run_lib_tests.step);
} }
/// `arm32` will expect the depender to supply the `zba-util` library via the package maanger
pub fn module(b: *std.Build) *std.Build.Module {
const bitfield = b.createModule(.{ .source_file = .{ .path = path("/lib/bitfield.zig") }, .dependencies = &.{} });
const zba_util = b.dependency("zba-util", .{}).module("zba-util");
return b.createModule(.{
.source_file = .{ .path = path("/src/lib.zig") },
.dependencies = &.{
.{ .name = "zba-util", .module = zba_util },
.{ .name = "bitfield", .module = bitfield },
},
});
}
// https://github.com/MasterQ32/SDL.zig/blob/4d565b54227b862c1540719e0e21a36d649e87d5/build.zig#L114-L120
fn path(comptime suffix: []const u8) []const u8 {
if (suffix[0] != '/') @compileError("relToPath requires an absolute path!");
return comptime blk: {
const root_dir = std.fs.path.dirname(@src().file) orelse ".";
break :blk root_dir ++ suffix;
};
}