summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/local/local_api.hpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-11-24 11:31:42 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-11-27 15:03:20 +0100
commitcf04253130030bc28866d10aa1f8fe1353643d42 (patch)
treeef7049624771866455105a8dab7b001840139701 /src/buildtool/execution_api/local/local_api.hpp
parentbc09302c2772c979c45ecc716c36e4a70bb484ac (diff)
downloadjustbuild-cf04253130030bc28866d10aa1f8fe1353643d42.tar.gz
Refactoring RepositoryConfig
With the introduction of 'just serve', export targets can now be built also independently from one another based on their corresponding minimal repository configuration, as stored in the target cache key. In this context, this commit changes the RepositoryConfig usage from one global (static) instance to pointers passed as necessary throughout the code.
Diffstat (limited to 'src/buildtool/execution_api/local/local_api.hpp')
-rw-r--r--src/buildtool/execution_api/local/local_api.hpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp
index c04e82f4..f919e9c9 100644
--- a/src/buildtool/execution_api/local/local_api.hpp
+++ b/src/buildtool/execution_api/local/local_api.hpp
@@ -24,6 +24,7 @@
#include "fmt/core.h"
#include "gsl/gsl"
+#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/compatibility/compatibility.hpp"
#include "src/buildtool/compatibility/native_support.hpp"
#include "src/buildtool/execution_api/bazel_msg/bazel_blob.hpp"
@@ -38,6 +39,10 @@
/// \brief API for local execution.
class LocalApi final : public IExecutionApi {
public:
+ explicit LocalApi(std::optional<gsl::not_null<RepositoryConfig*>>
+ repo_config = std::nullopt)
+ : repo_config_{std::move(repo_config)} {}
+
auto CreateAction(
ArtifactDigest const& root_digest,
std::vector<std::string> const& command,
@@ -74,12 +79,13 @@ class LocalApi final : public IExecutionApi {
info.digest, output_paths[i]);
if (not infos) {
if (Compatibility::IsCompatible()) {
- // infos not availablble, and in compatible mode cannot
+ // infos not available, and in compatible mode cannot
// fall back to git
return false;
}
- if (not GitApi().RetrieveToPaths({info},
- {output_paths[i]})) {
+ if (repo_config_ and
+ not GitApi(repo_config_.value())
+ .RetrieveToPaths({info}, {output_paths[i]})) {
return false;
}
}
@@ -92,12 +98,13 @@ class LocalApi final : public IExecutionApi {
info.digest, IsExecutableObject(info.type));
if (not blob_path) {
if (Compatibility::IsCompatible()) {
- // infos not availablble, and in compatible mode cannot
+ // infos not available, and in compatible mode cannot
// fall back to git
return false;
}
- if (not GitApi().RetrieveToPaths({info},
- {output_paths[i]})) {
+ if (repo_config_ and
+ not GitApi(repo_config_.value())
+ .RetrieveToPaths({info}, {output_paths[i]})) {
return false;
}
}
@@ -140,11 +147,13 @@ class LocalApi final : public IExecutionApi {
info.ToString(),
fd);
if (Compatibility::IsCompatible()) {
- // infos not availablble, and in compatible mode cannot
+ // infos not available, and in compatible mode cannot
// fall back to git
return false;
}
- if (not GitApi().RetrieveToFds({info}, {fd}, raw_tree)) {
+ if (repo_config_ and
+ not GitApi(repo_config_.value())
+ .RetrieveToFds({info}, {fd}, raw_tree)) {
return false;
}
}
@@ -413,6 +422,7 @@ class LocalApi final : public IExecutionApi {
}
private:
+ std::optional<gsl::not_null<RepositoryConfig*>> repo_config_{};
gsl::not_null<Storage const*> storage_ = &Storage::Instance();
};