From 4ab218039c4ae33c6f7b89cc8cdfa6434477a9e8 Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Sat, 1 Aug 2020 22:59:33 +0200 Subject: [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 * Remove comment Co-authored-by: nicole mazzuca * rename to VCPKG_DEFAULT_BINARY_CACHE * apply clang format Co-authored-by: nicole mazzuca --- toolsrc/src/vcpkg/binarycaching.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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& default_cache_path() { static auto cachepath = System::get_platform_cache_home().then([](fs::path p) -> ExpectedS { + 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(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; } -- cgit v1.2.3