diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-02-12 09:55:03 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-02-14 18:17:07 +0100 |
commit | a26432b923c1595c0489897ca23b1c8f0eeca6bc (patch) | |
tree | c9921d8d7feeb8a7fea35bb0b1a565ec0f5bee44 /src/buildtool/common/cli.hpp | |
parent | 5314488ffd056ad2ef70005d537d3fdb02ae867b (diff) | |
download | justbuild-a26432b923c1595c0489897ca23b1c8f0eeca6bc.tar.gz |
just add-to-cas: Enable --resolve-special option
Diffstat (limited to 'src/buildtool/common/cli.hpp')
-rw-r--r-- | src/buildtool/common/cli.hpp | 18 |
1 files changed, 18 insertions, 0 deletions
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<ResolveSpecial> 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<std::string>( + "--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( |