]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Convert ArgsInfo::input_file to fs::path
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 1 Jun 2024 11:05:32 +0000 (13:05 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 30 Jun 2024 15:18:49 +0000 (17:18 +0200)
src/ccache/ArgsInfo.hpp
src/ccache/argprocessing.cpp
src/ccache/ccache.cpp

index 607466ee043223edfb5659732819c29a66a64393..642c1c2d6daafa48c8417a0ed0560ebd1953479e 100644 (file)
@@ -33,7 +33,7 @@ struct ArgsInfo
   std::filesystem::path orig_input_file;
 
   // The source file path, potentially rewritten into relative.
-  std::string input_file;
+  std::filesystem::path input_file;
 
   // Prefix to the input file when adding it to a command line.
   std::string input_file_prefix;
index 9e6dc8f7dfdda56891017effaaf1791168fb92ea..337975ae0f63c0ce39de6faab4ea9210052750b4 100644 (file)
@@ -1311,7 +1311,7 @@ process_args(Context& ctx)
   args_info.orig_input_file = state.input_files.front();
   // Rewrite to relative to increase hit rate.
   args_info.input_file =
-    util::pstr(core::make_relative_path(ctx, args_info.orig_input_file));
+    core::make_relative_path(ctx, args_info.orig_input_file);
 
   // Bail out on too hard combinations of options.
   if (state.found_mf_opt && state.found_wp_md_or_mmd_opt) {
@@ -1474,10 +1474,11 @@ process_args(Context& ctx)
       LOG_RAW("No -c option found");
       // Having a separate statistic for autoconf tests is useful, as they are
       // the dominant form of "called for link" in many cases.
-      return tl::unexpected(args_info.input_file.find("conftest.")
-                                != std::string::npos
-                              ? Statistic::autoconf_test
-                              : Statistic::called_for_link);
+      return tl::unexpected(
+        util::pstr(args_info.input_file).str().find("conftest.")
+            != std::string::npos
+          ? Statistic::autoconf_test
+          : Statistic::called_for_link);
     }
   }
 
index cc2e99d1ff0fc79ac761b8b006823a685db325de..8d3607b4cdda7a01fb539dafe59b5f4d6727045b 100644 (file)
@@ -1285,7 +1285,7 @@ get_result_key_from_cpp(Context& ctx, Args& args, Hash& hash)
   if (ctx.args_info.direct_i_file) {
     // We are compiling a .i or .ii file - that means we can skip the cpp stage
     // and directly form the correct i_tmpfile.
-    preprocessed_path = ctx.args_info.input_file;
+    preprocessed_path = util::pstr(ctx.args_info.input_file);
   } else {
     // Run cpp on the input file to obtain the .i.