#include <algorithm>
#include <limits>
+#ifndef MYNAME
+# define MYNAME "ccache"
+#endif
+static const char CCACHE_NAME[] = MYNAME;
+
using Logging::log;
using nonstd::nullopt;
using nonstd::optional;
Args prefix;
for (const auto& word : Util::split_into_strings(prefix_command, " ")) {
- std::string path = find_executable(ctx, word, MYNAME);
+ std::string path = find_executable(ctx, word, CCACHE_NAME);
if (path.empty()) {
throw FatalError("{}: {}", word, strerror(errno));
}
hash_compiler(ctx, hash, st, path, false);
}
} else {
- std::string path = find_executable(ctx, compiler, MYNAME);
+ std::string path = find_executable(ctx, compiler, CCACHE_NAME);
if (!path.empty()) {
auto st = Stat::stat(path, Stat::OnError::log);
hash_compiler(ctx, hash, st, ccbin, false);
{
// We might be being invoked like "ccache gcc -c foo.c".
std::string base(Util::base_name(argv[0]));
- if (Util::same_program_name(base, MYNAME)) {
+ if (Util::same_program_name(base, CCACHE_NAME)) {
ctx.orig_args.pop_front();
if (Util::is_full_path(ctx.orig_args[0])) {
return;
base = ctx.config.compiler();
}
- std::string compiler = find_executable(ctx, base, MYNAME);
+ std::string compiler = find_executable(ctx, base, CCACHE_NAME);
if (compiler.empty()) {
throw FatalError("Could not find compiler \"{}\" in PATH", base);
}
if (compiler == argv[0]) {
throw FatalError(
"Recursive invocation (the name of the ccache binary must be \"{}\")",
- MYNAME);
+ CCACHE_NAME);
}
ctx.orig_args[0] = compiler;
}
}
case 'h': // --help
- fmt::print(stdout, USAGE_TEXT, MYNAME, MYNAME);
+ fmt::print(stdout, USAGE_TEXT, CCACHE_NAME, CCACHE_NAME);
exit(EXIT_SUCCESS);
case 'k': // --get-config
break;
case 'V': // --version
- fmt::print(VERSION_TEXT, MYNAME, CCACHE_VERSION);
+ fmt::print(VERSION_TEXT, CCACHE_NAME, CCACHE_VERSION);
exit(EXIT_SUCCESS);
case 'x': // --show-compression
break;
default:
- fmt::print(stderr, USAGE_TEXT, MYNAME, MYNAME);
+ fmt::print(stderr, USAGE_TEXT, CCACHE_NAME, CCACHE_NAME);
exit(EXIT_FAILURE);
}
try {
// Check if we are being invoked as "ccache".
std::string program_name(Util::base_name(argv[0]));
- if (Util::same_program_name(program_name, MYNAME)) {
+ if (Util::same_program_name(program_name, CCACHE_NAME)) {
if (argc < 2) {
- fmt::print(stderr, USAGE_TEXT, MYNAME, MYNAME);
+ fmt::print(stderr, USAGE_TEXT, CCACHE_NAME, CCACHE_NAME);
exit(EXIT_FAILURE);
}
// If the first argument isn't an option, then assume we are being passed
#include "system.hpp"
-#include "Args.hpp"
-#include "Counters.hpp"
-#include "Digest.hpp"
-#include "stats.hpp"
-
-#include "third_party/nonstd/optional.hpp"
-
-struct ArgsInfo;
-class Context;
-class Config;
-
-#ifndef MYNAME
-# define MYNAME "ccache"
-#endif
-
extern const char CCACHE_VERSION[];
enum class GuessedCompiler { clang, gcc, nvcc, pump, unknown };
-#define SLOPPY_INCLUDE_FILE_MTIME (1U << 0)
-#define SLOPPY_INCLUDE_FILE_CTIME (1U << 1)
-#define SLOPPY_TIME_MACROS (1U << 2)
-#define SLOPPY_PCH_DEFINES (1U << 3)
+const uint32_t SLOPPY_INCLUDE_FILE_MTIME = 1 << 0;
+const uint32_t SLOPPY_INCLUDE_FILE_CTIME = 1 << 1;
+const uint32_t SLOPPY_TIME_MACROS = 1 << 2;
+const uint32_t SLOPPY_PCH_DEFINES = 1 << 3;
// Allow us to match files based on their stats (size, mtime, ctime), without
// looking at their contents.
-#define SLOPPY_FILE_STAT_MATCHES (1U << 4)
+const uint32_t SLOPPY_FILE_STAT_MATCHES = 1 << 4;
// Allow us to not include any system headers in the manifest include files,
// similar to -MM versus -M for dependencies.
-#define SLOPPY_SYSTEM_HEADERS (1U << 5)
+const uint32_t SLOPPY_SYSTEM_HEADERS = 1 << 5;
// Allow us to ignore ctimes when comparing file stats, so we can fake mtimes
// if we want to (it is much harder to fake ctimes, requires changing clock)
-#define SLOPPY_FILE_STAT_MATCHES_CTIME (1U << 6)
+const uint32_t SLOPPY_FILE_STAT_MATCHES_CTIME = 1 << 6;
// Allow us to not include the -index-store-path option in the manifest hash.
-#define SLOPPY_CLANG_INDEX_STORE (1U << 7)
+const uint32_t SLOPPY_CLANG_INDEX_STORE = 1 << 7;
// Ignore locale settings.
-#define SLOPPY_LOCALE (1U << 8)
+const uint32_t SLOPPY_LOCALE = 1 << 8;
// Allow caching even if -fmodules is used.
-#define SLOPPY_MODULES (1U << 9)
-
-void block_signals();
-void unblock_signals();
+const uint32_t SLOPPY_MODULES = 1 << 9;