summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2025-02-25 10:14:53 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2025-03-10 16:28:59 +0100
commit10eabcf67a3089ce9be57df2389ef6af0123eb8b (patch)
tree8eb81e12f900625a2ac58f89826022b757f5ca85 /src
parent3c2d0d460485bde1e2ccf2d45e6f438adff4ce47 (diff)
downloadjustbuild-10eabcf67a3089ce9be57df2389ef6af0123eb8b.tar.gz
Invocation meta-data: include repository-config digest
To do so, extend multi-repo setup to also return the digest of the configuration file.
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/just_mr/TARGETS2
-rw-r--r--src/other_tools/just_mr/launch.cpp13
-rw-r--r--src/other_tools/just_mr/main.cpp2
-rw-r--r--src/other_tools/just_mr/setup.cpp15
-rw-r--r--src/other_tools/just_mr/setup.hpp6
5 files changed, 27 insertions, 11 deletions
diff --git a/src/other_tools/just_mr/TARGETS b/src/other_tools/just_mr/TARGETS
index 3e3b82c8..2bb592ca 100644
--- a/src/other_tools/just_mr/TARGETS
+++ b/src/other_tools/just_mr/TARGETS
@@ -216,6 +216,7 @@
, ["@", "gsl", "", "gsl"]
, ["@", "json", "", "json"]
, ["src/buildtool/build_engine/expression", "expression_ptr_interface"]
+ , ["src/buildtool/common", "common"]
, ["src/buildtool/common", "user_structs"]
, ["src/buildtool/common/remote", "remote_common"]
, ["src/buildtool/crypto", "hash_function"]
@@ -237,7 +238,6 @@
, ["src/buildtool/multithreading", "task_system"]
, ["src/buildtool/progress_reporting", "base_progress_reporter"]
, ["src/buildtool/serve_api/remote", "serve_api"]
- , ["src/buildtool/storage", "fs_utils"]
, ["src/buildtool/storage", "garbage_collector"]
, ["src/other_tools/just_mr/progress_reporting", "progress"]
, ["src/other_tools/just_mr/progress_reporting", "progress_reporter"]
diff --git a/src/other_tools/just_mr/launch.cpp b/src/other_tools/just_mr/launch.cpp
index 8744ffa3..181fc003 100644
--- a/src/other_tools/just_mr/launch.cpp
+++ b/src/other_tools/just_mr/launch.cpp
@@ -33,6 +33,7 @@
#include <memory>
#include <type_traits>
#include <unordered_map>
+#include <utility>
#include <vector>
#include "fmt/chrono.h"
@@ -86,7 +87,8 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file,
bool supports_remote_properties{false};
bool supports_serve{false};
bool supports_dispatch{false};
- std::optional<std::filesystem::path> mr_config_path{std::nullopt};
+ std::optional<std::pair<std::filesystem::path, std::string>> mr_config_pair{
+ std::nullopt};
std::optional<LockFile> lock{};
if (subcommand and kKnownJustSubcommands.contains(*subcommand)) {
@@ -105,7 +107,7 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file,
config_file, common_args.absent_repository_file);
use_config = true;
- mr_config_path = MultiRepoSetup(config,
+ mr_config_pair = MultiRepoSetup(config,
common_args,
setup_args,
just_cmd_args,
@@ -115,7 +117,7 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file,
storage,
/*interactive=*/false,
multi_repo_tool_name);
- if (not mr_config_path) {
+ if (not mr_config_pair) {
Logger::Log(LogLevel::Error,
"Failed to setup config for calling \"{} {}\"",
common_args.just_path
@@ -141,7 +143,7 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file,
}
if (use_config) {
cmd.emplace_back("-C");
- cmd.emplace_back(mr_config_path->string());
+ cmd.emplace_back(mr_config_pair->first.string());
}
if (use_build_root and forward_build_root) {
cmd.emplace_back("--local-build-root");
@@ -313,6 +315,9 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file,
auto meta = nlohmann::json::object();
meta["time"] = invocation_time;
+ if (mr_config_pair) {
+ meta["configuration"] = mr_config_pair->second;
+ }
meta["cmdline"] = cmd;
// "configuration" -- the blob-identifier of the multi-repo
// configuration
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index c2587681..963d4f97 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -433,7 +433,7 @@ auto main(int argc, char* argv[]) -> int {
// report success
Logger::Log(LogLevel::Info, "Setup completed");
// print config file to stdout
- std::cout << mr_config_path->string() << std::endl;
+ std::cout << mr_config_path->first.string() << std::endl;
return kExitSuccess;
}
diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp
index 5fb8dfed..9ba02fa7 100644
--- a/src/other_tools/just_mr/setup.cpp
+++ b/src/other_tools/just_mr/setup.cpp
@@ -30,6 +30,7 @@
#include "nlohmann/json.hpp"
#include "src/buildtool/build_engine/expression/expression.hpp"
#include "src/buildtool/build_engine/expression/expression_ptr.hpp"
+#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/common/remote/remote_common.hpp"
#include "src/buildtool/common/user_structs.hpp"
#include "src/buildtool/crypto/hash_function.hpp"
@@ -51,7 +52,6 @@
#include "src/buildtool/multithreading/task_system.hpp"
#include "src/buildtool/progress_reporting/base_progress_reporter.hpp"
#include "src/buildtool/serve_api/remote/serve_api.hpp"
-#include "src/buildtool/storage/fs_utils.hpp"
#include "src/buildtool/storage/garbage_collector.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress_reporter.hpp"
@@ -82,7 +82,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
Storage const& native_storage,
bool interactive,
std::string const& multi_repo_tool_name)
- -> std::optional<std::filesystem::path> {
+ -> std::optional<std::pair<std::filesystem::path, std::string>> {
// provide report
Logger::Log(LogLevel::Info, "Performing repositories setup");
// set anchor dir to setup_root; current dir will be reverted when anchor
@@ -536,5 +536,14 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
return std::nullopt;
}
// if successful, return the output config
- return StorageUtils::AddToCAS(native_storage, mr_config.dump(2));
+ auto const& cas = native_storage.CAS();
+ auto digest = cas.StoreBlob(mr_config.dump(2));
+ if (not digest) {
+ return std::nullopt;
+ }
+ auto blob_path = cas.BlobPath(*digest, /*is_executable=*/false);
+ if (not blob_path) {
+ return std::nullopt;
+ }
+ return std::make_optional(std::make_pair(*blob_path, digest->hash()));
}
diff --git a/src/other_tools/just_mr/setup.hpp b/src/other_tools/just_mr/setup.hpp
index 28328b4b..dd5278b4 100644
--- a/src/other_tools/just_mr/setup.hpp
+++ b/src/other_tools/just_mr/setup.hpp
@@ -19,6 +19,7 @@
#include <memory>
#include <optional>
#include <string>
+#include <utility>
#include "src/buildtool/build_engine/expression/configuration.hpp"
#include "src/buildtool/common/retry_cli.hpp"
@@ -26,7 +27,8 @@
#include "src/buildtool/storage/storage.hpp"
#include "src/other_tools/just_mr/cli.hpp"
-/// \brief Setup for a multi-repository build.
+/// \brief Setup for a multi-repository build. Return the pair
+/// of path and hash (as hex-string) of the multi-repository configuration.
[[nodiscard]] auto MultiRepoSetup(
std::shared_ptr<Configuration> const& config,
MultiRepoCommonArguments const& common_args,
@@ -38,6 +40,6 @@
Storage const& native_storage,
bool interactive,
std::string const& multi_repo_tool_name)
- -> std::optional<std::filesystem::path>;
+ -> std::optional<std::pair<std::filesystem::path, std::string>>;
#endif // INCLUDED_SRC_OTHER_TOOLS_JUST_MR_SETUP_HPP