aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Neumann <30894796+Neumann-A@users.noreply.github.com>2020-08-01 22:59:33 +0200
committerGitHub <noreply@github.com>2020-08-01 13:59:33 -0700
commit4ab218039c4ae33c6f7b89cc8cdfa6434477a9e8 (patch)
tree00883c76fa417e9290abdfde9f9f975c9d9842d3
parentb228555bbcc5897280d46fcfea008ec8f242b34d (diff)
downloadvcpkg-4ab218039c4ae33c6f7b89cc8cdfa6434477a9e8.tar.gz
vcpkg-4ab218039c4ae33c6f7b89cc8cdfa6434477a9e8.zip
[vcpkg] Add environment variable VCPKG_DEFAULT_BINARY_CACHE (#12423)
* [vcpkg] Add environment variable VCPKG_BINARY_CACHE * apply clang-format * change line ending * Update toolsrc/src/vcpkg/binarycaching.cpp Co-authored-by: nicole mazzuca <mazzucan@outlook.com> * Remove comment Co-authored-by: nicole mazzuca <mazzucan@outlook.com> * rename to VCPKG_DEFAULT_BINARY_CACHE * apply clang format Co-authored-by: nicole mazzuca <mazzucan@outlook.com>
-rw-r--r--toolsrc/src/vcpkg/binarycaching.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg/binarycaching.cpp b/toolsrc/src/vcpkg/binarycaching.cpp
index d63d6b3d4..75701d7ee 100644
--- a/toolsrc/src/vcpkg/binarycaching.cpp
+++ b/toolsrc/src/vcpkg/binarycaching.cpp
@@ -663,6 +663,24 @@ namespace
const ExpectedS<fs::path>& default_cache_path()
{
static auto cachepath = System::get_platform_cache_home().then([](fs::path p) -> ExpectedS<fs::path> {
+ auto maybe_cachepath = System::get_environment_variable("VCPKG_DEFAULT_BINARY_CACHE");
+ if (auto p_str = maybe_cachepath.get())
+ {
+ const auto path = fs::u8path(*p_str);
+ const auto status = fs::stdfs::status(path);
+ if (!fs::stdfs::exists(status))
+ return {"Path to VCPKG_DEFAULT_BINARY_CACHE does not exist: " + path.u8string(),
+ expected_right_tag};
+ if (!fs::stdfs::is_directory(status))
+ return {"Value of environment variable VCPKG_DEFAULT_BINARY_CACHE is not a directory: " +
+ path.u8string(),
+ expected_right_tag};
+ if (!path.is_absolute())
+ return {"Value of environment variable VCPKG_DEFAULT_BINARY_CACHE is not absolute: " +
+ path.u8string(),
+ expected_right_tag};
+ return ExpectedS<fs::path>(path);
+ }
p /= fs::u8path("vcpkg/archives");
if (p.is_absolute())
{
@@ -673,6 +691,10 @@ namespace
return {"default path was not absolute: " + p.u8string(), expected_right_tag};
}
});
+ if (cachepath.has_value())
+ Debug::print("Default binary cache path is: ", cachepath.get()->u8string(), '\n');
+ else
+ Debug::print("No binary cache path. Reason: ", cachepath.error(), '\n');
return cachepath;
}