return std::nullopt;
}
-bool
-is_ccache_executable(const std::string_view path)
-{
- std::string name(Util::base_name(path));
-#ifdef _WIN32
- name = util::to_lowercase(name);
-#endif
- return util::starts_with(name, "ccache");
-}
-
std::string
make_relative_path(const std::string& base_dir,
const std::string& actual_cwd,
// point.
std::optional<size_t> is_absolute_path_with_prefix(std::string_view path);
-// Detmine if `path` refers to a ccache executable.
-bool is_ccache_executable(std::string_view path);
-
// Return whether `ch` is a directory separator, i.e. '/' on POSIX systems and
// '/' or '\\' on Windows systems.
inline bool
throw core::Fatal(FMT("Could not find compiler \"{}\" in PATH", compiler));
}
- if (Util::is_ccache_executable(resolved_compiler)) {
+ if (is_ccache_executable(resolved_compiler)) {
throw core::Fatal("Recursive invocation of ccache");
}
{
ArgvParts argv_parts;
int i = 0;
- while (i < argc && Util::is_ccache_executable(argv[i])) {
+ while (i < argc && is_ccache_executable(argv[i])) {
argv_parts.masquerading_as_compiler = false;
++i;
}
return ctx.config.recache() ? Statistic::recache : Statistic::cache_miss;
}
+bool
+is_ccache_executable(const std::string_view path)
+{
+ std::string name(Util::base_name(path));
+#ifdef _WIN32
+ name = util::to_lowercase(name);
+#endif
+ return util::starts_with(name, "ccache");
+}
+
int
ccache_main(int argc, const char* const* argv)
{
try {
- if (Util::is_ccache_executable(argv[0])) {
+ if (is_ccache_executable(argv[0])) {
if (argc < 2) {
PRINT_RAW(stderr, core::get_usage_text(Util::base_name(argv[0])));
exit(EXIT_FAILURE);
const FindExecutableFunction& find_executable_function,
bool masquerading_as_compiler);
CompilerType guess_compiler(std::string_view path);
+bool is_ccache_executable(std::string_view path);
#include "Util.hpp"
#include "Win32Util.hpp"
+#include <ccache.hpp>
#include <core/exceptions.hpp>
#include <core/wincompat.hpp>
#include <fmtmacros.hpp>
if (candidate_exists) {
const auto real_candidate = util::real_path(candidate);
if ((real_exclude_path.empty() || real_candidate != real_exclude_path)
- && !Util::is_ccache_executable(real_candidate)) {
+ && !is_ccache_executable(real_candidate)) {
return candidate;
}
}
#endif
}
-TEST_CASE("Util::is_ccache_executable")
-{
- CHECK(Util::is_ccache_executable("ccache"));
- CHECK(Util::is_ccache_executable("ccache-1.2.3"));
- CHECK(!Util::is_ccache_executable("fooccache"));
- CHECK(!Util::is_ccache_executable("gcc"));
-#ifdef _WIN32
- CHECK(Util::is_ccache_executable("CCACHE"));
- CHECK(Util::is_ccache_executable("CCACHE.exe"));
- CHECK(Util::is_ccache_executable("CCACHE-1.2.3"));
- CHECK(Util::is_ccache_executable("CCACHE.EXE"));
- CHECK(Util::is_ccache_executable("CCACHE-1.2.3.EXE"));
-#endif
-}
-
TEST_CASE("Util::is_dir_separator")
{
CHECK(!Util::is_dir_separator('x'));
#endif
}
+TEST_CASE("is_ccache_executable")
+{
+ CHECK(is_ccache_executable("ccache"));
+ CHECK(is_ccache_executable("ccache-1.2.3"));
+ CHECK(!is_ccache_executable("fooccache"));
+ CHECK(!is_ccache_executable("gcc"));
+#ifdef _WIN32
+ CHECK(is_ccache_executable("CCACHE"));
+ CHECK(is_ccache_executable("CCACHE.exe"));
+ CHECK(is_ccache_executable("CCACHE-1.2.3"));
+ CHECK(is_ccache_executable("CCACHE.EXE"));
+ CHECK(is_ccache_executable("CCACHE-1.2.3.EXE"));
+#endif
+}
+
TEST_SUITE_END();