mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-04 03:09:07 +08:00
[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>
This commit is contained in:
parent
b228555bbc
commit
4ab218039c
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user