#include "ArgsInfo.hpp"
#include "Config.hpp"
#include "NonCopyable.hpp"
+#include "hash.hpp"
+
+#include <unordered_map>
struct args;
-struct digest;
struct Context : NonCopyable
{
// Time of compilation. Used to see if include files have changed after
// compilation.
time_t time_of_compilation = 0;
+
+ // Files included by the preprocessor and their hashes.
+ // Key: file path. Value: struct digest.
+ std::unordered_map<std::string, digest> included_files;
};
return true;
}
- if (g_included_files.find(path) != g_included_files.end()) {
+ if (ctx.included_files.find(path) != ctx.included_files.end()) {
// Already known include file.
return true;
}
digest d;
hash_result_as_bytes(fhash, &d);
- g_included_files.emplace(path, d);
+ ctx.included_files.emplace(path, d);
if (depend_mode_hash) {
hash_delimiter(depend_mode_hash, "include");
}
static void
-print_included_files(FILE* fp)
+print_included_files(Context& ctx, FILE* fp)
{
- for (const auto& item : g_included_files) {
+ for (const auto& item : ctx.included_files) {
fprintf(fp, "%s\n", item.first.c_str());
}
}
bool debug_included = getenv("CCACHE_DEBUG_INCLUDED");
if (debug_included) {
- print_included_files(stdout);
+ print_included_files(ctx, stdout);
}
return true;
bool debug_included = getenv("CCACHE_DEBUG_INCLUDED");
if (debug_included) {
- print_included_files(stdout);
+ print_included_files(ctx, stdout);
}
auto d = static_cast<digest*>(x_malloc(sizeof(digest)));
if (!manifest_put(ctx.config,
ctx.manifest_path,
*ctx.result_name,
- g_included_files,
+ ctx.included_files,
ctx.time_of_compilation,
save_timestamp)) {
cc_log("Failed to add result name to %s", ctx.manifest_path.c_str());
}
free_and_nullify(ignore_headers);
ignore_headers_len = 0;
- g_included_files.clear();
has_absolute_include_headers = false;
i_tmpfile = NULL;
free_and_nullify(cpp_stderr);
#include "legacy_globals.hpp"
-// Files included by the preprocessor and their hashes. Key: file path. Value:
-// struct digest.
-std::unordered_map<std::string, digest> g_included_files;
-
// Uses absolute path for some include files.
bool has_absolute_include_headers = false;