zig icon indicating copy to clipboard operation
zig copied to clipboard

Relative cache dir and build prefix

Open perillo opened this issue 2 years ago • 1 comments

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 fmt have zig-cache and zig-out hard coded, so that these directories are ignored. Using a custom cache directory, zig fmt may modify the cache entries.

  • Some user may depending on the current behavior for relative --cache-dir and --prefix. However in this case it possible to do (like in the ci scripts): export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"

    By the way, shellharden suggests to use $PWD instead of $(pwd).

perillo avatar Mar 11 '23 18:03 perillo

I would like to add some tests. Should I add them to test/cli.zig?

perillo avatar Mar 11 '23 20:03 perillo

Closing abandoned PR (CI checks failing).

andrewrk avatar Jun 17 '23 23:06 andrewrk