]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
chore: Rename primary/secondary config to config/system config
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 24 Sep 2022 19:08:43 +0000 (21:08 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 27 Sep 2022 20:24:37 +0000 (22:24 +0200)
doc/INSTALL.md
doc/MANUAL.adoc
src/Config.cpp
src/Config.hpp
src/ccache.cpp
src/core/Statistics.cpp
src/core/mainoptions.cpp
test/run
test/suites/upgrade.bash

index b86b4059e0bee64497f90502f62367b10dd92f5c..e07638743e14dd639ac66d4ec8e3cba0ba129a27 100644 (file)
@@ -59,8 +59,8 @@ make install
 
 You can set the installation directory to e.g. `/usr` by adding
 `-DCMAKE_INSTALL_PREFIX=/usr` to the `cmake` command. You can set the directory
-where the secondary configuration file should be located to e.g. `/etc` by
-adding `-DCMAKE_INSTALL_SYSCONFDIR=/etc`.
+where the system configuration file should be located to e.g. `/etc` by adding
+`-DCMAKE_INSTALL_SYSCONFDIR=/etc`.
 
 There are two different ways to use ccache to cache a compilation:
 
index 8011e0d9f95f96505ee26166da82c9bf47d73948..10aa9feabe45d1e951726a9dcaa604e3c9755a64 100644 (file)
@@ -289,27 +289,26 @@ file. The priorities of configuration options are as follows (where 1 is
 highest):
 
 1. Environment variables.
-2. The primary (cache-specific) configuration file (see below).
-3. The secondary (system-wide read-only) configuration file
-   `<sysconfdir>/ccache.conf` (typically `/etc/ccache.conf` or
-   `/usr/local/etc/ccache.conf`).
+2. The cache-specific configuration file (see below).
+3. The system (read-only) configuration file `<sysconfdir>/ccache.conf`
+   (typically `/etc/ccache.conf` or `/usr/local/etc/ccache.conf`).
 4. Compile-time defaults.
 
-As a special case, if the the environment variable `CCACHE_CONFIGPATH` is set
-it specifies the primary configuration file and the secondary (system-wide)
-configuration file won't be read.
+As a special case, if the environment variable `CCACHE_CONFIGPATH` is set it
+specifies the configuration file, and the system configuration file won't be
+read.
 
 
-=== Location of the primary configuration file
+=== Location of the configuration file
 
-The location of the primary (cache-specific) configuration is determined like
-this on non-Windows systems:
+The location of the cache-specific configuration file is determined like this on
+non-Windows systems:
 
 1. If `CCACHE_CONFIGPATH` is set, use that path.
 2. Otherwise, if the environment variable `CCACHE_DIR` is set then use
    `$CCACHE_DIR/ccache.conf`.
-3. Otherwise, if <<config_cache_dir,*cache_dir*>> is set in the secondary
-   (system-wide) configuration file then use `<cache_dir>/ccache.conf`.
+3. Otherwise, if <<config_cache_dir,*cache_dir*>> is set in the system
+   configuration file then use `<cache_dir>/ccache.conf`.
 4. Otherwise, if there is a legacy `$HOME/.ccache` directory then use
    `$HOME/.ccache/ccache.conf`.
 5. Otherwise, if `XDG_CONFIG_HOME` is set then use
@@ -323,8 +322,8 @@ On Windows, this is the method used to find the configuration file:
 1. If `CCACHE_CONFIGPATH` is set, use that path.
 2. Otherwise, if the environment variable `CCACHE_DIR` is set then use
    `%CCACHE_DIR%/ccache.conf`.
-3. Otherwise, if <<config_cache_dir,*cache_dir*>> is set in the secondary
-   (system-wide) configuration file then use `<cache_dir>\ccache.conf`. The
+3. Otherwise, if <<config_cache_dir,*cache_dir*>> is set in the system
+   configuration file then use `<cache_dir>\ccache.conf`. The
    system-wide configuration on Windows is
    `%ALLUSERSPROFILE%\ccache\ccache.conf` by default. The `ALLUSERSPROFILE`
    environment variable is usually `C:\ProgramData`.
@@ -461,7 +460,7 @@ of the cache in domain environments and similar problems. Please check this
 directory for cache directories and either delete them or the whole directory,
 or move them to the `%LOCALAPPDATA%\ccache` directory.
 +
-See also _<<Location of the primary configuration file>>_.
+See also _<<Location of the configuration file>>_.
 
 [#config_compiler]
 *compiler* (*CCACHE_COMPILER* or (deprecated) *CCACHE_CC*)::
index 2c7ca6282ca5dc5d1925cb322a6f6532d363dbe3..bd42718d59bcf9d1647f4a7e2da0c41fa90d3bf7 100644 (file)
@@ -489,7 +489,7 @@ Config::read()
 
   const char* env_ccache_configpath = getenv("CCACHE_CONFIGPATH");
   if (env_ccache_configpath) {
-    set_primary_config_path(env_ccache_configpath);
+    set_config_path(env_ccache_configpath);
   } else {
     // Only used for ccache tests:
     const char* const env_ccache_configpath2 = getenv("CCACHE_CONFIGPATH2");
@@ -500,33 +500,33 @@ Config::read()
       sysconfdir = Util::make_path(program_data, "ccache");
 #endif
 
-    set_secondary_config_path(env_ccache_configpath2
-                                ? env_ccache_configpath2
-                                : Util::make_path(sysconfdir, "ccache.conf"));
-    MTR_BEGIN("config", "conf_read_secondary");
+    set_system_config_path(env_ccache_configpath2
+                             ? env_ccache_configpath2
+                             : Util::make_path(sysconfdir, "ccache.conf"));
+    MTR_BEGIN("config", "conf_read_system");
     // A missing config file in SYSCONFDIR is OK so don't check return value.
-    update_from_file(secondary_config_path());
-    MTR_END("config", "conf_read_secondary");
+    update_from_file(system_config_path());
+    MTR_END("config", "conf_read_system");
 
     const char* const env_ccache_dir = getenv("CCACHE_DIR");
-    std::string primary_config_dir;
+    std::string config_dir;
     if (env_ccache_dir && *env_ccache_dir) {
-      primary_config_dir = env_ccache_dir;
+      config_dir = env_ccache_dir;
     } else if (!cache_dir().empty() && !env_ccache_dir) {
-      primary_config_dir = cache_dir();
+      config_dir = cache_dir();
     } else if (legacy_ccache_dir_exists) {
-      primary_config_dir = legacy_ccache_dir;
+      config_dir = legacy_ccache_dir;
 #ifdef _WIN32
     } else if (env_local_appdata
                && Stat::stat(
                  Util::make_path(env_local_appdata, "ccache", "ccache.conf"))) {
-      primary_config_dir = Util::make_path(env_local_appdata, "ccache");
+      config_dir = Util::make_path(env_local_appdata, "ccache");
     } else if (env_appdata
                && Stat::stat(
                  Util::make_path(env_appdata, "ccache", "ccache.conf"))) {
-      primary_config_dir = Util::make_path(env_appdata, "ccache");
+      config_dir = Util::make_path(env_appdata, "ccache");
     } else if (env_local_appdata) {
-      primary_config_dir = Util::make_path(env_local_appdata, "ccache");
+      config_dir = Util::make_path(env_local_appdata, "ccache");
     } else {
       throw core::Fatal(
         "could not find configuration file and the LOCALAPPDATA environment"
@@ -534,22 +534,22 @@ Config::read()
     }
 #else
     } else if (env_xdg_config_home) {
-      primary_config_dir = Util::make_path(env_xdg_config_home, "ccache");
+      config_dir = Util::make_path(env_xdg_config_home, "ccache");
     } else {
-      primary_config_dir = default_config_dir(home_dir);
+      config_dir = default_config_dir(home_dir);
     }
 #endif
-    set_primary_config_path(Util::make_path(primary_config_dir, "ccache.conf"));
+    set_config_path(Util::make_path(config_dir, "ccache.conf"));
   }
 
-  const std::string& cache_dir_before_primary_config = cache_dir();
+  const std::string& cache_dir_before_config_file_was_read = cache_dir();
 
-  MTR_BEGIN("config", "conf_read_primary");
-  update_from_file(primary_config_path());
-  MTR_END("config", "conf_read_primary");
+  MTR_BEGIN("config", "conf_read");
+  update_from_file(config_path());
+  MTR_END("config", "conf_read");
 
-  // Ignore cache_dir set in primary
-  set_cache_dir(cache_dir_before_primary_config);
+  // Ignore cache_dir set in configuration file
+  set_cache_dir(cache_dir_before_config_file_was_read);
 
   MTR_BEGIN("config", "conf_update_from_environment");
   update_from_environment();
@@ -575,35 +575,34 @@ Config::read()
     }
 #endif
   }
