From: Joel Rosdahl Date: Sun, 2 Jun 2024 10:59:45 +0000 (+0200) Subject: refactor: Convert ArgsInfo::output_dep to fs::path X-Git-Tag: v4.11~123 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=88ff64af126631aaaca3f2519d40197c485c8724;p=thirdparty%2Fccache.git refactor: Convert ArgsInfo::output_dep to fs::path --- diff --git a/src/ccache/ArgsInfo.hpp b/src/ccache/ArgsInfo.hpp index daec3e6e..d73f4a44 100644 --- a/src/ccache/ArgsInfo.hpp +++ b/src/ccache/ArgsInfo.hpp @@ -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; diff --git a/src/ccache/Depfile.cpp b/src/ccache/Depfile.cpp index f69ecbcc..6018bdc0 100644 --- a/src/ccache/Depfile.cpp +++ b/src/ccache/Depfile.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -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(output_dep); if (!content) { LOG("Failed to read dependency file {}: {}", output_dep, content.error()); diff --git a/src/ccache/argprocessing.cpp b/src/ccache/argprocessing.cpp index b6d3d870..8687ca0e 100644 --- a/src/ccache/argprocessing.cpp +++ b/src/ccache/argprocessing.cpp @@ -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