diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/common/TARGETS | 12 | ||||
-rw-r--r-- | src/buildtool/common/cli.hpp | 4 | ||||
-rw-r--r-- | src/buildtool/common/clidefaults.hpp | 27 | ||||
-rw-r--r-- | src/other_tools/just_mr/TARGETS | 1 | ||||
-rw-r--r-- | src/other_tools/just_mr/cli.hpp | 5 |
5 files changed, 42 insertions, 7 deletions
diff --git a/src/buildtool/common/TARGETS b/src/buildtool/common/TARGETS index 815aa89f..39352c31 100644 --- a/src/buildtool/common/TARGETS +++ b/src/buildtool/common/TARGETS @@ -1,9 +1,17 @@ -{ "cli": +{ "clidefaults": + { "type": ["@", "rules", "CC", "library"] + , "name": ["clidefaults"] + , "hdrs": ["clidefaults.hpp"] + , "stage": ["src", "buildtool", "common"] + , "deps": [["src/buildtool/logging", "log_level"]] + } +, "cli": { "type": ["@", "rules", "CC", "library"] , "name": ["cli"] , "hdrs": ["cli.hpp"] , "deps": - [ ["src/buildtool/build_engine/expression", "expression"] + [ "clidefaults" + , ["src/buildtool/build_engine/expression", "expression"] , ["src/buildtool/compatibility", "compatibility"] , ["src/buildtool/logging", "log_level"] , ["@", "cli11", "", "cli11"] diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp index 5590534a..5a7c5882 100644 --- a/src/buildtool/common/cli.hpp +++ b/src/buildtool/common/cli.hpp @@ -27,10 +27,10 @@ #include "gsl-lite/gsl-lite.hpp" #include "nlohmann/json.hpp" #include "src/buildtool/build_engine/expression/evaluator.hpp" +#include "src/buildtool/common/clidefaults.hpp" #include "src/buildtool/compatibility/compatibility.hpp" #include "src/buildtool/logging/log_level.hpp" -constexpr auto kDefaultLogLevel = LogLevel::Progress; constexpr auto kDefaultTimeout = std::chrono::milliseconds{300000}; /// \brief Arguments common to all commands. @@ -377,7 +377,7 @@ static inline auto SetupCommonBuildArguments( "JSON array with the list of strings representing the launcher to " "prepend actions' commands before being executed locally.") ->type_name("JSON") - ->default_val(nlohmann::json{"env", "--"}.dump()); + ->default_val(nlohmann::json(kDefaultLauncher).dump()); } static inline auto SetupBuildArguments( diff --git a/src/buildtool/common/clidefaults.hpp b/src/buildtool/common/clidefaults.hpp new file mode 100644 index 00000000..88c55b2e --- /dev/null +++ b/src/buildtool/common/clidefaults.hpp @@ -0,0 +1,27 @@ +// Copyright 2023 Huawei Cloud Computing Technology Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef INCLUDED_SRC_BUILDTOOL_COMMON_CLIDEFAULTS_HPP +#define INCLUDED_SRC_BUILDTOOL_COMMON_CLIDEFAULTS_HPP + +#include <string> +#include <vector> + +#include "src/buildtool/logging/log_level.hpp" + +constexpr auto kDefaultLogLevel = LogLevel::Progress; +static inline const std::vector<std::string> kDefaultLauncher = + std::vector<std::string>{"env", "--"}; + +#endif // INCLUDED_SRC_BUILDTOOL_COMMON_CLIDEFAULTS_HPP diff --git a/src/other_tools/just_mr/TARGETS b/src/other_tools/just_mr/TARGETS index 9a73f4f2..04276225 100644 --- a/src/other_tools/just_mr/TARGETS +++ b/src/other_tools/just_mr/TARGETS @@ -59,6 +59,7 @@ , ["@", "fmt", "", "fmt"] , ["@", "gsl-lite", "", "gsl-lite"] , ["@", "json", "", "json"] + , ["src/buildtool/common", "clidefaults"] , ["src/buildtool/execution_api/local", "config"] , ["src/other_tools/just_mr", "utils"] , ["src/buildtool/logging", "log_level"] diff --git a/src/other_tools/just_mr/cli.hpp b/src/other_tools/just_mr/cli.hpp index 5548e073..01622980 100644 --- a/src/other_tools/just_mr/cli.hpp +++ b/src/other_tools/just_mr/cli.hpp @@ -25,12 +25,11 @@ #include "fmt/core.h" #include "gsl-lite/gsl-lite.hpp" #include "nlohmann/json.hpp" +#include "src/buildtool/common/clidefaults.hpp" #include "src/buildtool/execution_api/local/config.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/other_tools/just_mr/utils.hpp" -constexpr auto kDefaultLogLevel = LogLevel::Progress; - /// \brief Arguments common to all just-mr subcommands struct MultiRepoCommonArguments { std::optional<std::filesystem::path> repository_config{std::nullopt}; @@ -112,7 +111,7 @@ static inline void SetupMultiRepoCommonArguments( "prepend actions' commands before being executed locally.") ->type_name("JSON") ->run_callback_for_default() - ->default_val(nlohmann::json{"env", "--"}.dump()); + ->default_val(nlohmann::json(kDefaultLauncher).dump()); app->add_option_function<std::string>( "--distdir", [clargs](auto const& distdir_raw) { |