Tested on Windows, I've not tested on other platforms.
When the @src builtin is called from build.zig (or any code that runs during zig build), in the returned SourceLocation the .file field appears to be always an absolute path, e.g.:
D:\devspace\myproject\build.zig
But when called in project code, it only returns the name of the file and not a full path:
projectcode.zig
The case where I hit this was writing a test for some of my build utils, inside build.zig. The functionality works when calling zig build but if I call zig test build.zig then the different value returned by @src() causes my tests to fail.
Tested on Windows, I've not tested on other platforms.
When the
@src
builtin is called frombuild.zig
(or any code that runs duringzig build
), in the returnedSourceLocation
the.file
field appears to be always an absolute path, e.g.:D:\devspace\myproject\build.zig
But when called in project code, it only returns the name of the file and not a full path:
projectcode.zig
The case where I hit this was writing a test for some of my build utils, inside
build.zig
. The functionality works when callingzig build
but if I callzig test build.zig
then the different value returned by@src()
causes my tests to fail.