#Zig build profile-specific output path

1 messages · Page 1 of 1 (latest)

sterile spire
#

Hello! While using Zig I’ve found it slightly annoying that regardless of what profile I use Zig will overwrite any previous builds without indication of which profile the executable was compiled with.

How does one customize the profile-specific build path of an executable? I’d like to create a result similar to:

zig-out/
- ReleaseSafe/ 
- ReleaseSmall
- Debug
viral musk
#

Not sure what the right way is, if any, but this works:

const dir = std.fs.path.join(b.allocator,  &.{ b.exe_dir, @tagName(myexe.build_mode) }) catch unreachable;
myexe.setOutputDir(dir);
#

which puts it in zig-out/bin/ReleaseFast etc

You can replace b.exe_dir with zig-out if you want your specific structure

sterile spire
#

@viral musk thank you!

dusty topaz
#

You can do also zig build -p NAME which will use ./NAME as the output directory, from the CLI.

#

(p for 'prefix')