]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Merge branch 'maint'
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 30 Aug 2013 21:07:51 +0000 (23:07 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 30 Aug 2013 21:07:51 +0000 (23:07 +0200)
* maint:
  Spelling fixes
  Avoid creating ccache directory when CCACHE_DISABLE is set

Conflicts:
ccache.c

1  2 
ccache.c
test.sh

diff --cc ccache.c
index fd3d41d30ecc50107b4a90c5630152266daff383,73d86eda9ec4d3dea74aa5bd6c36b81df28e1d98..ea9b39ba3711623367a818d4501f48741345c796
+++ b/ccache.c
        return result;
  }
  
 +static void
 +create_initial_config_file(struct conf *conf, const char *path)
 +{
 +      unsigned max_files;
 +      uint64_t max_size;
 +      char *stats_dir;
 +      FILE *f;
 +      struct stat st;
 +
 +      if (create_parent_dirs(path) != 0) {
 +              return;
 +      }
 +
 +      stats_dir = format("%s/0", conf->cache_dir);
 +      if (stat(stats_dir, &st) == 0) {
 +              stats_get_obsolete_limits(stats_dir, &max_files, &max_size);
 +              /* STATS_MAXFILES and STATS_MAXSIZE was stored for each top directory. */
 +              max_files *= 16;
 +              max_size *= 16;
 +      } else {
 +              max_files = 0;
 +              max_size = conf->max_size;
 +      }
 +      free(stats_dir);
 +
 +      f = fopen(path, "w");
 +      if (!f) {
 +              return;
 +      }
 +      if (max_files != 0) {
 +              fprintf(f, "max_files = %u\n", max_files);
 +              conf->max_files = max_files;
 +      }
 +      if (max_size != 0) {
 +              char *size = format_parsable_size_with_suffix(max_size);
 +              fprintf(f, "max_size = %s\n", size);
 +              free(size);
 +              conf->max_size = max_size;
 +      }
 +      fclose(f);
 +}
 +
 +/*
 + * Read config file(s), populate variables, create configuration file in cache
 + * directory if missing, etc.
 + */
 +static void
 +initialize(void)
 +{
 +      char *errmsg;
 +      char *p;
 +      struct stat st;
 +      bool should_create_initial_config = false;
 +
 +      conf_free(conf);
 +      conf = conf_create();
 +
 +      p = getenv("CCACHE_CONFIGPATH");
 +      if (p) {
 +              primary_config_path = x_strdup(p);
 +      } else {
 +              secondary_config_path = format("%s/ccache.conf", TO_STRING(SYSCONFDIR));
 +              if (!conf_read(conf, secondary_config_path, &errmsg)) {
 +                      if (stat(secondary_config_path, &st) == 0) {
 +                              fatal("%s", errmsg);
 +                      }
 +                      /* Missing config file in SYSCONFDIR is OK. */
 +                      free(errmsg);
 +              }
 +
 +              if ((p = getenv("CCACHE_DIR"))) {
 +                      free(conf->cache_dir);
 +                      conf->cache_dir = strdup(p);
 +              }
 +
 +              primary_config_path = format("%s/ccache.conf", conf->cache_dir);
 +      }
 +
 +      if (!conf_read(conf, primary_config_path, &errmsg)) {
 +              if (stat(primary_config_path, &st) == 0) {
 +                      fatal("%s", errmsg);
 +              }
 +              should_create_initial_config = true;
 +      }
 +
 +      if (!conf_update_from_environment(conf, &errmsg)) {
 +              fatal("%s", errmsg);
 +      }
 +
++      if (conf->disable) {
++              should_create_initial_config = false;
++      }
++
 +      if (should_create_initial_config) {
 +              create_initial_config_file(conf, primary_config_path);
 +      }
 +
 +      exitfn_init();
 +      exitfn_add_nullary(stats_flush);
 +      exitfn_add_nullary(clean_up_tmp_files);
 +
 +      cc_log("=== CCACHE %s STARTED =========================================",
 +             CCACHE_VERSION);
 +
 +      if (conf->umask != UINT_MAX) {
 +              umask(conf->umask);
 +      }
 +
 +      current_working_dir = get_cwd();
 +}
 +
  /* Reset the global state. Used by the test suite. */
  void
  cc_reset(void)
diff --cc test.sh
index efabac2c0960f9cfd5e43e04e916e4bea3d3ff16,d74e520c622898e49f2c2ccf95c3e609ba233b53..f5a10d08e5963bd8b9cfcbf1ab84a6196eb1bf38
+++ b/test.sh
@@@ -233,7 -216,12 +233,15 @@@ base_tests() 
      checkstat 'no input file' 1
  
      testname="CCACHE_DISABLE"
+     mv $CCACHE_DIR $CCACHE_DIR.saved
++    saved_config_path=$CCACHE_CONFIGPATH
++    unset CCACHE_CONFIGPATH
      CCACHE_DISABLE=1 $CCACHE_COMPILE -c test1.c 2> /dev/null
+     if [ -d $CCACHE_DIR ]; then
+         test_failed "$CCACHE_DIR created dispite CCACHE_DISABLE being set"
+     fi
++    CCACHE_CONFIGPATH=$saved_config_path
+     mv $CCACHE_DIR.saved $CCACHE_DIR
      checkstat 'cache hit (preprocessed)' 3
      $CCACHE_COMPILE -c test1.c
      checkstat 'cache hit (preprocessed)' 4