Skip to content

Commit 68e193a

Browse files
author
Felix "xq" Queißner
committed
Adds diagnostic printing.
1 parent 8207247 commit 68e193a

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

src/BuildInterface.zig

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,25 @@ const ContentWriter = struct {
308308
.dependency,
309309
.src_path,
310310
=> {
311+
311312
// We can safely call getPath2 as we can fully resolve the path
312313
// already
313-
const full_path = path.getPath2(cw.wfs.step.owner, &cw.wfs.step);
314-
315-
std.debug.assert(std.fs.path.isAbsolute(full_path));
314+
const rel_path = path.getPath2(cw.wfs.step.owner, &cw.wfs.step);
315+
316+
const full_path = if (!std.fs.path.isAbsolute(rel_path))
317+
std.fs.cwd().realpathAlloc(cw.wfs.step.owner.allocator, rel_path) catch @panic("oom")
318+
else
319+
rel_path;
320+
321+
if (!std.fs.path.isAbsolute(full_path)) {
322+
const cwd = std.fs.cwd().realpathAlloc(cw.wfs.step.owner.allocator, ".") catch @panic("oom");
323+
std.debug.print("non-absolute path detected for {t}: cwd=\"{f}\" path=\"{f}\"\n", .{
324+
path,
325+
std.zig.fmtString(cwd),
326+
std.zig.fmtString(full_path),
327+
});
328+
@panic("non-absolute path detected!");
329+
}
316330

317331
try writer.print("{f}", .{
318332
fmtPath(full_path),

0 commit comments

Comments
 (0)