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) {...@@ -9201,11 +9201,14 @@ void codegen_build_and_link(CodeGen *g) {
9201 bool any_c_objects_generated;9201 bool any_c_objects_generated;
9202 if (g->enable_cache) {9202 if (g->enable_cache) {
9203 Buf *manifest_dir = buf_alloc();9203 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
9206 if ((err = check_cache(g, manifest_dir, &digest, &any_c_objects_generated))) {9206 if ((err = check_cache(g, manifest_dir, &digest, &any_c_objects_generated))) {
9207 if (err == ErrorCacheUnavailable) {9207 if (err == ErrorCacheUnavailable) {
9208 // message already printed9208 // 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));
9209 } else {9212 } else {
9210 fprintf(stderr, "Unable to check cache: %s\n", err_str(err));9213 fprintf(stderr, "Unable to check cache: %s\n", err_str(err));
9211 }9214 }
src/error.cpp+1
...@@ -29,6 +29,7 @@ const char *err_str(Error err) {...@@ -29,6 +29,7 @@ const char *err_str(Error err) {
29 case ErrorCCompileErrors: return "C compile errors";29 case ErrorCCompileErrors: return "C compile errors";
30 case ErrorEndOfFile: return "end of file";30 case ErrorEndOfFile: return "end of file";
31 case ErrorIsDir: return "is directory";31 case ErrorIsDir: return "is directory";
32 case ErrorNotDir: return "not a directory";
32 case ErrorUnsupportedOperatingSystem: return "unsupported operating system";33 case ErrorUnsupportedOperatingSystem: return "unsupported operating system";
33 case ErrorSharingViolation: return "sharing violation";34 case ErrorSharingViolation: return "sharing violation";
34 case ErrorPipeBusy: return "pipe busy";35 case ErrorPipeBusy: return "pipe busy";
src/error.hpp+1
...@@ -31,6 +31,7 @@ enum Error {...@@ -31,6 +31,7 @@ enum Error {
31 ErrorCCompileErrors,31 ErrorCCompileErrors,
32 ErrorEndOfFile,32 ErrorEndOfFile,
33 ErrorIsDir,33 ErrorIsDir,
34 ErrorNotDir,
34 ErrorUnsupportedOperatingSystem,35 ErrorUnsupportedOperatingSystem,
35 ErrorSharingViolation,36 ErrorSharingViolation,
36 ErrorPipeBusy,37 ErrorPipeBusy,
src/os.cpp+2
...@@ -1998,6 +1998,8 @@ Error os_file_open_lock_rw(Buf *full_path, OsFile *out_file) {...@@ -1998,6 +1998,8 @@ Error os_file_open_lock_rw(Buf *full_path, OsFile *out_file) {
1998 return ErrorIsDir;1998 return ErrorIsDir;
1999 case ENOENT:1999 case ENOENT:
2000 return ErrorFileNotFound;2000 return ErrorFileNotFound;
2001 case ENOTDIR:
2002 return ErrorNotDir;
2001 default:2003 default:
2002 return ErrorFileSystem;2004 return ErrorFileSystem;
2003 }2005 }