Relative cache dir and build prefix
The purpose of this changeset is to allow the user to override the default zig-cache and zig-out directories.
The next step is to add the ZIG_INSTALL_DIR environment variable, so that both zig-cache and zig-out can be overridden using environment variables. I'm not sure if this is the correct way, however.
Some issues:
-
I used
var zig_cache = &@as([]const u8, "zig_cache")to store a string literal in a mutable variable, but I'm not sure if there is a better way. -
zig fmthavezig-cacheandzig-outhard coded, so that these directories are ignored. Using a custom cache directory,zig fmtmay modify the cache entries. -
Some user may depending on the current behavior for relative
--cache-dirand--prefix. However in this case it possible to do (like in theciscripts):export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"By the way,
shellhardensuggests to use$PWDinstead of$(pwd).
I would like to add some tests. Should I add them to test/cli.zig?
Closing abandoned PR (CI checks failing).