From: Joel Rosdahl Date: Sat, 24 Sep 2022 19:08:43 +0000 (+0200) Subject: chore: Rename primary/secondary config to config/system config X-Git-Tag: v4.7~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2e7f91070a46a31914dae6c2ba9815af5fab823;p=thirdparty%2Fccache.git chore: Rename primary/secondary config to config/system config --- diff --git a/doc/INSTALL.md b/doc/INSTALL.md index b86b4059e..e07638743 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -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: diff --git a/doc/MANUAL.adoc b/doc/MANUAL.adoc index 8011e0d9f..10aa9feab 100644 --- a/doc/MANUAL.adoc +++ b/doc/MANUAL.adoc @@ -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 - `/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 `/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 <> is set in the secondary - (system-wide) configuration file then use `/ccache.conf`. +3. Otherwise, if <> is set in the system + configuration file then use `/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 <> is set in the secondary - (system-wide) configuration file then use `\ccache.conf`. The +3. Otherwise, if <> is set in the system + configuration file then use `\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 _<>_. +See also _<>_. [#config_compiler] *compiler* (*CCACHE_COMPILER* or (deprecated) *CCACHE_CC*):: diff --git a/src/Config.cpp b/src/Config.cpp index 2c7ca6282..bd42718d5 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -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 diff --git a/src/Config.hpp b/src/Config.hpp index 0503512e9..b58d97dd9 100644 --- a/src/Config.hpp +++ b/src/Config.hpp @@ -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 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) { diff --git a/src/core/mainoptions.cpp b/src/core/mainoptions.cpp index 0fbe2e9a8..8b291d8ae 100644 --- a/src/core/mainoptions.cpp +++ b/src/core/mainoptions.cpp @@ -542,7 +542,7 @@ process_main_options(int argc, const char* const* argv) case 'F': { // --max-files auto files = util::value_or_throw(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; } diff --git a/test/run b/test/run index 5efe6a859..ed130e71c 100755 --- 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 diff --git a/test/suites/upgrade.bash b/test/suites/upgrade.bash index 69786c3b6..254f02e26 100644 --- a/test/suites/upgrade.bash +++ b/test/suites/upgrade.bash @@ -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 }