summaryrefslogtreecommitdiff
path: root/src/buildtool/common/cli.hpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-12-05 13:07:05 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-12-06 11:57:16 +0100
commitef2da9cbe1d55fd9667ad7fe42792ffd8ed0ec50 (patch)
tree1480f7e0b8a074ac307201aa50553aa20c757544 /src/buildtool/common/cli.hpp
parent4402929b8956561255754bc610734a84974e997f (diff)
downloadjustbuild-ef2da9cbe1d55fd9667ad7fe42792ffd8ed0ec50.tar.gz
Add CLI option to set write strategy for target-level cache
Diffstat (limited to 'src/buildtool/common/cli.hpp')
-rw-r--r--src/buildtool/common/cli.hpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp
index bdcc5716..9c2bc7e2 100644
--- a/src/buildtool/common/cli.hpp
+++ b/src/buildtool/common/cli.hpp
@@ -30,6 +30,7 @@
#include "src/buildtool/common/clidefaults.hpp"
#include "src/buildtool/compatibility/compatibility.hpp"
#include "src/buildtool/logging/log_level.hpp"
+#include "src/buildtool/main/build_utils.hpp"
#include "src/utils/cpp/path.hpp"
constexpr auto kDefaultTimeout = std::chrono::milliseconds{300000};
@@ -103,6 +104,12 @@ struct BuildArguments {
bool show_runfiles{false};
};
+/// \brief Arguments related to target-level caching
+struct TCArguments {
+ TargetCacheWriteStrategy target_cache_write_strategy{
+ TargetCacheWriteStrategy::Sync};
+};
+
/// \brief Arguments required for staging.
struct StageArguments {
std::filesystem::path output_dir{};
@@ -461,6 +468,26 @@ static inline auto SetupBuildArguments(
->type_name("LOGICAL_PATH");
}
+static inline auto SetupTCArguments(gsl::not_null<CLI::App*> const& app,
+ gsl::not_null<TCArguments*> const& tcargs) {
+ app->add_option_function<std::string>(
+ "--target-cache-write-strategy",
+ [tcargs](auto const& s) {
+ auto strategy = ToTargetCacheWriteStrategy(s);
+ if (strategy) {
+ tcargs->target_cache_write_strategy = *strategy;
+ }
+ else {
+ Logger::Log(LogLevel::Warning,
+ "Ignoring unknown strategy {} to write "
+ "target-level cache.",
+ nlohmann::json(s).dump());
+ }
+ },
+ "Strategy for writing target-cache. (Default: sync)")
+ ->type_name("STRATEGY");
+}
+
static inline auto SetupStageArguments(
gsl::not_null<CLI::App*> const& app,
gsl::not_null<StageArguments*> const& clargs) {