From dd20069a11955be357cb6aea779dea8fa7c91b4d Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Tue, 8 Jun 2010 22:59:42 +0200 Subject: [PATCH] Store CCACHE_COMPRESS as a global configuration variable --- ccache.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ccache.c b/ccache.c index 89e5a5c39..129f669e3 100644 --- a/ccache.c +++ b/ccache.c @@ -169,6 +169,12 @@ static int enable_unify; /* should we use the direct mode? */ static int enable_direct = 1; +/* + * Whether to enable compression of files stored in the cache. (Manifest files + * are always compressed.) + */ +static int enable_compression = 0; + /* number of levels (1 <= nlevels <= 8) */ static int nlevels = 2; @@ -578,7 +584,6 @@ static void to_cache(ARGS *args) char *tmp_stdout, *tmp_stderr, *tmp_obj; struct stat st; int status; - int compress; x_asprintf(&tmp_stdout, "%s.tmp.stdout.%s", cached_obj, tmp_string()); x_asprintf(&tmp_stderr, "%s.tmp.stderr.%s", cached_obj, tmp_string()); @@ -691,8 +696,6 @@ static void to_cache(ARGS *args) failed(); } - compress = getenv("CCACHE_COMPRESS") ? 1 : 0; - if (stat(tmp_stderr, &st) != 0) { cc_log("Failed to stat %s", tmp_stderr); stats_update(STATS_ERROR); @@ -700,7 +703,7 @@ static void to_cache(ARGS *args) } if (st.st_size > 0) { if (move_uncompressed_file(tmp_stderr, cached_stderr, - compress) != 0) { + enable_compression) != 0) { cc_log("Failed to move %s to %s", tmp_stderr, cached_stderr); stats_update(STATS_ERROR); @@ -710,7 +713,7 @@ static void to_cache(ARGS *args) } else { unlink(tmp_stderr); } - if (move_uncompressed_file(tmp_obj, cached_obj, compress) != 0) { + if (move_uncompressed_file(tmp_obj, cached_obj, enable_compression) != 0) { cc_log("Failed to move %s to %s", tmp_obj, cached_obj); stats_update(STATS_ERROR); failed(); @@ -1822,6 +1825,11 @@ static void ccache(int argc, char *argv[]) enable_direct = 0; } + if (getenv("CCACHE_COMPRESS")) { + cc_log("Compression enabled"); + enable_compression = 1; + } + if ((env = getenv("CCACHE_NLEVELS"))) { nlevels = atoi(env); if (nlevels < 1) nlevels = 1; -- 2.47.3