diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/other_tools/just_mr/fetch.cpp | 15 | ||||
-rw-r--r-- | src/other_tools/just_mr/fetch.hpp | 4 | ||||
-rw-r--r-- | src/other_tools/just_mr/launch.cpp | 12 | ||||
-rw-r--r-- | src/other_tools/just_mr/launch.hpp | 3 | ||||
-rw-r--r-- | src/other_tools/just_mr/main.cpp | 21 | ||||
-rw-r--r-- | src/other_tools/just_mr/setup.cpp | 24 | ||||
-rw-r--r-- | src/other_tools/just_mr/setup.hpp | 4 | ||||
-rw-r--r-- | src/other_tools/just_mr/update.cpp | 8 | ||||
-rw-r--r-- | src/other_tools/just_mr/update.hpp | 4 | ||||
-rw-r--r-- | src/other_tools/root_maps/fpath_git_map.cpp | 20 | ||||
-rw-r--r-- | src/other_tools/root_maps/fpath_git_map.hpp | 4 |
11 files changed, 83 insertions, 36 deletions
diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp index 47b4586c..853cd233 100644 --- a/src/other_tools/just_mr/fetch.cpp +++ b/src/other_tools/just_mr/fetch.cpp @@ -37,7 +37,8 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, MultiRepoCommonArguments const& common_args, MultiRepoSetupArguments const& setup_args, MultiRepoFetchArguments const& fetch_args, - MultiRepoRemoteAuthArguments const& auth_args) -> int { + MultiRepoRemoteAuthArguments const& auth_args, + std::string multi_repository_tool_name) -> int { // provide report Logger::Log(LogLevel::Info, "Performing repositories fetch"); @@ -491,9 +492,11 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, &ts, archives_to_fetch, []([[maybe_unused]] auto const& values) {}, - [&failed_archives](auto const& msg, bool fatal) { + [&failed_archives, &multi_repository_tool_name](auto const& msg, + bool fatal) { Logger::Log(fatal ? LogLevel::Error : LogLevel::Warning, - "While performing just-mr fetch:\n{}", + "While performing {} fetch:\n{}", + multi_repository_tool_name, msg); failed_archives = failed_archives or fatal; }); @@ -505,9 +508,11 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config, &ts, git_trees_to_fetch, []([[maybe_unused]] auto const& values) {}, - [&failed_git_trees](auto const& msg, bool fatal) { + [&failed_git_trees, &multi_repository_tool_name](auto const& msg, + bool fatal) { Logger::Log(fatal ? LogLevel::Error : LogLevel::Warning, - "While performing just-mr fetch:\n{}", + "While performing {} fetch:\n{}", + multi_repository_tool_name, msg); failed_git_trees = failed_git_trees or fatal; }); diff --git a/src/other_tools/just_mr/fetch.hpp b/src/other_tools/just_mr/fetch.hpp index 79e4c212..56b526b4 100644 --- a/src/other_tools/just_mr/fetch.hpp +++ b/src/other_tools/just_mr/fetch.hpp @@ -16,6 +16,7 @@ #define INCLUDED_SRC_OTHER_TOOLS_JUST_MR_FETCH_HPP #include <memory> +#include <string> #include "src/buildtool/build_engine/expression/configuration.hpp" #include "src/other_tools/just_mr/cli.hpp" @@ -25,7 +26,8 @@ MultiRepoCommonArguments const& common_args, MultiRepoSetupArguments const& setup_args, MultiRepoFetchArguments const& fetch_args, - MultiRepoRemoteAuthArguments const& auth_args) + MultiRepoRemoteAuthArguments const& auth_args, + std::string multi_repository_tool_name) -> int; #endif // INCLUDED_SRC_OTHER_TOOLS_JUST_MR_FETCH_HPP diff --git a/src/other_tools/just_mr/launch.cpp b/src/other_tools/just_mr/launch.cpp index 2c771836..99496306 100644 --- a/src/other_tools/just_mr/launch.cpp +++ b/src/other_tools/just_mr/launch.cpp @@ -15,6 +15,7 @@ #include "src/other_tools/just_mr/launch.hpp" #include <filesystem> +#include <utility> #include "nlohmann/json.hpp" #include "src/buildtool/build_engine/expression/configuration.hpp" @@ -34,7 +35,8 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file, MultiRepoJustSubCmdsArguments const& just_cmd_args, MultiRepoLogArguments const& log_args, MultiRepoRemoteAuthArguments const& auth_args, - bool forward_build_root) -> int { + bool forward_build_root, + std::string multi_repo_tool_name) -> int { // check if subcmd_name can be taken from additional args auto additional_args_offset = 0U; auto subcommand = just_cmd_args.subcmd_name; @@ -70,10 +72,14 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file, setup_args, just_cmd_args, auth_args, - /*interactive=*/false); + /*interactive=*/false, + std::move(multi_repo_tool_name)); if (not mr_config_path) { Logger::Log(LogLevel::Error, - "Failed to setup config while calling \"just {}\"", + "Failed to setup config for calling \"{} {}\"", + common_args.just_path + ? common_args.just_path->string() + : kDefaultJustPath, *subcommand); return kExitSetupError; } diff --git a/src/other_tools/just_mr/launch.hpp b/src/other_tools/just_mr/launch.hpp index 51f0a38e..11559ffe 100644 --- a/src/other_tools/just_mr/launch.hpp +++ b/src/other_tools/just_mr/launch.hpp @@ -28,6 +28,7 @@ MultiRepoJustSubCmdsArguments const& just_cmd_args, MultiRepoLogArguments const& log_args, MultiRepoRemoteAuthArguments const& auth_args, - bool forward_build_root) -> int; + bool forward_build_root, + std::string multi_repo_tool_name) -> int; #endif // INCLUDED_SRC_OTHER_TOOLS_JUST_MR_LAUNCH_HPP diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp index b1f0ed85..e42f5eca 100644 --- a/src/other_tools/just_mr/main.cpp +++ b/src/other_tools/just_mr/main.cpp @@ -193,6 +193,15 @@ void SetupLogging(MultiRepoLogArguments const& clargs) { auto main(int argc, char* argv[]) -> int { SetupDefaultLogging(); + std::string my_name{}; + if (argc > 0) { + try { + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + my_name = std::filesystem::path(argv[0]).filename().string(); + } catch (...) { + // ignore, as my_name is only used for error messages + } + } try { // get the user-defined arguments auto arguments = ParseCommandLineArguments(argc, argv); @@ -324,7 +333,8 @@ auto main(int argc, char* argv[]) -> int { arguments.just_cmd, arguments.log, arguments.auth, - forward_build_root); + forward_build_root, + my_name); } auto lock = GarbageCollector::SharedLock(); if (not lock) { @@ -352,7 +362,8 @@ auto main(int argc, char* argv[]) -> int { arguments.setup, arguments.just_cmd, arguments.auth, - /*interactive=*/(arguments.cmd == SubCommand::kSetupEnv)); + /*interactive=*/(arguments.cmd == SubCommand::kSetupEnv), + my_name); // dump resulting config to stdout if (not mr_config_path) { return kExitSetupError; @@ -366,7 +377,8 @@ auto main(int argc, char* argv[]) -> int { // Run subcommand `update` if (arguments.cmd == SubCommand::kUpdate) { - return MultiRepoUpdate(config, arguments.common, arguments.update); + return MultiRepoUpdate( + config, arguments.common, arguments.update, my_name); } // Run subcommand `fetch` @@ -392,7 +404,8 @@ auto main(int argc, char* argv[]) -> int { arguments.common, arguments.setup, arguments.fetch, - arguments.auth); + arguments.auth, + my_name); } // Unknown subcommand should fail diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp index 96411363..d582c5ff 100644 --- a/src/other_tools/just_mr/setup.cpp +++ b/src/other_tools/just_mr/setup.cpp @@ -44,7 +44,9 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config, MultiRepoSetupArguments const& setup_args, MultiRepoJustSubCmdsArguments const& just_cmd_args, MultiRepoRemoteAuthArguments const& auth_args, - bool interactive) -> std::optional<std::filesystem::path> { + bool interactive, + std::string multi_repo_tool_name) + -> std::optional<std::filesystem::path> { // provide report Logger::Log(LogLevel::Info, "Performing repositories setup"); // set anchor dir to setup_root; current dir will be reverted when anchor @@ -155,11 +157,15 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config, remote_api ? &(*remote_api) : nullptr, common_args.fetch_absent, common_args.jobs); - auto fpath_git_map = CreateFilePathGitMap(just_cmd_args.subcmd_name, - &critical_git_op_map, - &import_to_git_map, - &resolve_symlinks_map, - common_args.jobs); + auto fpath_git_map = CreateFilePathGitMap( + just_cmd_args.subcmd_name, + &critical_git_op_map, + &import_to_git_map, + &resolve_symlinks_map, + common_args.jobs, + multi_repo_tool_name, + common_args.just_path ? common_args.just_path->string() + : kDefaultJustPath); auto distdir_git_map = CreateDistdirGitMap(&content_cas_map, &import_to_git_map, @@ -236,9 +242,11 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config, mr_config["repositories"][repo] = mr_repos[repo]; } }, - [&failed, interactive](auto const& msg, bool fatal) { + [&failed, interactive, multi_repo_tool_name](auto const& msg, + bool fatal) { Logger::Log(fatal ? LogLevel::Error : LogLevel::Warning, - "While performing just-mr {}:\n{}", + "While performing {} {}:\n{}", + multi_repo_tool_name, interactive ? "setup-env" : "setup", msg); failed = failed or fatal; diff --git a/src/other_tools/just_mr/setup.hpp b/src/other_tools/just_mr/setup.hpp index eea9a24a..df08658f 100644 --- a/src/other_tools/just_mr/setup.hpp +++ b/src/other_tools/just_mr/setup.hpp @@ -18,6 +18,7 @@ #include <filesystem> #include <memory> #include <optional> +#include <string> #include "src/buildtool/build_engine/expression/configuration.hpp" #include "src/other_tools/just_mr/cli.hpp" @@ -29,6 +30,7 @@ MultiRepoSetupArguments const& setup_args, MultiRepoJustSubCmdsArguments const& just_cmd_args, MultiRepoRemoteAuthArguments const& auth_args, - bool interactive) -> std::optional<std::filesystem::path>; + bool interactive, + std::string multi_repo_tool_name) -> std::optional<std::filesystem::path>; #endif // INCLUDED_SRC_OTHER_TOOLS_JUST_MR_SETUP_HPP diff --git a/src/other_tools/just_mr/update.cpp b/src/other_tools/just_mr/update.cpp index 013ff808..25fd60d3 100644 --- a/src/other_tools/just_mr/update.cpp +++ b/src/other_tools/just_mr/update.cpp @@ -31,7 +31,8 @@ auto MultiRepoUpdate(std::shared_ptr<Configuration> const& config, MultiRepoCommonArguments const& common_args, - MultiRepoUpdateArguments const& update_args) -> int { + MultiRepoUpdateArguments const& update_args, + std::string multi_repo_tool_name) -> int { // provide report Logger::Log(LogLevel::Info, "Performing repositories update"); @@ -204,9 +205,10 @@ auto MultiRepoUpdate(std::shared_ptr<Configuration> const& config, ["commit"] = *values[i]; } }, - [&failed](auto const& msg, bool fatal) { + [&failed, &multi_repo_tool_name](auto const& msg, bool fatal) { Logger::Log(fatal ? LogLevel::Error : LogLevel::Warning, - "While performing just-mr update:\n{}", + "While performing {} update:\n{}", + multi_repo_tool_name, msg); failed = failed or fatal; }); diff --git a/src/other_tools/just_mr/update.hpp b/src/other_tools/just_mr/update.hpp index 5535c57c..de70c62a 100644 --- a/src/other_tools/just_mr/update.hpp +++ b/src/other_tools/just_mr/update.hpp @@ -23,7 +23,7 @@ /// \brief Update of Git repos commit information for a multi-repository build. [[nodiscard]] auto MultiRepoUpdate(std::shared_ptr<Configuration> const& config, MultiRepoCommonArguments const& common_args, - MultiRepoUpdateArguments const& update_args) - -> int; + MultiRepoUpdateArguments const& update_args, + std::string multi_repo_tool_name) -> int; #endif // INCLUDED_SRC_OTHER_TOOLS_JUST_MR_UPDATE_HPP diff --git a/src/other_tools/root_maps/fpath_git_map.cpp b/src/other_tools/root_maps/fpath_git_map.cpp index f8199547..79767b95 100644 --- a/src/other_tools/root_maps/fpath_git_map.cpp +++ b/src/other_tools/root_maps/fpath_git_map.cpp @@ -136,15 +136,19 @@ auto CreateFilePathGitMap( gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map, gsl::not_null<ImportToGitMap*> const& import_to_git_map, gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map, - std::size_t jobs) -> FilePathGitMap { + std::size_t jobs, + std::string multi_repo_tool_name, + std::string build_tool_name) -> FilePathGitMap { auto dir_to_git = [current_subcmd, critical_git_op_map, import_to_git_map, - resolve_symlinks_map](auto ts, - auto setter, - auto logger, - auto /*unused*/, - auto const& key) { + resolve_symlinks_map, + multi_repo_tool_name, + build_tool_name](auto ts, + auto setter, + auto logger, + auto /*unused*/, + auto const& key) { // setup wrapped logger auto wrapped_logger = std::make_shared<AsyncMapConsumerLogger>( [logger](auto const& msg, bool fatal) { @@ -251,9 +255,11 @@ auto CreateFilePathGitMap( if (current_subcmd) { (*logger)(fmt::format("Inefficient Git import of file " "path \'{}\'.\nPlease consider using " - "\'just-mr setup\' and \'just {}\' " + "\'{} setup\' and \'{} {}\' " "separately to cache the output.", key.fpath.string(), + multi_repo_tool_name, + build_tool_name, *current_subcmd), /*fatal=*/false); } diff --git a/src/other_tools/root_maps/fpath_git_map.hpp b/src/other_tools/root_maps/fpath_git_map.hpp index 556ff61a..4dbe204f 100644 --- a/src/other_tools/root_maps/fpath_git_map.hpp +++ b/src/other_tools/root_maps/fpath_git_map.hpp @@ -51,7 +51,9 @@ using FilePathGitMap = AsyncMapConsumer<FpathInfo, nlohmann::json>; gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map, gsl::not_null<ImportToGitMap*> const& import_to_git_map, gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map, - std::size_t jobs) -> FilePathGitMap; + std::size_t jobs, + std::string multi_repo_tool_name, + std::string build_tool_name) -> FilePathGitMap; namespace std { template <> |