diff options
| author | Kevin Lalumiere <klalumiere@coveo.com> | 2021-01-25 02:11:02 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-24 23:11:02 -0800 |
| commit | f60b947e1311f72c4dae984a1da0ae7eda4e4048 (patch) | |
| tree | 847c6adae437a57636bf8d8832682718821f7f86 /toolsrc/src | |
| parent | b5e8e48b49d02374de8bf07a16546d3a116fabc7 (diff) | |
| download | vcpkg-f60b947e1311f72c4dae984a1da0ae7eda4e4048.tar.gz vcpkg-f60b947e1311f72c4dae984a1da0ae7eda4e4048.zip | |
[vcpkg] Allow to use Nuget's cache for Nuget binary caching sources (fix #15169) (#15512)
* Fix warning on clang version 10.0.0-4ubuntu1
The warning was
```shell
../src/vcpkg/commands.porthistory.cpp:55:14: error: unused function 'is_date' [-Werror,-Wunused-function]
```
* Add environment variable VCPKG_USE_NUGET_CACHE
As the name suggests, this environment variable allow tu use Nuget
cache for Nuget binary caching sources.
* Document NuGet's Cache environment variable
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/vcpkg/binarycaching.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/toolsrc/src/vcpkg/binarycaching.cpp b/toolsrc/src/vcpkg/binarycaching.cpp index 58d0584c4..280a5be28 100644 --- a/toolsrc/src/vcpkg/binarycaching.cpp +++ b/toolsrc/src/vcpkg/binarycaching.cpp @@ -2,6 +2,7 @@ #include <vcpkg/base/downloads.h> #include <vcpkg/base/files.h> #include <vcpkg/base/parse.h> +#include <vcpkg/base/strings.h> #include <vcpkg/base/system.debug.h> #include <vcpkg/base/system.print.h> #include <vcpkg/base/system.process.h> @@ -415,7 +416,11 @@ namespace , m_read_configs(std::move(read_configs)) , m_write_configs(std::move(write_configs)) , m_interactive(interactive) + , m_use_nuget_cache(false) { + const std::string use_nuget_cache = System::get_environment_variable("VCPKG_USE_NUGET_CACHE").value_or(""); + m_use_nuget_cache = Strings::case_insensitive_ascii_equals(use_nuget_cache, "true") || + Strings::case_insensitive_ascii_equals(use_nuget_cache, "1"); } int run_nuget_commandline(const System::Command& cmdline) @@ -531,9 +536,7 @@ namespace .string_arg("-Source") .string_arg(Strings::join(";", m_read_sources)) .string_arg("-ExcludeVersion") - .string_arg("-NoCache") .string_arg("-PreRelease") - .string_arg("-DirectDownload") .string_arg("-PackageSaveMode") .string_arg("nupkg") .string_arg("-Verbosity") @@ -543,6 +546,10 @@ namespace { cmdline.string_arg("-NonInteractive"); } + if (!m_use_nuget_cache) + { + cmdline.string_arg("-DirectDownload").string_arg("-NoCache"); + } cmdlines.push_back(std::move(cmdline)); } @@ -561,9 +568,7 @@ namespace .string_arg("-ConfigFile") .path_arg(cfg) .string_arg("-ExcludeVersion") - .string_arg("-NoCache") .string_arg("-PreRelease") - .string_arg("-DirectDownload") .string_arg("-PackageSaveMode") .string_arg("nupkg") .string_arg("-Verbosity") @@ -573,6 +578,10 @@ namespace { cmdline.string_arg("-NonInteractive"); } + if (!m_use_nuget_cache) + { + cmdline.string_arg("-DirectDownload").string_arg("-NoCache"); + } cmdlines.push_back(std::move(cmdline)); } @@ -735,6 +744,7 @@ namespace std::set<PackageSpec> m_restored; bool m_interactive; + bool m_use_nuget_cache; }; } @@ -1429,6 +1439,9 @@ void vcpkg::help_topic_binary_caching(const VcpkgPaths&) "\n" "if the appropriate environment variables are defined and non-empty.\n"); tbl.blank(); + tbl.text("NuGet's cache is not used by default. To use it for every nuget-based source, set the environment " + "variable `VCPKG_USE_NUGET_CACHE` to `true` (case-insensitive) or `1`.\n"); + tbl.blank(); System::print2(tbl.m_str); const auto& maybe_cachepath = default_cache_path(); if (auto p = maybe_cachepath.get()) |
