Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ZIGUP_INSTALL_PATH environment variable #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion zigup.zig
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,14 @@ fn help() void {
\\ zigup fetch-index download and print the download index json
\\
\\Common Options:
\\ --install-dir DIR override the default install location
\\ --install-dir DIR override the default install location, overrides ZIGUP_INSTALL_PATH
\\ --path-link PATH path to the `zig` symlink that points to the default compiler
\\ this will typically be a file path within a PATH directory so
\\ that the user can just run `zig`
\\
\\Environment Variables:
\\ ZIGUP_INSTALL_PATH override the default install location
\\
) catch unreachable;
}

Expand All @@ -231,6 +234,18 @@ pub fn main2() !u8 {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
const allocator = arena.allocator();

const zigup_install_path = std.process.getEnvVarOwned(allocator, "ZIGUP_INSTALL_PATH") catch |err|
switch (err) {
error.EnvironmentVariableNotFound => null,
else => unreachable,
};
defer if (zigup_install_path) |path| {
allocator.free(path);
};
if (zigup_install_path) |path| {
global_optional_install_dir = path;
}

const args_array = try std.process.argsAlloc(allocator);
// no need to free, os will do it
//defer std.process.argsFree(allocator, argsArray);
Expand Down