]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Clean up ccache.hpp
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 4 Aug 2020 09:38:21 +0000 (11:38 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 4 Aug 2020 09:38:21 +0000 (11:38 +0200)
src/ccache.cpp
src/ccache.hpp

index 0dd4704bd4d237fb7f713acce8fabb44380a911f..522876234c3c5692176769252058ee27ccc4bd17 100644 (file)
 #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;
@@ -152,7 +157,7 @@ add_prefix(const Context& ctx, Args& args, const std::string& prefix_command)
 
   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));
     }
@@ -1152,7 +1157,7 @@ hash_nvcc_host_compiler(const Context& ctx,
           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);
@@ -1697,7 +1702,7 @@ find_compiler(Context& ctx, const char* const* argv)
 {
   // 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;
@@ -1710,14 +1715,14 @@ find_compiler(Context& ctx, const char* const* argv)
     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;
 }
@@ -2276,7 +2281,7 @@ handle_main_options(int argc, const char* const* argv)
     }
 
     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
@@ -2330,7 +2335,7 @@ handle_main_options(int argc, const char* const* argv)
       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
@@ -2368,7 +2373,7 @@ handle_main_options(int argc, const char* const* argv)
       break;
 
     default:
-      fmt::print(stderr, USAGE_TEXT, MYNAME, MYNAME);
+      fmt::print(stderr, USAGE_TEXT, CCACHE_NAME, CCACHE_NAME);
       exit(EXIT_FAILURE);
     }
 
@@ -2388,9 +2393,9 @@ ccache_main(int argc, const char* const* argv)
   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
index 69bd5ffa577c321434b4c0bb8d6ce36a91a4abe1..70d397b523d0afa45080677a20f8835990bb6ed5 100644 (file)
 
 #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;