]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat: Add --print-version option (#1454)
authorSilver Zachara <silver.zachara@gmail.com>
Fri, 17 May 2024 19:12:25 +0000 (21:12 +0200)
committerGitHub <noreply@github.com>
Fri, 17 May 2024 19:12:25 +0000 (21:12 +0200)
I have added a new `--print-version` option as ccache will support PCH
on msvc and I will need to somehow detect the ccache version to
correctly decide if PCH should be disabled
(`CMAKE_DISABLE_PRECOMPILE_HEADERS`).

So if ccache >=4.10 then don't disable PCH and if it's below then set
`CMAKE_DISABLE_PRECOMPILE_HEADERS=ON`.

doc/MANUAL.adoc
src/ccache/core/mainoptions.cpp

index 914f975d786e35909c62991bfc68b8e785170ba0..ea040de58455b2e54dda94ed065398f27f6f8ede 100644 (file)
@@ -299,6 +299,10 @@ directory to a certain size, use `CCACHE_MAXSIZE=_SIZE_ ccache -c`.
     Print statistics counter IDs and corresponding values in machine-parsable
     (tab-separated or JSON) format. See `--format`.
 
+*--print-version*::
+
+    Print version and don't do anything else.
+
 
 
 === Extra options
index 2137939bfde3a7455b274f23b816b6d582e8788c..5e0a0e37525af481b0f3e4527212a7a60a67ac39 100644 (file)
@@ -180,6 +180,7 @@ Options for scripting or debugging:
                                format
         --print-stats          print statistics counter IDs and corresponding
                                values in machine-parsable format
+        --print-version        print version only
 
 See also the manual on <https://ccache.dev/documentation.html>.
 )";
@@ -445,6 +446,7 @@ enum {
   INSPECT,
   PRINT_LOG_STATS,
   PRINT_STATS,
+  PRINT_VERSION,
   RECOMPRESS_THREADS,
   SHOW_LOG_STATS,
   TRIM_DIR,
@@ -476,6 +478,7 @@ const option long_options[] = {
   {"max-size", required_argument, nullptr, 'M'},
   {"print-log-stats", no_argument, nullptr, PRINT_LOG_STATS},
   {"print-stats", no_argument, nullptr, PRINT_STATS},
+  {"print-version", no_argument, nullptr, PRINT_VERSION},
   {"recompress", required_argument, nullptr, 'X'},
   {"recompress-threads", required_argument, nullptr, RECOMPRESS_THREADS},
   {"set-config", required_argument, nullptr, 'o'},
@@ -812,6 +815,11 @@ process_main_options(int argc, const char* const* argv)
       break;
     }
 
+    case PRINT_VERSION:
+      PRINT_RAW(stdout, CCACHE_VERSION);
+      PRINT_RAW(stdout, '\n');
+      break;
+
     case 'x': // --show-compression
     {
       ProgressBar progress_bar("Scanning...");