diff options
| author | ras0219 <533828+ras0219@users.noreply.github.com> | 2020-10-06 12:06:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-06 12:06:26 -0700 |
| commit | 8fe1851e1eb51a971b2b7cfdb8161ac03bbbd6d5 (patch) | |
| tree | be0a98124bdd9702c32692caa58a5ff76b4ae8ad /toolsrc/include | |
| parent | 587dc2ed881b885f715fae623e6fee96ce526fe4 (diff) | |
| download | vcpkg-8fe1851e1eb51a971b2b7cfdb8161ac03bbbd6d5.tar.gz vcpkg-8fe1851e1eb51a971b2b7cfdb8161ac03bbbd6d5.zip | |
[vcpkg] Enable reentrant vcpkg calls (#13751)
* [vcpkg] Enable recursive vcpkg calls
Via envvars VCPKG_COMMAND and VCPKG_X_RECURSIVE_DATA. Child processes can call vcpkg via "$VCPKG_COMMAND <args>" in limited internal circumstances.
* [vcpkg] Address CR comments
* [vcpkg] Do not move through Optional<&> into Optional<T>
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/vcpkg/base/optional.h | 18 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/system.h | 1 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/vcpkgcmdarguments.h | 4 |
3 files changed, 23 insertions, 0 deletions
diff --git a/toolsrc/include/vcpkg/base/optional.h b/toolsrc/include/vcpkg/base/optional.h index 54e370dff..caacf815e 100644 --- a/toolsrc/include/vcpkg/base/optional.h +++ b/toolsrc/include/vcpkg/base/optional.h @@ -29,6 +29,24 @@ namespace vcpkg constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() { } constexpr OptionalStorage(const T& t) : m_is_present(true), m_t(t) { } constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) { } + template<class U, class = std::enable_if_t<!std::is_reference<U>::value>> + constexpr explicit OptionalStorage(Optional<U>&& t) : m_is_present(false), m_inactive() + { + if (auto p = t.get()) + { + m_is_present = true; + new (&m_t) T(std::move(*p)); + } + } + template<class U> + constexpr explicit OptionalStorage(const Optional<U>& t) : m_is_present(false), m_inactive() + { + if (auto p = t.get()) + { + m_is_present = true; + new (&m_t) T(*p); + } + } ~OptionalStorage() noexcept { diff --git a/toolsrc/include/vcpkg/base/system.h b/toolsrc/include/vcpkg/base/system.h index 2340728fd..8e45f6538 100644 --- a/toolsrc/include/vcpkg/base/system.h +++ b/toolsrc/include/vcpkg/base/system.h @@ -8,6 +8,7 @@ namespace vcpkg::System { Optional<std::string> get_environment_variable(ZStringView varname) noexcept; + void set_environment_variable(ZStringView varname, Optional<ZStringView> value) noexcept; const ExpectedS<fs::path>& get_home_dir() noexcept; diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h index 3901000e3..eaf5cc3eb 100644 --- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h +++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h @@ -174,10 +174,13 @@ namespace vcpkg constexpr static StringLiteral REGISTRIES_FEATURE = "registries"; Optional<bool> registries_feature = nullopt; + constexpr static StringLiteral RECURSIVE_DATA_ENV = "VCPKG_X_RECURSIVE_DATA"; + bool binary_caching_enabled() const { return binary_caching.value_or(true); } bool compiler_tracking_enabled() const { return compiler_tracking.value_or(true); } bool registries_enabled() const { return registries_feature.value_or(false); } bool output_json() const { return json.value_or(false); } + bool is_recursive_invocation() const { return m_is_recursive_invocation; } std::string command; std::vector<std::string> command_arguments; @@ -192,6 +195,7 @@ namespace vcpkg void track_feature_flag_metrics() const; private: + bool m_is_recursive_invocation = false; std::unordered_set<std::string> command_switches; std::unordered_map<std::string, std::vector<std::string>> command_options; }; |
