#include "NonCopyable.hpp"
struct args;
+struct digest;
struct Context : NonCopyable
{
// The original argument list.
struct args* orig_args = nullptr;
+
+ // Name (represented as a struct digest) of the file containing the cached
+ // result.
+ struct digest* result_name = nullptr;
+
+ // Full path to the file containing the result
+ // (cachedir/a/b/cdef[...]-size.result).
+ std::string result_path;
};
cc_log("Adding result name to %s", manifest_path);
if (!manifest_put(ctx.config,
manifest_path,
- *cached_result_name,
+ *ctx.result_name,
g_included_files,
save_timestamp)) {
cc_log("Failed to add result name to %s", manifest_path);
{
char result_name_string[DIGEST_STRING_BUFFER_SIZE];
digest_as_string(result_name, result_name_string);
- cached_result_name = result_name;
- cached_result_path =
- x_strdup(Util::get_path_in_cache(ctx.config.cache_dir(),
- ctx.config.cache_dir_levels(),
- result_name_string,
- ".result")
- .c_str());
+ ctx.result_name = result_name;
+ ctx.result_path = Util::get_path_in_cache(ctx.config.cache_dir(),
+ ctx.config.cache_dir_levels(),
+ result_name_string,
+ ".result");
ctx.stats_file =
fmt::format("{}/{}/stats", ctx.config.cache_dir(), result_name_string[0]);
}
result_file_map.emplace(FileType::dwarf_object, ctx.args_info.output_dwo);
}
- auto orig_dest_stat = Stat::stat(cached_result_path);
- result_put(ctx, cached_result_path, result_file_map);
+ auto orig_dest_stat = Stat::stat(ctx.result_path);
+ result_put(ctx, ctx.result_path, result_file_map);
- cc_log("Stored in cache: %s", cached_result_path);
+ cc_log("Stored in cache: %s", ctx.result_path.c_str());
- auto new_dest_stat = Stat::stat(cached_result_path, Stat::OnError::log);
+ auto new_dest_stat = Stat::stat(ctx.result_path, Stat::OnError::log);
if (!new_dest_stat) {
stats_update(STATS_ERROR);
failed();
if (ctx.args_info.generating_diagnostics) {
result_file_map.emplace(FileType::diagnostic, ctx.args_info.output_dia);
}
- bool ok = result_get(ctx, cached_result_path, result_file_map);
+ bool ok = result_get(ctx, ctx.result_path, result_file_map);
if (!ok) {
cc_log("Failed to get result from cache");
tmp_unlink(tmp_stderr);
cc_reset()
{
free_and_nullify(included_pch_file);
- free_and_nullify(cached_result_name);
- free_and_nullify(cached_result_path);
free_and_nullify(manifest_path);
time_of_compilation = 0;
for (size_t i = 0; i < ignore_headers_len; i++) {
#include "legacy_globals.hpp"
-// Name (represented as a struct digest) of the file containing the cached
-// result.
-struct digest* cached_result_name;
-
-// Full path to the file containing the result
-// (cachedir/a/b/cdef[...]-size.result).
-char* cached_result_path;
-
// Full path to the file containing the manifest
// (cachedir/a/b/cdef[...]-size.manifest).
char* manifest_path;