-  // else: cache_dir was set explicitly via environment or via secondary
-  // config.
+  // else: cache_dir was set explicitly via environment or via system config.
 
-  // We have now determined config.cache_dir and populated the rest of config
-  // in prio order (1. environment, 2. primary config, 3. secondary config).
+  // We have now determined config.cache_dir and populated the rest of config in
+  // prio order (1. environment, 2. cache-specific config, 3. system config).
 }
 
 const std::string&
-Config::primary_config_path() const
+Config::config_path() const
 {
-  return m_primary_config_path;
+  return m_config_path;
 }
 
 const std::string&
-Config::secondary_config_path() const
+Config::system_config_path() const
 {
-  return m_secondary_config_path;
+  return m_system_config_path;
 }
 
 void
-Config::set_primary_config_path(std::string path)
+Config::set_config_path(std::string path)
 {
-  m_primary_config_path = std::move(path);
+  m_config_path = std::move(path);
 }
 
 void
-Config::set_secondary_config_path(std::string path)
+Config::set_system_config_path(std::string path)
 {
-  m_secondary_config_path = std::move(path);
+  m_system_config_path = std::move(path);
 }
 
 bool
index 0503512e97d2ee97ebde727dcf593ba326874c95..b58d97dd90f6b0c8b490344df40f1a15b748ed63 100644 (file)
@@ -120,12 +120,12 @@ public:
   void set_temporary_dir(const std::string& value);
 
   // Where to write configuration changes.
