From 5947747533ec9ee63b4598455a281edd5e55b4a9 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 15 Dec 2023 00:48:26 -0600 Subject: [PATCH] chore: allow use as git submodule --- build.zig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/build.zig b/build.zig index e2db1e7..57369de 100644 --- a/build.zig +++ b/build.zig @@ -36,3 +36,19 @@ pub fn build(b: *std.Build) void { const test_step = b.step("test", "Run library tests"); test_step.dependOn(&run_lib_tests.step); } + +pub fn module(b: *std.Build) *std.Build.Module { + return b.createModule(.{ + .source_file = .{ .path = path("/src/lib.zig") }, + .dependencies = &.{}, + }); +} + +// 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; + }; +}