summaryrefslogtreecommitdiff
path: root/src/buildtool/common/cli.hpp
diff options
context:
space:
mode:
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) {