]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Convert ArgsInfo::output_dep to fs::path
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 2 Jun 2024 10:59:45 +0000 (12:59 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 30 Jun 2024 15:18:50 +0000 (17:18 +0200)
src/ccache/ArgsInfo.hpp
src/ccache/Depfile.cpp
src/ccache/argprocessing.cpp

index daec3e6e75afdfd16e0cfb3a77a27c1191c7b881..d73f4a44bab1b512a693a786d9f37e8adceac75d 100644 (file)
@@ -51,7 +51,7 @@ struct ArgsInfo
 
   // The path to the dependency file (implicit or specified with -MFdepfile,
   // -Wp,-MD,depfile or -Wp,-MMD,depfile).
-  std::string output_dep;
+  std::filesystem::path output_dep;
 
   // The path to the stack usage (implicit when using -fstack-usage).
   std::string output_su;
index f69ecbcc4e89487b08c8f415960e649fdc84832c..6018bdc001f86c37c7d6a7c443ca0a574d2219e5 100644 (file)
@@ -26,6 +26,7 @@
 #include <ccache/util/assertions.hpp>
 #include <ccache/util/file.hpp>
 #include <ccache/util/filesystem.hpp>
+#include <ccache/util/format.hpp>
 #include <ccache/util/logging.hpp>
 #include <ccache/util/path.hpp>
 #include <ccache/util/string.hpp>
@@ -99,7 +100,7 @@ make_paths_relative_in_output_dep(const Context& ctx)
     return; // nothing to do
   }
 
-  const std::string& output_dep = ctx.args_info.output_dep;
+  const auto& output_dep = ctx.args_info.output_dep;
   const auto content = util::read_file<std::string>(output_dep);
   if (!content) {
     LOG("Failed to read dependency file {}: {}", output_dep, content.error());
index b6d3d870de63a31bf356fa2c54bc7869b4665b73..8687ca0ed83a5de798a49375471ed2c6400b35d9 100644 (file)
@@ -773,15 +773,14 @@ process_option_arg(const Context& ctx,
 
     if (state.output_dep_origin <= OutputDepOrigin::mf) {
       state.output_dep_origin = OutputDepOrigin::mf;
-      args_info.output_dep =
-        util::pstr(core::make_relative_path(ctx, dep_file));
+      args_info.output_dep = core::make_relative_path(ctx, dep_file);
     }
     // Keep the format of the args the same.
     if (separate_argument) {
       state.dep_args.push_back("-MF");
       state.dep_args.push_back(args_info.output_dep);
     } else {
-      state.dep_args.push_back("-MF" + args_info.output_dep);
+      state.dep_args.push_back(FMT("-MF{}", args_info.output_dep));
     }
     return Statistic::none;
   }
@@ -1579,8 +1578,7 @@ process_args(Context& ctx)
 
   if (args_info.generating_dependencies) {
     if (state.output_dep_origin == OutputDepOrigin::none) {
-      args_info.output_dep =
-        util::pstr(util::with_extension(args_info.output_obj, ".d"));
+      args_info.output_dep = util::with_extension(args_info.output_obj, ".d");
       if (!config.run_second_cpp()) {
         // If we're compiling preprocessed code we're sending dep_args to the
         // preprocessor so we need to use -MF to write to the correct .d file