// Current working directory taken from $PWD, or getcwd() if $PWD is bad.
char *current_working_dir = NULL;
+// Print the unified preprocessed source code format, to stdout
+bool unify_print = false;
+
// The original argument list.
static struct args *orig_args;
}
if (conf->unify) {
+ char *print = getenv("CCACHE_UNIFY_PRINT");
+ unify_print = print != NULL ? true : false;
+
// When we are doing the unifying tricks we need to include the input file
// name in the hash to get the warnings right.
hash_delimiter(hash, "unifyfilename");
hash_string(hash, input_file);
hash_delimiter(hash, "unifycpp");
- if (unify_hash(hash, path_stdout) != 0) {
+ if (unify_hash(hash, path_stdout, unify_print) != 0) {
stats_update(STATS_ERROR);
cc_log("Failed to unify %s", path_stdout);
failed();
// ----------------------------------------------------------------------------
// unify.c
-int unify_hash(struct mdfour *hash, const char *fname);
+int unify_hash(struct mdfour *hash, const char *fname, bool print);
// ----------------------------------------------------------------------------
// exitfn.c
#include "ccache.h"
+static bool print_unified = true;
+
static const char *const s_tokens[] = {
"...", ">>=", "<<=", "+=", "-=", "*=", "/=", "%=", "&=", "^=",
"|=", ">>", "<<", "++", "--", "->", "&&", "||", "<=", ">=",
if (c == 0) {
if (len > 0) {
hash_buffer(hash, (char *)buf, len);
+ if (print_unified) {
+ printf("%.*s", (int) len, buf);
+ }
len = 0;
}
hash_buffer(hash, NULL, 0);
buf[len++] = c;
if (len == 64) {
hash_buffer(hash, (char *)buf, len);
+ if (print_unified) {
+ printf("%.*s", (int) len, buf);
+ }
len = 0;
}
}
// Hash a file that consists of preprocessor output, but remove any line number
// information from the hash.
int
-unify_hash(struct mdfour *hash, const char *fname)
+unify_hash(struct mdfour *hash, const char *fname, bool print)
{
char *data;
size_t size;
stats_update(STATS_PREPROCESSOR);
return -1;
}
+ print_unified = print;
unify(hash, (unsigned char *)data, size);
free(data);
return 0;