diff options
| author | Billy Robert O'Neal III <bion@microsoft.com> | 2020-03-10 23:44:48 -0700 |
|---|---|---|
| committer | Billy Robert O'Neal III <bion@microsoft.com> | 2020-03-10 23:44:48 -0700 |
| commit | 347d8ef530aaf39ca6d89043ca9ce9a8bac9a70f (patch) | |
| tree | 17154b4e0b16c8c5420941bb8a92e0d676755284 /toolsrc/include | |
| parent | 93045f29748a614ae02b89d06beb9b5a5fd25fc9 (diff) | |
| download | vcpkg-347d8ef530aaf39ca6d89043ca9ce9a8bac9a70f.tar.gz vcpkg-347d8ef530aaf39ca6d89043ca9ce9a8bac9a70f.zip | |
Implement a warning when running vcpkg inside a developer command prompt if the set of packages to install all target a different architecture than the prompt.
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/vcpkg/base/optional.h | 38 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/system.h | 4 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/triplet.h | 7 |
3 files changed, 47 insertions, 2 deletions
diff --git a/toolsrc/include/vcpkg/base/optional.h b/toolsrc/include/vcpkg/base/optional.h index fc3733ead..50586ecc8 100644 --- a/toolsrc/include/vcpkg/base/optional.h +++ b/toolsrc/include/vcpkg/base/optional.h @@ -283,6 +283,21 @@ namespace vcpkg } } + friend bool operator==(const Optional& lhs, const Optional& rhs) + { + if (lhs.m_base.has_value()) + { + if (rhs.m_base.has_value()) + { + return lhs.m_base.value() == rhs.m_base.value(); + } + + return false; + } + + return !rhs.m_base.has_value(); + } + private: details::OptionalStorage<T> m_base; }; @@ -317,4 +332,27 @@ namespace vcpkg if (auto p = o.get()) return t != *p; return true; } + + template<class Container, class Projection> + auto common_projection(const Container& input, Projection proj) + -> Optional<std::decay_t<decltype(proj(*(input.begin())))>> + { + const auto last = input.end(); + auto first = input.begin(); + if (first == last) + { + return nullopt; + } + + const auto& prototype = proj(*first); + while (++first != last) + { + if (prototype != proj(*first)) + { + return nullopt; + } + } + + return prototype; + } } diff --git a/toolsrc/include/vcpkg/base/system.h b/toolsrc/include/vcpkg/base/system.h index 907a692a2..4172f0c50 100644 --- a/toolsrc/include/vcpkg/base/system.h +++ b/toolsrc/include/vcpkg/base/system.h @@ -21,6 +21,8 @@ namespace vcpkg::System Optional<CPUArchitecture> to_cpu_architecture(StringView arch); + ZStringView to_zstring_view(CPUArchitecture arch) noexcept; + CPUArchitecture get_host_processor(); std::vector<CPUArchitecture> get_supported_host_architectures(); @@ -30,4 +32,6 @@ namespace vcpkg::System const Optional<fs::path>& get_program_files_platform_bitness(); int get_num_logical_cores(); + + Optional<CPUArchitecture> guess_visual_studio_prompt_target_architecture(); } diff --git a/toolsrc/include/vcpkg/triplet.h b/toolsrc/include/vcpkg/triplet.h index 8d8c3e879..d836dd230 100644 --- a/toolsrc/include/vcpkg/triplet.h +++ b/toolsrc/include/vcpkg/triplet.h @@ -1,6 +1,8 @@ #pragma once #include <string> +#include <vcpkg/base/system.h> +#include <vcpkg/base/optional.h> namespace vcpkg { @@ -15,17 +17,18 @@ namespace vcpkg static const Triplet X86_WINDOWS; static const Triplet X64_WINDOWS; + static const Triplet ARM_WINDOWS; + static const Triplet ARM64_WINDOWS; static const Triplet X86_UWP; static const Triplet X64_UWP; static const Triplet ARM_UWP; static const Triplet ARM64_UWP; - static const Triplet ARM_WINDOWS; - static const Triplet ARM64_WINDOWS; const std::string& canonical_name() const; const std::string& to_string() const; void to_string(std::string& out) const; size_t hash_code() const; + Optional<System::CPUArchitecture> guess_architecture() const noexcept; bool operator==(Triplet other) const { return this->m_instance == other.m_instance; } bool operator<(Triplet other) const { return canonical_name() < other.canonical_name(); } |
