]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Context: move cpp_stderr and convert to std::string
authorThomas Otto <thomas.otto@pdv-fs.de>
Sat, 25 Jan 2020 10:02:07 +0000 (11:02 +0100)
committerThomas Otto <thomas.otto@pdv-fs.de>
Mon, 17 Feb 2020 21:06:17 +0000 (22:06 +0100)
src/Context.hpp
src/ccache.cpp
src/legacy_globals.cpp
src/legacy_globals.hpp

index 74eb4e30eac1b17008486c29233d8a67c5349a95..b6e7e85dee222342e776895a8931079668a10b18 100644 (file)
@@ -75,4 +75,7 @@ struct Context : NonCopyable
 
   // The name of the temporary preprocessed file.
   std::string i_tmpfile;
+
+  // The name of the cpp stderr file.
+  std::string cpp_stderr;
 };
index d7f4f60a9f5a943bc2ce96e171e878e8216e5ec8..3388d01e2df887fc4472ffe81ab2e3b5e7b4470f 100644 (file)
@@ -1222,7 +1222,7 @@ to_cache(Context& ctx,
 
   // Merge stderr from the preprocessor (if any) and stderr from the real
   // compiler into tmp_stderr.
-  if (cpp_stderr) {
+  if (!ctx.cpp_stderr.empty()) {
     char* tmp_stderr2 = format("%s.2", tmp_stderr);
     if (x_rename(tmp_stderr, tmp_stderr2)) {
       cc_log("Failed to rename %s to %s: %s",
@@ -1233,9 +1233,9 @@ to_cache(Context& ctx,
       failed();
     }
 
-    int fd_cpp_stderr = open(cpp_stderr, O_RDONLY | O_BINARY);
+    int fd_cpp_stderr = open(ctx.cpp_stderr.c_str(), O_RDONLY | O_BINARY);
     if (fd_cpp_stderr == -1) {
-      cc_log("Failed opening %s: %s", cpp_stderr, strerror(errno));
+      cc_log("Failed opening %s: %s", ctx.cpp_stderr.c_str(), strerror(errno));
       stats_update(STATS_ERROR);
       failed();
     }
@@ -1472,7 +1472,7 @@ get_result_name_from_cpp(Context& ctx, struct args* args, struct hash* hash)
   } else {
     // If we are using the CPP trick, we need to remember this stderr data and
     // output it just before the main stderr from the compiler pass.
-    cpp_stderr = path_stderr;
+    ctx.cpp_stderr = from_cstr(path_stderr);
     hash_delimiter(hash, "runsecondcpp");
     hash_string(hash, "false");
   }
@@ -3531,7 +3531,6 @@ cc_reset()
   }
   free_and_nullify(ignore_headers);
   ignore_headers_len = 0;
-  free_and_nullify(cpp_stderr);
 }
 
 // Make a copy of stderr that will not be cached, so things like distcc can
index 0359c8756abfacc5b3e438b62948ac51b3bd2a91..c5ac740287cd7dee19821bc6e5138ea5739743e8 100644 (file)
@@ -24,9 +24,6 @@ char** ignore_headers;
 // Size of headers to ignore list.
 size_t ignore_headers_len;
 
-// The name of the cpp stderr file.
-char* cpp_stderr;
-
 // The stats file to use for the manifest.
 char* manifest_stats_file;
 
index b6a695b063563cf25750f93402162b3a48270023..acfce56be451f70a4b7b5d9fe348c9793df3c9d4 100644 (file)
@@ -34,8 +34,6 @@ extern char** ignore_headers;
 
 extern size_t ignore_headers_len;
 
-extern char* cpp_stderr;
-
 extern char* manifest_stats_file;
 
 extern enum guessed_compiler guessed_compiler;