]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Context: move manifest_path and converted to std::string
authorThomas Otto <thomas.otto@pdv-fs.de>
Sat, 25 Jan 2020 09:46:54 +0000 (10:46 +0100)
committerThomas Otto <thomas.otto@pdv-fs.de>
Mon, 17 Feb 2020 20:39:19 +0000 (21:39 +0100)
src/Context.hpp
src/ccache.cpp
src/legacy_globals.cpp
src/legacy_globals.hpp

index 1e7727f0e81aebdeb45a5763292284c8a925a48f..617a09a7c195d431b5014c01f992a44975a0fc4b 100644 (file)
@@ -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;
 };
index 8f9cbe998ab8217f1b17056c48d52e2947948346..c9c015a19276a7d6956af4d1d3205671775f05aa 100644 (file)
@@ -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;
     }
index aba2231d1489f3dd32b7197e0fea60036dbf0e1f..9afb079fc61428c8c875ddbfc1733f0f9541e665 100644 (file)
 
 #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;
index 0ee048d47ae1539d6672b6dafd0d9cda543ef843..b01b6f4450df85dfc2c84a1584f6f6d191a228ce 100644 (file)
@@ -30,8 +30,6 @@
 
 extern unsigned lock_staleness_limit;
 
-extern char* manifest_path;
-
 extern time_t time_of_compilation;
 
 extern std::unordered_map<std::string, digest> g_included_files;