-  const std::string& primary_config_path() const;
-  // Secondary, read-only configuration file (if any).
-  const std::string& secondary_config_path() const;
+  const std::string& config_path() const;
+  // System (read-only) configuration file (if any).
+  const std::string& system_config_path() const;
 
-  void set_primary_config_path(std::string path);
-  void set_secondary_config_path(std::string path);
+  void set_config_path(std::string path);
+  void set_system_config_path(std::string path);
 
   using ItemVisitor = std::function<void(const std::string& key,
                                          const std::string& value,
@@ -155,8 +155,8 @@ public:
   static void check_key_tables_consistency();
 
 private:
-  std::string m_primary_config_path;
-  std::string m_secondary_config_path;
+  std::string m_config_path;
+  std::string m_system_config_path;
 
   bool m_absolute_paths_in_stderr = false;
   std::string m_base_dir;
index c127c6d22da26881afa818d47c6b8afaada697e1..a52dd4945ca758c7530e568e3ab2e5a82b2bd263 100644 (file)
@@ -2029,8 +2029,8 @@ initialize(Context& ctx, int argc, const char* const* argv)
   LOG("=== CCACHE {} STARTED =========================================",
       CCACHE_VERSION);
 
-  LOG("Primary configuration file: {}", ctx.config.primary_config_path());
-  LOG("Secondary configuration file: {}", ctx.config.secondary_config_path());
+  LOG("Configuration file: {}", ctx.config.config_path());
+  LOG("System configuration file: {}", ctx.config.system_config_path());
 
   if (getenv("CCACHE_INTERNAL_TRACE")) {
 #ifdef MTR_ENABLED
index 289b77222f85eabee973f3fef6934dfc5bfaa80b..b7d23acbde7a4e9411553dc3ea9417b3d4b1ea15 100644 (file)
@@ -244,10 +244,9 @@ Statistics::format_human_readable(const Config& config,
 
   if (verbosity > 0 && !from_log) {
     table.add_row({"Cache directory:", C(config.cache_dir()).colspan(4)});
+    table.add_row({"Config file:", C(config.config_path()).colspan(4)});
     table.add_row(
-      {"Primary config:", C(config.primary_config_path()).colspan(4)});
-    table.add_row(
-      {"Secondary config:", C(config.secondary_config_path()).colspan(4)});
+      {"System config file:", C(config.system_config_path()).colspan(4)});
     table.add_row(
       {"Stats updated:", C(format_timestamp(last_updated)).colspan(4)});
     if (verbosity > 1) {
index 0fbe2e9a8568650c58258f28c80ed61b47dab43e..8b291d8ae5feb899e792c304dbd159f4aa3cfc44 100644 (file)
@@ -542,7 +542,7 @@ process_main_options(int argc, const char* const* argv)
 
     case 'F': { // --max-files
       auto files = util::value_or_throw<Error>(util::parse_unsigned(arg));
-      config.set_value_in_file(config.primary_config_path(), "max_files", arg);
+      config.set_value_in_file(config.config_path(), "max_files", arg);
       if (files == 0) {
         PRINT_RAW(stdout, "Unset cache file limit\n");
       } else {
@@ -553,7 +553,7 @@ process_main_options(int argc, const char* const* argv)
 
     case 'M': { // --max-size
       uint64_t size = Util::parse_size(arg);
-      config.set_value_in_file(config.primary_config_path(), "max_size", arg);
+      config.set_value_in_file(config.config_path(), "max_size", arg);
       if (size == 0) {
         PRINT_RAW(stdout, "Unset cache size limit\n");
       } else {
@@ -573,7 +573,7 @@ process_main_options(int argc, const char* const* argv)
       }
       std::string key = arg.substr(0, eq_pos);
       std::string value = arg.substr(eq_pos + 1);
-      config.set_value_in_file(config.primary_config_path(), key, value);
+      config.set_value_in_file(config.config_path(), key, value);
       break;
     }
 
index 5efe6a85973a8c7ed77bc8bc0317d4f69d0504f8..ed130e71c6092a312a344686adad0cd303a496f0 100755 (executable)
--- a/test/run
+++ b/test/run
@@ -380,7 +380,7 @@ reset_environment() {
 
     export CCACHE_DETECT_SHEBANG=1
     export CCACHE_DIR=$ABS_TESTDIR/.ccache
-    export CCACHE_CONFIGPATH=$CCACHE_DIR/ccache.conf # skip secondary config
+    export CCACHE_CONFIGPATH=$CCACHE_DIR/ccache.conf # skip system config
     export CCACHE_LOGFILE=$ABS_TESTDIR/ccache.log
     export CCACHE_NODIRECT=1
 
index 69786c3b68c4f357cbef063aa24e1097bdedaa20..254f02e26f6f1600eae956d5e1032626c9cc8767 100644 (file)
@@ -21,9 +21,9 @@ SUITE_upgrade() {
     else
         expected=$HOME/.config/ccache/ccache.conf
     fi
-    actual=$($CCACHE -sv | sed -n 's/ *Primary config: *//p')
+    actual=$($CCACHE -sv | sed -n 's/^Config file: *//p')
     if [ "$actual" != "$expected" ]; then
-        test_failed "expected primary config $expected actual $actual"
+        test_failed "expected config $expected, actual $actual"
     fi
 
     # -------------------------------------------------------------------------
@@ -42,9 +42,9 @@ SUITE_upgrade() {
     fi
 
     expected=$XDG_CONFIG_HOME/ccache/ccache.conf
-    actual=$($CCACHE -sv | sed -n 's/ *Primary config: *//p')
+    actual=$($CCACHE -sv | sed -n 's/^Config file: *//p')
     if [ "$actual" != "$expected" ]; then
-        test_failed "expected primary config $expected actual $actual"
+        test_failed "expected config $expected, actual $actual"
     fi
 
     # -------------------------------------------------------------------------
@@ -64,9 +64,9 @@ SUITE_upgrade() {
     fi
 
     expected=$HOME/.ccache/ccache.conf
-    actual=$($CCACHE -sv | sed -n 's/ *Primary config: *//p')
+    actual=$($CCACHE -sv | sed -n 's/^Config file: *//p')
     if [ "$actual" != "$expected" ]; then
-        test_failed "expected primary config $expected actual $actual"
+        test_failed "expected config $expected, actual $actual"
     fi
 
     # -------------------------------------------------------------------------
@@ -85,16 +85,16 @@ SUITE_upgrade() {
     fi
 
     expected=$CCACHE_DIR/ccache.conf
-    actual=$($CCACHE -sv | sed -n 's/ *Primary config: *//p')
+    actual=$($CCACHE -sv | sed -n 's/^Config file: *//p')
     if [ "$actual" != "$expected" ]; then
-        test_failed "expected primary config $expected actual $actual"
+        test_failed "expected config $expected, actual $actual"
     fi
 
     # -------------------------------------------------------------------------
     TEST "Cache config/directory with empty CCACHE_DIR"
 
     # Empty (but set) CCACHE_DIR means "use defaults" and should thus override
-    # cache_dir set in the secondary config.
+    # cache_dir set in the system config.
 
     unset CCACHE_CONFIGPATH
     export CCACHE_CONFIGPATH2=$PWD/ccache.conf2
@@ -111,8 +111,8 @@ SUITE_upgrade() {
     fi
 
     expected=$XDG_CONFIG_HOME/ccache/ccache.conf
-    actual=$($CCACHE -sv | sed -n 's/ *Primary config: *//p')
+    actual=$($CCACHE -sv | sed -n 's/^Config file: *//p')
     if [ "$actual" != "$expected" ]; then
-        test_failed "expected primary config $expected actual $actual"
+        test_failed "expected config $expected, actual $actual"
     fi
 }