From 4d8467fafc5966f884325d1e3b7dae34c420fa10 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 7 Mar 2019 13:16:52 -0500 Subject: [PATCH] better behavior when cache dir unavailable and choose different manifest dir for local cache to avoid conflict with zig build --- src/codegen.cpp | 5 ++++- src/error.cpp | 1 + src/error.hpp | 1 + src/os.cpp | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index 910f31cc040c5f773a62bc876f78c56ef5111772..d05f780440e4b8dd9dcb15b5b63f7dacf7eef99d 100644 --- a/src/codegen.cpp +++ b/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)); } diff --git a/src/error.cpp b/src/error.cpp index 17d44bffedb41f1b02a3461394442a3a5d6504d8..38d62512f6b67029a3683d0110e8babf520c52a2 100644 --- a/src/error.cpp +++ b/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"; diff --git a/src/error.hpp b/src/error.hpp index 6d9727a2179689d4fe0a8f0fb0c96b4d378dd7d0..8a806d3e5f4e9941abdf23ec675484e67e5b5ac2 100644 --- a/src/error.hpp +++ b/src/error.hpp @@ -31,6 +31,7 @@ enum Error { ErrorCCompileErrors, ErrorEndOfFile, ErrorIsDir, + ErrorNotDir, ErrorUnsupportedOperatingSystem, ErrorSharingViolation, ErrorPipeBusy, diff --git a/src/os.cpp b/src/os.cpp index ac3bbc721cced62c9f0eb6bf84154c5485e3422f..355f9167c1b4514e446b36d307cd84bf9c834b76 100644 --- a/src/os.cpp +++ b/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; } -- 2.54.0