Commit 4d8467fafc

Andrew Kelley <andrew@ziglang.org>
2019-03-07 19:16:52
better behavior when cache dir unavailable
and choose different manifest dir for local cache to avoid conflict with zig build
1 parent e2ce00f
src/codegen.cpp
@@ -9201,11 +9201,14 @@ void codegen_build_and_link(CodeGen *g) {
     bool any_c_objects_generated;
     if (g->enable_cache) {
         Buf *manifest_dir = buf_alloc();
-        os_path_join(g->cache_dir, buf_create_from_str("build"), manifest_dir);
+        os_path_join(g->cache_dir, buf_create_from_str("h"), manifest_dir);
 
         if ((err = check_cache(g, manifest_dir, &digest, &any_c_objects_generated))) {
             if (err == ErrorCacheUnavailable) {
                 // message already printed
+            } else if (err == ErrorNotDir) {
+                fprintf(stderr, "Unable to check cache: %s is not a directory\n",
+                    buf_ptr(manifest_dir));
             } else {
                 fprintf(stderr, "Unable to check cache: %s\n", err_str(err));
             }
src/error.cpp
@@ -29,6 +29,7 @@ const char *err_str(Error err) {
         case ErrorCCompileErrors: return "C compile errors";
         case ErrorEndOfFile: return "end of file";
         case ErrorIsDir: return "is directory";
+        case ErrorNotDir: return "not a directory";
         case ErrorUnsupportedOperatingSystem: return "unsupported operating system";
         case ErrorSharingViolation: return "sharing violation";
         case ErrorPipeBusy: return "pipe busy";
src/error.hpp
@@ -31,6 +31,7 @@ enum Error {
     ErrorCCompileErrors,
     ErrorEndOfFile,
     ErrorIsDir,
+    ErrorNotDir,
     ErrorUnsupportedOperatingSystem,
     ErrorSharingViolation,
     ErrorPipeBusy,
src/os.cpp
@@ -1998,6 +1998,8 @@ Error os_file_open_lock_rw(Buf *full_path, OsFile *out_file) {
                     return ErrorIsDir;
                 case ENOENT:
                     return ErrorFileNotFound;
+                case ENOTDIR:
+                    return ErrorNotDir;
                 default:
                     return ErrorFileSystem;
             }