From: Thomas Otto Date: Sat, 25 Jan 2020 09:46:54 +0000 (+0100) Subject: Context: move manifest_path and converted to std::string X-Git-Tag: v4.0~613^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1c5ff9a2ae3561bd78760b6ca6199444589376c5;p=thirdparty%2Fccache.git Context: move manifest_path and converted to std::string --- diff --git a/src/Context.hpp b/src/Context.hpp index 1e7727f0e..617a09a7c 100644 --- a/src/Context.hpp +++ b/src/Context.hpp @@ -55,4 +55,8 @@ struct Context : NonCopyable // Full path to the file containing the result // (cachedir/a/b/cdef[...]-size.result). std::string result_path; + + // Full path to the file containing the manifest + // (cachedir/a/b/cdef[...]-size.manifest). + std::string manifest_path; }; diff --git a/src/ccache.cpp b/src/ccache.cpp index 8f9cbe998..c9c015a19 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -1042,7 +1042,7 @@ update_manifest_file(Context& ctx) return; } - auto old_st = Stat::stat(manifest_path); + auto old_st = Stat::stat(ctx.manifest_path); // See comment in get_file_hash_index for why saving of timestamps is forced // for precompiled headers. @@ -1050,15 +1050,15 @@ update_manifest_file(Context& ctx) || ctx.args_info.output_is_precompiled_header; MTR_BEGIN("manifest", "manifest_put"); - cc_log("Adding result name to %s", manifest_path); + cc_log("Adding result name to %s", ctx.manifest_path.c_str()); if (!manifest_put(ctx.config, - manifest_path, + ctx.manifest_path, *ctx.result_name, g_included_files, save_timestamp)) { - cc_log("Failed to add result name to %s", manifest_path); + cc_log("Failed to add result name to %s", ctx.manifest_path.c_str()); } else { - auto st = Stat::stat(manifest_path, Stat::OnError::log); + auto st = Stat::stat(ctx.manifest_path, Stat::OnError::log); stats_update_size(ctx, from_cstr(manifest_stats_file), st.size_on_disk() - old_st.size_on_disk(), @@ -1976,18 +1976,16 @@ calculate_result_name(Context& ctx, char manifest_name_string[DIGEST_STRING_BUFFER_SIZE]; hash_result_as_string(hash, manifest_name_string); - manifest_path = - x_strdup(Util::get_path_in_cache(ctx.config.cache_dir(), - ctx.config.cache_dir_levels(), - manifest_name_string, - ".manifest") - .c_str()); + ctx.manifest_path = Util::get_path_in_cache(ctx.config.cache_dir(), + ctx.config.cache_dir_levels(), + manifest_name_string, + ".manifest"); manifest_stats_file = format( "%s/%c/stats", ctx.config.cache_dir().c_str(), manifest_name_string[0]); - cc_log("Looking for result name in %s", manifest_path); + cc_log("Looking for result name in %s", ctx.manifest_path.c_str()); MTR_BEGIN("manifest", "manifest_get"); - result_name = manifest_get(ctx, manifest_path); + result_name = manifest_get(ctx, ctx.manifest_path); MTR_END("manifest", "manifest_get"); if (result_name) { cc_log("Got result name from manifest"); @@ -3527,7 +3525,6 @@ void cc_reset() { free_and_nullify(included_pch_file); - free_and_nullify(manifest_path); time_of_compilation = 0; for (size_t i = 0; i < ignore_headers_len; i++) { free_and_nullify(ignore_headers[i]); @@ -3819,7 +3816,7 @@ do_cache_compilation(Context& ctx, char* argv[]) cc_log("Hash from manifest doesn't match preprocessor output"); cc_log("Likely reason: different CCACHE_BASEDIRs used"); cc_log("Removing manifest as a safety measure"); - x_unlink(manifest_path); + x_unlink(ctx.manifest_path.c_str()); put_result_in_manifest = true; } diff --git a/src/legacy_globals.cpp b/src/legacy_globals.cpp index aba2231d1..9afb079fc 100644 --- a/src/legacy_globals.cpp +++ b/src/legacy_globals.cpp @@ -18,10 +18,6 @@ #include "legacy_globals.hpp" -// Full path to the file containing the manifest -// (cachedir/a/b/cdef[...]-size.manifest). -char* manifest_path; - // Time of compilation. Used to see if include files have changed after // compilation. time_t time_of_compilation; diff --git a/src/legacy_globals.hpp b/src/legacy_globals.hpp index 0ee048d47..b01b6f445 100644 --- a/src/legacy_globals.hpp +++ b/src/legacy_globals.hpp @@ -30,8 +30,6 @@ extern unsigned lock_staleness_limit; -extern char* manifest_path; - extern time_t time_of_compilation; extern std::unordered_map g_included_files;