From a26432b923c1595c0489897ca23b1c8f0eeca6bc Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Wed, 12 Feb 2025 09:55:03 +0100 Subject: just add-to-cas: Enable --resolve-special option --- src/buildtool/common/cli.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/buildtool/common/cli.hpp') diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp index c6771cb3..f486a5fd 100644 --- a/src/buildtool/common/cli.hpp +++ b/src/buildtool/common/cli.hpp @@ -35,6 +35,7 @@ #include "src/buildtool/build_engine/expression/evaluator.hpp" #include "src/buildtool/common/clidefaults.hpp" #include "src/buildtool/crypto/hash_function.hpp" +#include "src/buildtool/file_system/symlinks/resolve_special.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/main/build_utils.hpp" @@ -194,6 +195,7 @@ struct GcArguments { struct ToAddArguments { std::filesystem::path location; bool follow_symlinks{}; + std::optional resolve_special{std::nullopt}; }; struct ProtocolArguments final { @@ -679,6 +681,22 @@ static inline auto SetupToAddArguments( clargs->follow_symlinks, "Resolve the positional argument to not be a symbolic link " "before adding it to CAS."); + app->add_option_function( + "--resolve-special", + [clargs](auto const& raw_value) { + if (kResolveSpecialMap.contains(raw_value)) { + clargs->resolve_special = kResolveSpecialMap.at(raw_value); + } + else { + Logger::Log(LogLevel::Warning, + "Ignoring unknown --resolve-special strategy {}.", + nlohmann::json(raw_value).dump()); + } + }, + "Optional strategy for handling special entries (e.g., symlinks) when " + "the content to add is a directory. Default behaviour if missing is to " + "only allow non-upward symlinks. Currently supported values: ignore, " + "tree-upwards, tree-all, all."); } static inline auto SetupGraphArguments( -- cgit v1.2.3