#Help: custom exe output path

1 messages · Page 1 of 1 (latest)

pearl robin
#

I have been trying to figure this out for about 90 minutes now and all I'm trying to do is set where my exe gets created from build.zig: I want it in the project root, not /zig-out/bin. I have been looking at source and std docs and getting bad advice from LLMs to no avail.

@winged compass
#zig message

If I am reading this right, this is a way to get the install path, but it looks unclear how to set it, as its type is GeneratedFile, which in turn has a .path field that says it has to get set during the step's make()... but...

"A file that is generated by a build step. This struct is an interface that is meant to be used with @fieldParentPtr to implement the actual path logic."

Which makes it sound like maybe it could be used to change the path, though I'm fuzzy on how I would go about that.

I was able to get it to go to zig-out and skip bin by setting a ".prefix" somewhere, but not zig-out itself. Any advice is much appreciated.

tacit bramble
#

zig build --prefix .

#

should work

#

there are also other functions to manipulate build artifacts but the above command is enough if you just want the exe to be elsewhere

pearl robin
#

😭 I ended up writing a powershell script to run build zig and delete the extra folder
good enough

waxen grotto
#

as @tacit bramble said, the install path is set via the cli --prefix, inside build.zig you only have access to install paths relative to the prefix.