remove --zig-install-prefix arg now that we find std at runtime

This commit is contained in:
Andrew Kelley 2018-04-12 11:00:11 -04:00
parent c43f77f109
commit 7b2cb7e679
3 changed files with 20 additions and 62 deletions

View File

@ -39,33 +39,19 @@ pub fn findZigLibDir(allocator: &mem.Allocator) ![]u8 {
};
}
// TODO look in hard coded installation path from configuration
//if (ZIG_INSTALL_PREFIX != nullptr) {
// if (test_zig_install_prefix(buf_create_from_str(ZIG_INSTALL_PREFIX), out_path)) {
// return 0;
// }
//}
return error.FileNotFound;
}
pub fn resolveZigLibDir(allocator: &mem.Allocator, zig_install_prefix_arg: ?[]const u8) ![]u8 {
if (zig_install_prefix_arg) |zig_install_prefix| {
return testZigInstallPrefix(allocator, zig_install_prefix) catch |err| {
warn("No Zig installation found at prefix {}: {}\n", zig_install_prefix_arg, @errorName(err));
return error.ZigInstallationNotFound;
};
} else {
return findZigLibDir(allocator) catch |err| {
warn(
\\Unable to find zig lib directory: {}.
\\Reinstall Zig or use --zig-install-prefix.
\\
,
@errorName(err)
);
pub fn resolveZigLibDir(allocator: &mem.Allocator) ![]u8 {
return findZigLibDir(allocator) catch |err| {
warn(
\\Unable to find zig lib directory: {}.
\\Reinstall Zig or use --zig-install-prefix.
\\
,
@errorName(err)
);
return error.ZigLibDirNotFound;
};
}
return error.ZigLibDirNotFound;
};
}

View File

@ -106,7 +106,6 @@ const usage_build =
\\ --cache-dir [path] Override path to cache directory
\\ --verbose Print commands before executing them
\\ --prefix [path] Override default install prefix
\\ --zig-install-prefix [path] Override directory where zig thinks it is installed
\\
\\Project-Specific Options:
\\
@ -132,7 +131,6 @@ const args_build_spec = []Flag {
Flag.Arg1("--cache-dir"),
Flag.Bool("--verbose"),
Flag.Arg1("--prefix"),
Flag.Arg1("--zig-install-prefix"),
Flag.Arg1("--build-file"),
Flag.Arg1("--cache-dir"),
@ -163,7 +161,7 @@ fn cmdBuild(allocator: &Allocator, args: []const []const u8) !void {
os.exit(0);
}
const zig_lib_dir = try introspect.resolveZigLibDir(allocator, flags.single("zig-install-prefix") ?? null);
const zig_lib_dir = try introspect.resolveZigLibDir(allocator);
defer allocator.free(zig_lib_dir);
const zig_std_dir = try os.path.join(allocator, zig_lib_dir, "std");
@ -230,10 +228,6 @@ fn cmdBuild(allocator: &Allocator, args: []const []const u8) !void {
try build_args.append(build_file_dirname);
try build_args.append(full_cache_dir);
if (flags.single("zig-install-prefix")) |zig_install_prefix| {
try build_args.append(zig_install_prefix);
}
var proc = try os.ChildProcess.init(build_args.toSliceConst(), allocator);
defer proc.deinit();
@ -296,7 +290,6 @@ const usage_build_generic =
\\ --verbose-ir Turn on compiler debug output for Zig IR
\\ --verbose-llvm-ir Turn on compiler debug output for LLVM IR
\\ --verbose-cimport Turn on compiler debug output for C imports
\\ --zig-install-prefix [path] Override directory where zig thinks it is installed
\\ -dirafter [dir] Same as -isystem but do it last
\\ -isystem [dir] Add additional search path for other .h files
\\ -mllvm [arg] Additional arguments to forward to LLVM's option processing
@ -357,7 +350,6 @@ const args_build_generic = []Flag {
Flag.Bool("--verbose-ir"),
Flag.Bool("--verbose-llvm-ir"),
Flag.Bool("--verbose-cimport"),
Flag.Arg1("--zig-install-prefix"),
Flag.Arg1("-dirafter"),
Flag.ArgMergeN("-isystem", 1),
Flag.Arg1("-mllvm"),
@ -500,9 +492,7 @@ fn buildOutputType(allocator: &Allocator, args: []const []const u8, out_type: Mo
};
defer allocator.free(full_cache_dir);
const zig_lib_dir = introspect.resolveZigLibDir(allocator, flags.single("zig-install-prefix") ?? null) catch {
os.exit(1);
};
const zig_lib_dir = introspect.resolveZigLibDir(allocator) catch os.exit(1);
defer allocator.free(zig_lib_dir);
var module =

View File

@ -54,7 +54,6 @@ static int usage(const char *arg0) {
" --verbose-ir turn on compiler debug output for Zig IR\n"
" --verbose-llvm-ir turn on compiler debug output for LLVM IR\n"
" --verbose-cimport turn on compiler debug output for C imports\n"
" --zig-install-prefix [path] override directory where zig thinks it is installed\n"
" -dirafter [dir] same as -isystem but do it last\n"
" -isystem [dir] add additional search path for other .h files\n"
" -mllvm [arg] additional arguments to forward to LLVM's option processing\n"
@ -199,23 +198,14 @@ static int find_zig_lib_dir(Buf *out_path) {
return ErrorFileNotFound;
}
static Buf *resolve_zig_lib_dir(const char *zig_install_prefix_arg) {
static Buf *resolve_zig_lib_dir(void) {
int err;
Buf *result = buf_alloc();
if (zig_install_prefix_arg == nullptr) {
if ((err = find_zig_lib_dir(result))) {
fprintf(stderr, "Unable to find zig lib directory. Reinstall Zig or use --zig-install-prefix.\n");
exit(EXIT_FAILURE);
}
return result;
if ((err = find_zig_lib_dir(result))) {
fprintf(stderr, "Unable to find zig lib directory\n");
exit(EXIT_FAILURE);
}
Buf *zig_lib_dir_buf = buf_create_from_str(zig_install_prefix_arg);
if (test_zig_install_prefix(zig_lib_dir_buf, result)) {
return result;
}
fprintf(stderr, "No Zig installation found at prefix: %s\n", zig_install_prefix_arg);
exit(EXIT_FAILURE);
return result;
}
enum Cmd {
@ -299,7 +289,6 @@ int main(int argc, char **argv) {
const char *libc_include_dir = nullptr;
const char *msvc_lib_dir = nullptr;
const char *kernel32_lib_dir = nullptr;
const char *zig_install_prefix = nullptr;
const char *dynamic_linker = nullptr;
ZigList<const char *> clang_argv = {0};
ZigList<const char *> llvm_argv = {0};
@ -359,17 +348,12 @@ int main(int argc, char **argv) {
} else if (i + 1 < argc && strcmp(argv[i], "--cache-dir") == 0) {
cache_dir = argv[i + 1];
i += 1;
} else if (i + 1 < argc && strcmp(argv[i], "--zig-install-prefix") == 0) {
args.append(argv[i]);
i += 1;
zig_install_prefix = argv[i];
args.append(zig_install_prefix);
} else {
args.append(argv[i]);
}
}
Buf *zig_lib_dir_buf = resolve_zig_lib_dir(zig_install_prefix);
Buf *zig_lib_dir_buf = resolve_zig_lib_dir();
Buf *zig_std_dir = buf_alloc();
os_path_join(zig_lib_dir_buf, buf_create_from_str("std"), zig_std_dir);
@ -590,8 +574,6 @@ int main(int argc, char **argv) {
msvc_lib_dir = argv[i];
} else if (strcmp(arg, "--kernel32-lib-dir") == 0) {
kernel32_lib_dir = argv[i];
} else if (strcmp(arg, "--zig-install-prefix") == 0) {
zig_install_prefix = argv[i];
} else if (strcmp(arg, "--dynamic-linker") == 0) {
dynamic_linker = argv[i];
} else if (strcmp(arg, "-isystem") == 0) {
@ -803,7 +785,7 @@ int main(int argc, char **argv) {
full_cache_dir);
}
Buf *zig_lib_dir_buf = resolve_zig_lib_dir(zig_install_prefix);
Buf *zig_lib_dir_buf = resolve_zig_lib_dir();
CodeGen *g = codegen_create(zig_root_source_file, target, out_type, build_mode, zig_lib_dir_buf);
codegen_set_out_name(g, buf_out_name);