diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-09-26 00:30:51 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-09-26 00:30:51 -0400 |
| commit | 4637e8f9699af9c3c6cf4df50ef5bb67c7a318a4 (patch) | |
| tree | afb9731e10cef9d192560b52cd9ae2cf179775c4 /src/compiler.cpp | |
| parent | dc7016344eeb3ba2d58f80968c3df9503e7c72e7 (diff) | |
| download | zig-4637e8f9699af9c3c6cf4df50ef5bb67c7a318a4.tar.gz zig-4637e8f9699af9c3c6cf4df50ef5bb67c7a318a4.zip | |
zig additionally looks for lib/std/std.zig
previously zig would search up directory parents for
lib/zig/std/std.zig. It still does that, but now it also accepts
lib/std/std.zig. This will probably be how we start shipping windows
.zip files, since the extra directory is pointless.
It also means you can run zig binaries from subdirectories of the zig
source tree without lib files being installed.
Diffstat (limited to 'src/compiler.cpp')
| -rw-r--r-- | src/compiler.cpp | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/src/compiler.cpp b/src/compiler.cpp index 5d401f1851..50be7416b2 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -130,37 +130,35 @@ Error get_compiler_id(Buf **result) { } static bool test_zig_install_prefix(Buf *test_path, Buf *out_zig_lib_dir) { - Buf lib_buf = BUF_INIT; - buf_init_from_str(&lib_buf, "lib"); - - Buf zig_buf = BUF_INIT; - buf_init_from_str(&zig_buf, "zig"); - - Buf std_buf = BUF_INIT; - buf_init_from_str(&std_buf, "std"); - - Buf std_zig_buf = BUF_INIT; - buf_init_from_str(&std_zig_buf, "std.zig"); - - Buf test_lib_dir = BUF_INIT; - Buf test_zig_dir = BUF_INIT; - Buf test_std_dir = BUF_INIT; - Buf test_index_file = BUF_INIT; - - os_path_join(test_path, &lib_buf, &test_lib_dir); - os_path_join(&test_lib_dir, &zig_buf, &test_zig_dir); - os_path_join(&test_zig_dir, &std_buf, &test_std_dir); - os_path_join(&test_std_dir, &std_zig_buf, &test_index_file); - - int err; - bool exists; - if ((err = os_file_exists(&test_index_file, &exists))) { - exists = false; + { + Buf *test_zig_dir = buf_sprintf("%s" OS_SEP "lib" OS_SEP "zig", buf_ptr(test_path)); + Buf *test_index_file = buf_sprintf("%s" OS_SEP "std" OS_SEP "std.zig", buf_ptr(test_zig_dir)); + int err; + bool exists; + if ((err = os_file_exists(test_index_file, &exists))) { + exists = false; + } + if (exists) { + buf_init_from_buf(out_zig_lib_dir, test_zig_dir); + return true; + } } - if (exists) { - buf_init_from_buf(out_zig_lib_dir, &test_zig_dir); - return true; + + // Also try without "zig" + { + Buf *test_zig_dir = buf_sprintf("%s" OS_SEP "lib", buf_ptr(test_path)); + Buf *test_index_file = buf_sprintf("%s" OS_SEP "std" OS_SEP "std.zig", buf_ptr(test_zig_dir)); + int err; + bool exists; + if ((err = os_file_exists(test_index_file, &exists))) { + exists = false; + } + if (exists) { + buf_init_from_buf(out_zig_lib_dir, test_zig_dir); + return true; + } } + return false; } |
