summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2022-09-24 21:08:43 +0200
committerJoel Rosdahl <joel@rosdahl.net>2022-09-27 22:24:37 +0200
commita2e7f91070a46a31914dae6c2ba9815af5fab823 (patch)
treeddc24ef7e39a1282c76c5a1c0ea0d25ef2a46979
parentb97e77ce460f905f1141935d03d3727543edad12 (diff)
downloadccache-a2e7f91070a46a31914dae6c2ba9815af5fab823.tar.gz
chore: Rename primary/secondary config to config/system config
-rw-r--r--doc/INSTALL.md4
-rw-r--r--doc/MANUAL.adoc29
-rw-r--r--src/Config.cpp69
-rw-r--r--src/Config.hpp14
-rw-r--r--src/ccache.cpp4
-rw-r--r--src/core/Statistics.cpp5
-rw-r--r--src/core/mainoptions.cpp6
-rwxr-xr-xtest/run2
-rw-r--r--test/suites/upgrade.bash22
9 files changed, 76 insertions, 79 deletions
diff --git a/doc/INSTALL.md b/doc/INSTALL.md
index b86b4059..e0763874 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 8011e0d9..10aa9fea 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
- `<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*)::
diff --git a/src/Config.cpp b/src/Config.cpp
index 2c7ca628..bd42718d 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 0503512e..b58d97dd 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<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;
diff --git a/src/ccache.cpp b/src/ccache.cpp
index c127c6d2..a52dd494 100644
--- a/src/ccache.cpp
+++ b/src/ccache.cpp
@@ -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
diff --git a/src/core/Statistics.cpp b/src/core/Statistics.cpp
index 289b7722..b7d23acb 100644
--- a/src/core/Statistics.cpp
+++ b/src/core/Statistics.cpp
@@ -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) {
diff --git a/src/core/mainoptions.cpp b/src/core/mainoptions.cpp
index 0fbe2e9a..8b291d8a 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<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;
}
diff --git a/test/run b/test/run
index 5efe6a85..ed130e71 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 69786c3b..254f02e2 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
}