summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-03-08 10:21:46 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-03-11 15:17:16 +0100
commit20d105a65d305c724948ce389654c74cacac013c (patch)
treeb0a99ceeb7c4264558893b2e086a6b3117941667 /src
parent4f306e033ba5523b3b07ca8c709b609f0c117cf1 (diff)
downloadjustbuild-20d105a65d305c724948ce389654c74cacac013c.tar.gz
gc: add option --no-rotation
... to clean up what can be done without losing cache information.
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/common/cli.hpp12
-rw-r--r--src/buildtool/main/cli.cpp1
-rw-r--r--src/buildtool/main/cli.hpp1
-rw-r--r--src/buildtool/main/main.cpp3
4 files changed, 16 insertions, 1 deletions
diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp
index 387092bc..5b8df960 100644
--- a/src/buildtool/common/cli.hpp
+++ b/src/buildtool/common/cli.hpp
@@ -180,6 +180,10 @@ struct ServeArguments {
std::vector<std::filesystem::path> repositories{};
};
+struct GcArguments {
+ bool no_rotate{};
+};
+
static inline auto SetupCommonArguments(
gsl::not_null<CLI::App*> const& app,
gsl::not_null<CommonArguments*> const& clargs) {
@@ -723,4 +727,12 @@ static inline void SetupRetryArguments(
"the resources that survived the outage. (Default: 60)");
}
+static inline void SetupGcArguments(gsl::not_null<CLI::App*> const& app,
+ gsl::not_null<GcArguments*> const& args) {
+ app->add_flag("--no-rotate",
+ args->no_rotate,
+ "Do not rotate cache generations, only clean up what can be "
+ "done without losing cache.");
+}
+
#endif // INCLUDED_SRC_BUILDTOOL_COMMON_CLI_HPP
diff --git a/src/buildtool/main/cli.cpp b/src/buildtool/main/cli.cpp
index c5da32bb..413befa6 100644
--- a/src/buildtool/main/cli.cpp
+++ b/src/buildtool/main/cli.cpp
@@ -127,6 +127,7 @@ auto SetupGcCommandArguments(
gsl::not_null<CommandLineArguments*> const& clargs) {
SetupLogArguments(app, &clargs->log);
SetupCacheArguments(app, &clargs->endpoint);
+ SetupGcArguments(app, &clargs->gc);
}
/// \brief Setup arguments for sub command "just execute".
diff --git a/src/buildtool/main/cli.hpp b/src/buildtool/main/cli.hpp
index 1ca45255..04ae2a16 100644
--- a/src/buildtool/main/cli.hpp
+++ b/src/buildtool/main/cli.hpp
@@ -52,6 +52,7 @@ struct CommandLineArguments {
ServiceArguments service;
ServeArguments serve;
RetryArguments retry;
+ GcArguments gc;
};
auto ParseCommandLineArguments(int argc, char const* const* argv)
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 5241fa54..78ec57a7 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -857,7 +857,8 @@ auto main(int argc, char* argv[]) -> int {
SetupAuthConfig(arguments.auth, arguments.cauth, arguments.sauth);
if (arguments.cmd == SubCommand::kGc) {
- if (GarbageCollector::TriggerGarbageCollection()) {
+ if (GarbageCollector::TriggerGarbageCollection(
+ arguments.gc.no_rotate)) {
return kExitSuccess;
}
return kExitFailure;