feat: allow lib use as git-submodule
This commit is contained in:
parent
6c81608c59
commit
2af9c351bc
24
build.zig
24
build.zig
|
@ -51,3 +51,27 @@ pub fn build(b: *std.Build) void {
|
|||
const test_step = b.step("test", "Run library tests");
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue