From 08bf0f9201a0cd6d317e3f73a26d245eedfd1121 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Thu, 15 Dec 2022 03:42:56 -0400 Subject: [PATCH] fix: make dependency path strings relative --- build.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index 7281e23..461252e 100644 --- a/build.zig +++ b/build.zig @@ -1,18 +1,23 @@ const std = @import("std"); +fn path(comptime suffix: []const u8) []const u8 { + if (suffix[0] == '/') @compileError("expected a relative path"); + return comptime (std.fs.path.dirname(@src().file) orelse ".") ++ std.fs.path.sep_str ++ suffix; +} + const pkgs = struct { const Pkg = std.build.Pkg; pub const gdbstub: Pkg = .{ .name = "gdbstub", - .source = .{ .path = "src/lib.zig" }, + .source = .{ .path = path("src/lib.zig") }, .dependencies = &[_]Pkg{network}, }; // https://github.com/MasterQ32/zig-network pub const network: Pkg = .{ .name = "network", - .source = .{ .path = "lib/zig-network/network.zig" }, + .source = .{ .path = path("lib/zig-network/network.zig") }, }; };