summaryrefslogtreecommitdiff
path: root/src/buildtool
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2025-06-11 17:17:52 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2025-06-12 17:07:17 +0200
commitcc7350c9c3535b672788e68b5b7082ec441a4d6d (patch)
tree835f4f6b71063226859f8fa65830cc85693e5286 /src/buildtool
parent826cfa2022fbce7c3bf22b23b335f2080d878eaa (diff)
downloadjustbuild-cc7350c9c3535b672788e68b5b7082ec441a4d6d.tar.gz
Add a flag to `gc` command: `--all`
Diffstat (limited to 'src/buildtool')
-rw-r--r--src/buildtool/common/cli.hpp18
-rw-r--r--src/buildtool/main/main.cpp4
2 files changed, 16 insertions, 6 deletions
diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp
index 6b6ad535..ff4db0bb 100644
--- a/src/buildtool/common/cli.hpp
+++ b/src/buildtool/common/cli.hpp
@@ -192,7 +192,8 @@ struct ServeArguments {
};
struct GcArguments {
- bool no_rotate{};
+ bool no_rotate = false;
+ bool all = false;
};
struct ToAddArguments {
@@ -838,10 +839,17 @@ static inline auto SetupServeArguments(
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.");
+ auto* no_rotate =
+ app->add_flag("--no-rotate",
+ args->no_rotate,
+ "Do not rotate cache generations, only clean up what can "
+ "be done without losing cache.");
+
+ auto* all = app->add_flag(
+ "--all", args->all, "Remove all cache generations at once");
+
+ no_rotate->excludes(all);
+ all->excludes(no_rotate);
}
#endif // INCLUDED_SRC_BUILDTOOL_COMMON_CLI_HPP
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 8c122e6b..d13ad2e7 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -771,7 +771,9 @@ auto main(int argc, char* argv[]) -> int {
}
if (GarbageCollector::TriggerGarbageCollection(
- *storage_config, arguments.gc.no_rotate)) {
+ *storage_config,
+ arguments.gc.no_rotate,
+ arguments.gc.all)) {
return kExitSuccess;
}
return kExitBuildEnvironment;