summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-03-23 12:38:05 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-03-23 16:00:15 +0100
commit680ed52991dfcc0987829f416e02e7eae9239472 (patch)
treeb1a03fe7a3aa7ce28cfac6425c3ce704d76c9e87 /src
parentced48241beb02517b16984093082235a25aa6baa (diff)
downloadjustbuild-680ed52991dfcc0987829f416e02e7eae9239472.tar.gz
just install{,-cas}: offer local CAS as preferred CAS
... to avoid unnecessary downloads and hence speed things up.
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/graph_traverser/graph_traverser.hpp3
-rw-r--r--src/buildtool/main/install_cas.cpp9
-rw-r--r--src/buildtool/main/install_cas.hpp1
-rw-r--r--src/buildtool/main/main.cpp1
4 files changed, 10 insertions, 4 deletions
diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp
index e34df5cf..1d5b821d 100644
--- a/src/buildtool/graph_traverser/graph_traverser.hpp
+++ b/src/buildtool/graph_traverser/graph_traverser.hpp
@@ -571,7 +571,8 @@ class GraphTraverser {
auto output_paths = PrepareOutputPaths(rel_paths);
if (not output_paths or
- not remote_api_->RetrieveToPaths(object_infos, *output_paths)) {
+ not remote_api_->RetrieveToPaths(
+ object_infos, *output_paths, GetLocalApi())) {
Logger::Log(LogLevel::Error, "Could not retrieve outputs.");
return std::nullopt;
}
diff --git a/src/buildtool/main/install_cas.cpp b/src/buildtool/main/install_cas.cpp
index 03c57d71..b56a1069 100644
--- a/src/buildtool/main/install_cas.cpp
+++ b/src/buildtool/main/install_cas.cpp
@@ -61,8 +61,10 @@ namespace {
}
#ifndef BOOTSTRAP_BUILD_TOOL
-auto FetchAndInstallArtifacts(gsl::not_null<IExecutionApi*> const& api,
- FetchArguments const& clargs) -> bool {
+auto FetchAndInstallArtifacts(
+ gsl::not_null<IExecutionApi*> const& api,
+ gsl::not_null<IExecutionApi*> const& alternative_api,
+ FetchArguments const& clargs) -> bool {
auto object_info = ObjectInfoFromLiberalString(clargs.object_id);
if (clargs.output_path) {
@@ -72,7 +74,8 @@ auto FetchAndInstallArtifacts(gsl::not_null<IExecutionApi*> const& api,
}
if (not FileSystemManager::CreateDirectory(output_path.parent_path()) or
- not api->RetrieveToPaths({object_info}, {output_path})) {
+ not api->RetrieveToPaths(
+ {object_info}, {output_path}, alternative_api)) {
Logger::Log(LogLevel::Error, "failed to retrieve artifact.");
return false;
}
diff --git a/src/buildtool/main/install_cas.hpp b/src/buildtool/main/install_cas.hpp
index 562c7bae..e083776e 100644
--- a/src/buildtool/main/install_cas.hpp
+++ b/src/buildtool/main/install_cas.hpp
@@ -31,6 +31,7 @@
#ifndef BOOTSTRAP_BUILD_TOOL
[[nodiscard]] auto FetchAndInstallArtifacts(
gsl::not_null<IExecutionApi*> const& api,
+ gsl::not_null<IExecutionApi*> const& alternative_api,
FetchArguments const& clargs) -> bool;
#endif
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 16385ade..35137d77 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -1299,6 +1299,7 @@ auto main(int argc, char* argv[]) -> int {
if (arguments.cmd == SubCommand::kInstallCas) {
return FetchAndInstallArtifacts(traverser.GetRemoteApi(),
+ traverser.GetLocalApi(),
arguments.fetch)
? kExitSuccess
: kExitFailure;