]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Context: move profile_dir
authorThomas Otto <thomas.otto@pdv-fs.de>
Fri, 24 Jan 2020 19:11:24 +0000 (20:11 +0100)
committerThomas Otto <thomas.otto@pdv-fs.de>
Thu, 13 Feb 2020 22:51:43 +0000 (23:51 +0100)
src/ccache.cpp
src/legacy_globals.cpp
src/legacy_globals.hpp
unittest/test_argument_processing.cpp

index 97daf2209c28c54313065a173bf17075b6130bb1..6882717596ae5ebff75374a4ef186b9a9f5110cc 100644 (file)
@@ -1678,8 +1678,8 @@ hash_common_info(Context& ctx,
   // Possibly hash the coverage data file path.
   if (ctx.args_info.generating_coverage && ctx.args_info.profile_arcs) {
     char* dir = x_dirname(ctx.args_info.output_obj.c_str());
-    if (profile_dir) {
-      dir = x_strdup(profile_dir);
+    if (!ctx.args_info.profile_dir.empty()) {
+      dir = x_strdup(ctx.args_info.profile_dir.c_str());
     } else {
       char* real_dir = x_realpath(dir);
       free(dir);
@@ -1926,21 +1926,23 @@ calculate_result_name(Context& ctx,
   // The profile directory can be specified as an argument to
   // -fprofile-generate=, -fprofile-use= or -fprofile-dir=.
   if (profile_generate) {
-    if (!profile_dir) {
-      profile_dir = get_cwd();
+    if (ctx.args_info.profile_dir.empty()) {
+      ctx.args_info.profile_dir = from_cstr(get_cwd());
     }
-    cc_log("Adding profile directory %s to our hash", profile_dir);
+    cc_log("Adding profile directory %s to our hash",
+           ctx.args_info.profile_dir.c_str());
     hash_delimiter(hash, "-fprofile-dir");
-    hash_string(hash, profile_dir);
+    hash_string(hash, ctx.args_info.profile_dir);
   }
 
   if (profile_use) {
     // Calculate gcda name.
-    if (!profile_dir) {
-      profile_dir = get_cwd();
+    if (ctx.args_info.profile_dir.empty()) {
+      ctx.args_info.profile_dir = from_cstr(get_cwd());
     }
     string_view base_name = Util::remove_extension(ctx.args_info.output_obj);
-    std::string gcda_name = fmt::format("{}/{}.gcda", profile_dir, base_name);
+    std::string gcda_name =
+      fmt::format("{}/{}.gcda", ctx.args_info.profile_dir, base_name);
     cc_log("Adding profile data %s to our hash", gcda_name.c_str());
     // Add the gcda to our hash.
     hash_delimiter(hash, "-fprofile-use");
@@ -3550,7 +3552,6 @@ cc_reset(void)
   g_config.clear_and_reset();
 
   free_and_nullify(current_working_dir);
-  free_and_nullify(profile_dir);
   free_and_nullify(included_pch_file);
   args_free(orig_args);
   orig_args = NULL;
@@ -3704,8 +3705,6 @@ do_cache_compilation(Context& ctx, char* argv[])
     failed(); // stats_update is called in cc_process_args.
   }
 
-  profile_dir = x_strdup(ctx.args_info.profile_dir.c_str());
-
   direct_i_file = ctx.args_info.direct_i_file;
   output_is_precompiled_header = ctx.args_info.output_is_precompiled_header;
   profile_use = ctx.args_info.profile_use;
index 58aa782989ae0c243f43578436a8b6376aa311c9..06d51a76289ec7698fd0fa98ffcf402b092428ff 100644 (file)
@@ -58,9 +58,6 @@ char** ignore_headers;
 // Size of headers to ignore list.
 size_t ignore_headers_len;
 
-// Name of the custom profile directory (default: object dirname).
-char* profile_dir;
-
 // The name of the temporary preprocessed file.
 char* i_tmpfile;
 
index 831f3c8ca848be078b2aaf7d755550c050a73918..2e5208278223cc05ce40e5fe1d727df9a56a84ad 100644 (file)
@@ -54,8 +54,6 @@ extern char** ignore_headers;
 
 extern size_t ignore_headers_len;
 
-extern char* profile_dir;
-
 extern char* i_tmpfile;
 
 extern bool direct_i_file;
index f8b5fe318e3d81a83fd4b1130e478dc7e938a4f1..914e771eff49e30924f26ce898e7ab52336f9f06 100644 (file)
@@ -84,8 +84,6 @@ cc_process_args(Context& ctx,
                                  extra_args_to_hash,
                                  compiler_args);
 
-  profile_dir = x_strdup(ctx.args_info.profile_dir.c_str());
-
   direct_i_file = ctx.args_info.direct_i_file;
   output_is_precompiled_header = ctx.args_info.output_is_precompiled_header;
   profile_use = ctx.args_info.profile_use;