authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-07 13:16:52-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-07 13:16:52-05:00
log4d8467fafc5966f884325d1e3b7dae34c420fa10
tree2091e6fcc94ab63ca49a861fe493ddba89d5eeb6
parente2ce00f272acdf3a0b5bdb3f9322aa1c487c483d

better behavior when cache dir unavailable

and choose different manifest dir for local cache to avoid conflict with zig build

4 files changed, 8 insertions(+), 1 deletions(-)

src/codegen.cpp+4-1
......@@ -9201,11 +9201,14 @@ void codegen_build_and_link(CodeGen *g) {
92019201 bool any_c_objects_generated;
92029202 if (g->enable_cache) {
92039203 Buf *manifest_dir = buf_alloc();
9204 os_path_join(g->cache_dir, buf_create_from_str("build"), manifest_dir);
9204 os_path_join(g->cache_dir, buf_create_from_str("h"), manifest_dir);
92059205
92069206 if ((err = check_cache(g, manifest_dir, &digest, &any_c_objects_generated))) {
92079207 if (err == ErrorCacheUnavailable) {
92089208 // message already printed
9209 } else if (err == ErrorNotDir) {
9210 fprintf(stderr, "Unable to check cache: %s is not a directory\n",
9211 buf_ptr(manifest_dir));
92099212 } else {
92109213 fprintf(stderr, "Unable to check cache: %s\n", err_str(err));
92119214 }
src/error.cpp+1
......@@ -29,6 +29,7 @@ const char *err_str(Error err) {
2929 case ErrorCCompileErrors: return "C compile errors";
3030 case ErrorEndOfFile: return "end of file";
3131 case ErrorIsDir: return "is directory";
32 case ErrorNotDir: return "not a directory";
3233 case ErrorUnsupportedOperatingSystem: return "unsupported operating system";
3334 case ErrorSharingViolation: return "sharing violation";
3435 case ErrorPipeBusy: return "pipe busy";
src/error.hpp+1
......@@ -31,6 +31,7 @@ enum Error {
3131 ErrorCCompileErrors,
3232 ErrorEndOfFile,
3333 ErrorIsDir,
34 ErrorNotDir,
3435 ErrorUnsupportedOperatingSystem,
3536 ErrorSharingViolation,
3637 ErrorPipeBusy,
src/os.cpp+2
......@@ -1998,6 +1998,8 @@ Error os_file_open_lock_rw(Buf *full_path, OsFile *out_file) {
19981998 return ErrorIsDir;
19991999 case ENOENT:
20002000 return ErrorFileNotFound;
2001 case ENOTDIR:
2002 return ErrorNotDir;
20012003 default:
20022004 return ErrorFileSystem;
20032005 }