free(object_name);
}
- const char *compilercheck;
-
- compilercheck = getenv("CCACHE_COMPILERCHECK");
- if (!compilercheck) {
- compilercheck = "mtime";
- }
- if (str_eq(compilercheck, "none")) {
+ /*
+ * Hash mtime or content of a file, or the output of a command, according to
+ * the CCACHE_COMPILERCHECK setting.
+ */
+ static void
+ hash_compiler(struct mdfour *hash, struct stat *st, const char *path,
+ bool allow_command)
+ {
- } else if (str_eq(compilercheck, "mtime")) {
++ if (str_eq(conf->compiler_check, "none")) {
+ /* Do nothing. */
- } else if (str_eq(compilercheck, "content") || !allow_command) {
++ } else if (str_eq(conf->compiler_check, "mtime")) {
+ hash_delimiter(hash, "cc_mtime");
+ hash_int(hash, st->st_size);
+ hash_int(hash, st->st_mtime);
- if (!hash_multicommand_output(hash, compilercheck, orig_args->argv[0])) {
- fatal("Failure running compiler check command: %s", compilercheck);
++ } else if (str_eq(conf->compiler_check, "content") || !allow_command) {
+ hash_delimiter(hash, "cc_content");
+ hash_file(hash, path);
+ } else { /* command string */
++ if (!hash_multicommand_output(
++ hash, conf->compiler_check, orig_args->argv[0])) {
++ fatal("Failure running compiler check command: %s", conf->compiler_check);
+ }
+ }
+ }
+
/*
* Update a hash sum with information common for the direct and preprocessor
* modes.
}
if (direct_mode) {
- if (!(sloppiness & SLOPPY_FILE_MACRO)) {
+ /* Hash environment variables that affect the preprocessor output. */
+ const char **p;
+ const char *envvars[] = {
+ "CPATH",
+ "C_INCLUDE_PATH",
+ "CPLUS_INCLUDE_PATH",
+ "OBJC_INCLUDE_PATH",
+ "OBJCPLUS_INCLUDE_PATH", /* clang */
+ NULL
+ };
+ for (p = envvars; *p != NULL ; ++p) {
+ char *v = getenv(*p);
+ if (v) {
+ hash_delimiter(hash, *p);
+ hash_string(hash, v);
+ }
+ }
+
+ if (!(conf->sloppiness & SLOPPY_FILE_MACRO)) {
/*
* The source code file or an include file may contain
* __FILE__, so make sure that the hash is unique for