diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-10-12 11:22:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-12 11:22:25 -0700 |
| commit | 85e6b1b36e734c0db50464b07b77589d63c3c875 (patch) | |
| tree | 095289838517a64f06298b1a05ded47a7139d7d9 /toolsrc/include | |
| parent | d7a313c5c356e1641f18cd14ad0ac0c3901bc0bf (diff) | |
| parent | 9c3f9582fb4541a59e4282269e4f6c9c7debcc3e (diff) | |
| download | vcpkg-85e6b1b36e734c0db50464b07b77589d63c3c875.tar.gz vcpkg-85e6b1b36e734c0db50464b07b77589d63c3c875.zip | |
Merge branch 'master' into vtk-components
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/CStringView.h | 44 | ||||
| -rw-r--r-- | toolsrc/include/SourceParagraph.h | 5 | ||||
| -rw-r--r-- | toolsrc/include/Span.h | 30 | ||||
| -rw-r--r-- | toolsrc/include/StatusParagraphs.h | 3 | ||||
| -rw-r--r-- | toolsrc/include/VcpkgPaths.h | 11 | ||||
| -rw-r--r-- | toolsrc/include/coff_file_reader.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/pch.h | 7 | ||||
| -rw-r--r-- | toolsrc/include/triplet.h | 4 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Build.h | 12 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Checks.h | 22 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Commands.h | 43 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Commands_Export.h | 8 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Commands_Export_IFW.h | 25 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Dependencies.h | 8 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Files.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Parse.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Strings.h | 21 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_System.h | 7 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Util.h | 15 |
19 files changed, 220 insertions, 51 deletions
diff --git a/toolsrc/include/CStringView.h b/toolsrc/include/CStringView.h index 282caad3a..c1810b4f1 100644 --- a/toolsrc/include/CStringView.h +++ b/toolsrc/include/CStringView.h @@ -11,13 +11,36 @@ namespace vcpkg constexpr BasicCStringView(const BasicCStringView&) = default; BasicCStringView(const std::basic_string<CharType>& str) : cstr(str.c_str()) {} - constexpr operator const CharType*() const { return cstr; } constexpr const CharType* c_str() const { return cstr; } private: const CharType* cstr; }; + namespace details + { + inline bool vcpkg_strcmp(const char* l, const char* r) { return strcmp(l, r) == 0; } + inline bool vcpkg_strcmp(const wchar_t* l, const wchar_t* r) { return wcscmp(l, r) == 0; } + } + + template<class CharType> + bool operator==(const BasicCStringView<CharType>& l, const BasicCStringView<CharType>& r) + { + return details::vcpkg_strcmp(l.c_str(), r.c_str()); + } + + template<class CharType> + bool operator==(const CharType* l, const BasicCStringView<CharType>& r) + { + return details::vcpkg_strcmp(l, r.c_str()); + } + + template<class CharType> + bool operator==(const BasicCStringView<CharType>& r, const CharType* l) + { + return details::vcpkg_strcmp(l, r.c_str()); + } + template<class CharType> bool operator==(const std::basic_string<CharType>& l, const BasicCStringView<CharType>& r) { @@ -30,6 +53,25 @@ namespace vcpkg return l == r.c_str(); } + // notequals + template<class CharType> + bool operator!=(const BasicCStringView<CharType>& l, const BasicCStringView<CharType>& r) + { + return !details::vcpkg_strcmp(l.c_str(), r.c_str()); + } + + template<class CharType> + bool operator!=(const CharType* l, const BasicCStringView<CharType>& r) + { + return !details::vcpkg_strcmp(l, r.c_str()); + } + + template<class CharType> + bool operator!=(const BasicCStringView<CharType>& r, const CharType* l) + { + return !details::vcpkg_strcmp(l, r.c_str()); + } + template<class CharType> bool operator!=(const BasicCStringView<CharType>& r, const std::basic_string<CharType>& l) { diff --git a/toolsrc/include/SourceParagraph.h b/toolsrc/include/SourceParagraph.h index 8563d83b0..ccf9faf4f 100644 --- a/toolsrc/include/SourceParagraph.h +++ b/toolsrc/include/SourceParagraph.h @@ -7,7 +7,6 @@ #include "vcpkg_expected.h" #include <string> -#include <unordered_map> #include <vector> namespace vcpkg @@ -27,7 +26,7 @@ namespace vcpkg // zlib[uwp] becomes Dependency{"zlib", "uwp"} std::vector<Dependency> expand_qualified_dependencies(const std::vector<std::string>& depends); - const std::string to_string(const Dependency& dep); + std::string to_string(const Dependency& dep); struct FeatureParagraph { @@ -58,7 +57,7 @@ namespace vcpkg std::vector<std::unique_ptr<FeatureParagraph>> feature_paragraphs; }; - void print_error_message(span<const std::unique_ptr<Parse::ParseControlErrorInfo>> error_info_list); + void print_error_message(Span<const std::unique_ptr<Parse::ParseControlErrorInfo>> error_info_list); inline void print_error_message(const std::unique_ptr<Parse::ParseControlErrorInfo>& error_info_list) { return print_error_message({&error_info_list, 1}); diff --git a/toolsrc/include/Span.h b/toolsrc/include/Span.h index b16af2cef..a43e8f992 100644 --- a/toolsrc/include/Span.h +++ b/toolsrc/include/Span.h @@ -2,10 +2,11 @@ #include <array>
#include <cstddef>
+#include <initializer_list>
#include <vector>
template<class T>
-struct span
+struct Span
{
public:
using element_type = T;
@@ -13,18 +14,19 @@ public: using reference = T&;
using iterator = T*;
- constexpr span() noexcept : m_ptr(nullptr), m_count(0) {}
- constexpr span(std::nullptr_t) noexcept : span() {}
- constexpr span(T* ptr, size_t count) noexcept : m_ptr(ptr), m_count(count) {}
- constexpr span(T* ptr_begin, T* ptr_end) noexcept : m_ptr(ptr_begin), m_count(ptr_end - ptr_begin) {}
+ constexpr Span() noexcept : m_ptr(nullptr), m_count(0) {}
+ constexpr Span(std::nullptr_t) noexcept : Span() {}
+ constexpr Span(T* ptr, size_t count) noexcept : m_ptr(ptr), m_count(count) {}
+ constexpr Span(T* ptr_begin, T* ptr_end) noexcept : m_ptr(ptr_begin), m_count(ptr_end - ptr_begin) {}
+ constexpr Span(std::initializer_list<T> l) noexcept : m_ptr(l.begin()), m_count(l.size()) {}
template<size_t N>
- constexpr span(T (&arr)[N]) noexcept : span(arr, N)
+ constexpr Span(T (&arr)[N]) noexcept : Span(arr, N)
{
}
- span(std::vector<T>& v) noexcept : span(v.data(), v.size()) {}
- span(const std::vector<std::remove_const_t<T>>& v) noexcept : span(v.data(), v.size()) {}
+ Span(std::vector<T>& v) noexcept : Span(v.data(), v.size()) {}
+ Span(const std::vector<std::remove_const_t<T>>& v) noexcept : Span(v.data(), v.size()) {}
constexpr iterator begin() const { return m_ptr; }
constexpr iterator end() const { return m_ptr + m_count; }
@@ -36,3 +38,15 @@ private: pointer m_ptr;
size_t m_count;
};
+
+template<class T>
+Span<T> make_span(std::vector<T>& v)
+{
+ return {v.data(), v.size()};
+}
+
+template<class T>
+Span<const T> make_span(const std::vector<T>& v)
+{
+ return {v.data(), v.size()};
+}
diff --git a/toolsrc/include/StatusParagraphs.h b/toolsrc/include/StatusParagraphs.h index bf2ef2f3e..1a9ee6a03 100644 --- a/toolsrc/include/StatusParagraphs.h +++ b/toolsrc/include/StatusParagraphs.h @@ -17,8 +17,7 @@ namespace vcpkg const_iterator find(const PackageSpec& spec) const { return find(spec.name(), spec.triplet()); } const_iterator find(const std::string& name, const Triplet& triplet) const; iterator find(const std::string& name, const Triplet& triplet); - std::vector<std::unique_ptr<StatusParagraph>*> StatusParagraphs::find_all(const std::string& name, - const Triplet& triplet); + std::vector<std::unique_ptr<StatusParagraph>*> find_all(const std::string& name, const Triplet& triplet); iterator find(const std::string& name, const Triplet& triplet, const std::string& feature); const_iterator find_installed(const PackageSpec& spec) const diff --git a/toolsrc/include/VcpkgPaths.h b/toolsrc/include/VcpkgPaths.h index d55c95fe1..d4640fba2 100644 --- a/toolsrc/include/VcpkgPaths.h +++ b/toolsrc/include/VcpkgPaths.h @@ -17,8 +17,10 @@ namespace vcpkg struct Toolset { + fs::path visual_studio_root_path; fs::path dumpbin; fs::path vcvarsall; + std::vector<std::wstring> vcvarsall_options; CWStringView version; std::vector<ToolsetArchOption> supported_architectures; }; @@ -57,12 +59,16 @@ namespace vcpkg const fs::path& get_cmake_exe() const; const fs::path& get_git_exe() const; const fs::path& get_nuget_exe() const; + const fs::path& get_ifw_installerbase_exe() const; + const fs::path& get_ifw_binarycreator_exe() const; + const fs::path& get_ifw_repogen_exe() const; /// <summary>Retrieve a toolset matching a VS version</summary> /// <remarks> /// Valid version strings are "v140", "v141", and "". Empty string gets the latest. /// </remarks> - const Toolset& get_toolset(const std::string& toolset_version) const; + const Toolset& VcpkgPaths::get_toolset(const Optional<std::string>& toolset_version, + const Optional<fs::path>& visual_studio_path) const; Files::Filesystem& get_filesystem() const; @@ -70,6 +76,9 @@ namespace vcpkg Lazy<fs::path> cmake_exe; Lazy<fs::path> git_exe; Lazy<fs::path> nuget_exe; + Lazy<fs::path> ifw_installerbase_exe; + Lazy<fs::path> ifw_binarycreator_exe; + Lazy<fs::path> ifw_repogen_exe; Lazy<std::vector<Toolset>> toolsets; }; } diff --git a/toolsrc/include/coff_file_reader.h b/toolsrc/include/coff_file_reader.h index 09f6447c2..7287211a1 100644 --- a/toolsrc/include/coff_file_reader.h +++ b/toolsrc/include/coff_file_reader.h @@ -3,7 +3,7 @@ #include "filesystem_fs.h" #include <vector> -namespace vcpkg::COFFFileReader +namespace vcpkg::CoffFileReader { struct DllInfo { diff --git a/toolsrc/include/pch.h b/toolsrc/include/pch.h index 770bcf07a..0f34063f8 100644 --- a/toolsrc/include/pch.h +++ b/toolsrc/include/pch.h @@ -2,7 +2,7 @@ #define NOMINMAX #define WIN32_LEAN_AND_MEAN - +#pragma warning(suppress : 4768) #include <windows.h> #include <algorithm> @@ -28,7 +28,10 @@ #include <regex> #include <set> #include <shellapi.h> -#include <shlobj.h> +#pragma warning(push) +#pragma warning(disable : 4768) +#include <Shlobj.h> +#pragma warning(pop) #include <stdexcept> #include <string> #include <sys/timeb.h> diff --git a/toolsrc/include/triplet.h b/toolsrc/include/triplet.h index be3bcf5b3..46a52f8e6 100644 --- a/toolsrc/include/triplet.h +++ b/toolsrc/include/triplet.h @@ -9,7 +9,7 @@ namespace vcpkg struct Triplet { public: - constexpr Triplet() : m_instance(&default_instance) {} + constexpr Triplet() : m_instance(&DEFAULT_INSTANCE) {} static Triplet from_canonical_name(const std::string& triplet_as_string); @@ -26,7 +26,7 @@ namespace vcpkg bool operator==(const Triplet& other) const; private: - static const TripletInstance default_instance; + static const TripletInstance DEFAULT_INSTANCE; constexpr Triplet(const TripletInstance* ptr) : m_instance(ptr) {} diff --git a/toolsrc/include/vcpkg_Build.h b/toolsrc/include/vcpkg_Build.h index e12ed3b1d..5ba675757 100644 --- a/toolsrc/include/vcpkg_Build.h +++ b/toolsrc/include/vcpkg_Build.h @@ -9,7 +9,6 @@ #include <array> #include <map> -#include <unordered_map> #include <vector> namespace vcpkg::Build @@ -56,7 +55,7 @@ namespace vcpkg::Build CASCADED_DUE_TO_MISSING_DEPENDENCIES }; - static constexpr std::array<BuildResult, 5> BuildResult_values = { + static constexpr std::array<BuildResult, 5> BUILD_RESULT_VALUES = { BuildResult::SUCCEEDED, BuildResult::BUILD_FAILED, BuildResult::POST_BUILD_CHECKS_FAILED, @@ -80,7 +79,8 @@ namespace vcpkg::Build std::string target_architecture; std::string cmake_system_name; std::string cmake_system_version; - std::string platform_toolset; + Optional<std::string> platform_toolset; + Optional<fs::path> visual_studio_path; }; std::wstring make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset); @@ -143,7 +143,7 @@ namespace vcpkg::Build COUNT, }; - constexpr std::array<BuildPolicy, size_t(BuildPolicy::COUNT)> g_all_policies = { + constexpr std::array<BuildPolicy, size_t(BuildPolicy::COUNT)> G_ALL_POLICIES = { BuildPolicy::EMPTY_PACKAGE, BuildPolicy::DLLS_WITHOUT_LIBS, BuildPolicy::ONLY_RELEASE_CRT, @@ -159,9 +159,9 @@ namespace vcpkg::Build BuildPolicies() = default; BuildPolicies(std::map<BuildPolicy, bool>&& map) : m_policies(std::move(map)) {} - inline bool is_enabled(BuildPolicy policy) const + bool is_enabled(BuildPolicy policy) const { - auto it = m_policies.find(policy); + const auto it = m_policies.find(policy); if (it != m_policies.cend()) return it->second; return false; } diff --git a/toolsrc/include/vcpkg_Checks.h b/toolsrc/include/vcpkg_Checks.h index 01cb7209b..ce486ac19 100644 --- a/toolsrc/include/vcpkg_Checks.h +++ b/toolsrc/include/vcpkg_Checks.h @@ -20,33 +20,35 @@ namespace vcpkg::Checks [[noreturn]] inline void exit_success(const LineInfo& line_info) { exit_with_code(line_info, EXIT_SUCCESS); } // Display an error message to the user and exit the tool. - [[noreturn]] void exit_with_message(const LineInfo& line_info, const CStringView errorMessage); + [[noreturn]] void exit_with_message(const LineInfo& line_info, const CStringView error_message); template<class Arg1, class... Args> // Display an error message to the user and exit the tool. [[noreturn]] void exit_with_message(const LineInfo& line_info, - const char* errorMessageTemplate, - const Arg1 errorMessageArg1, - const Args&... errorMessageArgs) + const char* error_message_template, + const Arg1 error_message_arg1, + const Args&... error_message_args) { - exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...)); + exit_with_message(line_info, + Strings::format(error_message_template, error_message_arg1, error_message_args...)); } void check_exit(const LineInfo& line_info, bool expression); - void check_exit(const LineInfo& line_info, bool expression, const CStringView errorMessage); + void check_exit(const LineInfo& line_info, bool expression, const CStringView error_message); template<class Conditional, class Arg1, class... Args> void check_exit(const LineInfo& line_info, Conditional&& expression, - const char* errorMessageTemplate, - const Arg1 errorMessageArg1, - const Args&... errorMessageArgs) + const char* error_message_template, + const Arg1 error_message_arg1, + const Args&... error_message_args) { if (!expression) { // Only create the string if the expression is false - exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...)); + exit_with_message(line_info, + Strings::format(error_message_template, error_message_arg1, error_message_args...)); } } } diff --git a/toolsrc/include/vcpkg_Commands.h b/toolsrc/include/vcpkg_Commands.h index 756a12f01..7cfa2760e 100644 --- a/toolsrc/include/vcpkg_Commands.h +++ b/toolsrc/include/vcpkg_Commands.h @@ -33,6 +33,22 @@ namespace vcpkg::Commands namespace Install { + enum class KeepGoing + { + NO = 0, + YES + }; + + inline KeepGoing to_keep_going(const bool value) { return value ? KeepGoing::YES : KeepGoing::NO; } + + enum class PrintSummary + { + NO = 0, + YES + }; + + inline PrintSummary to_print_summary(const bool value) { return value ? PrintSummary::YES : PrintSummary::NO; } + struct InstallDir { static InstallDir from_destination_root(const fs::path& destination_root, @@ -67,6 +83,14 @@ namespace vcpkg::Commands InstallResult install_package(const VcpkgPaths& paths, const BinaryControlFile& binary_paragraph, StatusParagraphs* status_db); + + void perform_and_exit(const std::vector<Dependencies::AnyAction>& action_plan, + const Build::BuildPackageOptions& install_plan_options, + const KeepGoing keep_going, + const PrintSummary print_summary, + const VcpkgPaths& paths, + StatusParagraphs& status_db); + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet); } @@ -82,6 +106,19 @@ namespace vcpkg::Commands namespace Remove { + enum class Purge + { + NO = 0, + YES + }; + + inline Purge to_purge(const bool value) { return value ? Purge::YES : Purge::NO; } + + void perform_remove_plan_action(const VcpkgPaths& paths, + const Dependencies::RemovePlanAction& action, + const Purge purge, + StatusParagraphs& status_db); + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet); void remove_package(const VcpkgPaths& paths, const PackageSpec& spec, StatusParagraphs* status_db); } @@ -157,6 +194,11 @@ namespace vcpkg::Commands void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); } + namespace Autocomplete + { + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); + } + namespace Help { void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); @@ -173,6 +215,7 @@ namespace vcpkg::Commands namespace Version { const std::string& version(); + void warn_if_vcpkg_version_mismatch(const VcpkgPaths& paths); void perform_and_exit(const VcpkgCmdArguments& args); } diff --git a/toolsrc/include/vcpkg_Commands_Export.h b/toolsrc/include/vcpkg_Commands_Export.h new file mode 100644 index 000000000..6e698c1b4 --- /dev/null +++ b/toolsrc/include/vcpkg_Commands_Export.h @@ -0,0 +1,8 @@ +#pragma once + +#include "VcpkgPaths.h" + +namespace vcpkg::Commands::Export +{ + void export_integration_files(const fs::path& raw_exported_dir_path, const VcpkgPaths& paths); +} diff --git a/toolsrc/include/vcpkg_Commands_Export_IFW.h b/toolsrc/include/vcpkg_Commands_Export_IFW.h new file mode 100644 index 000000000..7bee45eaf --- /dev/null +++ b/toolsrc/include/vcpkg_Commands_Export_IFW.h @@ -0,0 +1,25 @@ +#pragma once + +#include "VcpkgPaths.h" +#include "vcpkg_Dependencies.h" +#include "vcpkg_Files.h" + +#include <string> +#include <vector> + +namespace vcpkg::Commands::Export::IFW +{ + struct Options + { + Optional<std::string> maybe_repository_url; + Optional<std::string> maybe_packages_dir_path; + Optional<std::string> maybe_repository_dir_path; + Optional<std::string> maybe_config_file_path; + Optional<std::string> maybe_installer_file_path; + }; + + void do_export(const std::vector<Dependencies::ExportPlanAction>& export_plan, + const std::string& export_id, + const Options& ifw_options, + const VcpkgPaths& paths); +} diff --git a/toolsrc/include/vcpkg_Dependencies.h b/toolsrc/include/vcpkg_Dependencies.h index c1f6ad9a5..d67122e48 100644 --- a/toolsrc/include/vcpkg_Dependencies.h +++ b/toolsrc/include/vcpkg_Dependencies.h @@ -45,9 +45,9 @@ namespace vcpkg::Dependencies InstallPlanAction(); - InstallPlanAction::InstallPlanAction(const PackageSpec& spec, - const std::unordered_set<std::string>& features, - const RequestType& request_type); + InstallPlanAction(const PackageSpec& spec, + const std::unordered_set<std::string>& features, + const RequestType& request_type); InstallPlanAction(const PackageSpec& spec, const AnyParagraph& any_paragraph, const RequestType& request_type); InstallPlanAction(const PackageSpec& spec, const SourceControlFile& any_paragraph, @@ -89,6 +89,8 @@ namespace vcpkg::Dependencies Optional<InstallPlanAction> install_plan; Optional<RemovePlanAction> remove_plan; + + const PackageSpec& spec() const; }; enum class ExportPlanType diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h index ad29ffa14..855e8ea45 100644 --- a/toolsrc/include/vcpkg_Files.h +++ b/toolsrc/include/vcpkg_Files.h @@ -38,4 +38,6 @@ namespace vcpkg::Files bool has_invalid_chars_for_filesystem(const std::string& s); void print_paths(const std::vector<fs::path>& paths); + + std::vector<fs::path> find_from_PATH(const std::wstring& name); } diff --git a/toolsrc/include/vcpkg_Parse.h b/toolsrc/include/vcpkg_Parse.h index e663448b9..2dda033b3 100644 --- a/toolsrc/include/vcpkg_Parse.h +++ b/toolsrc/include/vcpkg_Parse.h @@ -26,7 +26,7 @@ namespace vcpkg::Parse ParagraphParser(RawParagraph&& fields) : fields(std::move(fields)) {} void required_field(const std::string& fieldname, std::string& out); - std::string optional_field(const std::string& fieldname); + std::string optional_field(const std::string& fieldname) const; std::unique_ptr<ParseControlErrorInfo> error_info(const std::string& name) const; private: diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h index e94742c8f..c44ce2b99 100644 --- a/toolsrc/include/vcpkg_Strings.h +++ b/toolsrc/include/vcpkg_Strings.h @@ -36,6 +36,9 @@ namespace vcpkg::Strings::details namespace vcpkg::Strings { + static constexpr const char* EMPTY = ""; + static constexpr const wchar_t* WEMPTY = L""; + template<class... Args> std::string format(const char* fmtstr, const Args&... args) { @@ -62,23 +65,25 @@ namespace vcpkg::Strings std::string ascii_to_lowercase(const std::string& input); + bool case_insensitive_ascii_starts_with(const std::string& s, const std::string& pattern); + template<class Container, class Transformer, class CharType> std::basic_string<CharType> join(const CharType* delimiter, const Container& v, Transformer transformer) { - if (v.size() == 0) + const auto begin = v.begin(); + const auto end = v.end(); + + if (begin == end) { return std::basic_string<CharType>(); } std::basic_string<CharType> output; - size_t size = v.size(); - - output.append(transformer(v[0])); - - for (size_t i = 1; i < size; ++i) + output.append(transformer(*begin)); + for (auto it = std::next(begin); it != end; ++it) { output.append(delimiter); - output.append(transformer(v[i])); + output.append(transformer(*it)); } return output; @@ -86,7 +91,7 @@ namespace vcpkg::Strings template<class Container, class CharType> std::basic_string<CharType> join(const CharType* delimiter, const Container& v) { - using Element = decltype(v[0]); + using Element = decltype(*v.begin()); return join(delimiter, v, [](const Element& x) -> const Element& { return x; }); } diff --git a/toolsrc/include/vcpkg_System.h b/toolsrc/include/vcpkg_System.h index 32da6e39c..65f80ae6d 100644 --- a/toolsrc/include/vcpkg_System.h +++ b/toolsrc/include/vcpkg_System.h @@ -23,7 +23,7 @@ namespace vcpkg::System ExitCodeAndOutput cmd_execute_and_capture_output(const CWStringView cmd_line); - std::wstring create_powershell_script_cmd(const fs::path& script_path, const CWStringView args = L""); + std::wstring create_powershell_script_cmd(const fs::path& script_path, const CWStringView args = Strings::WEMPTY); enum class Color { @@ -32,6 +32,7 @@ namespace vcpkg::System warning = 14, }; + void println(); void print(const CStringView message); void println(const CStringView message); void print(const Color c, const CStringView message); @@ -79,9 +80,9 @@ namespace vcpkg::System std::vector<CPUArchitecture> get_supported_host_architectures(); - const fs::path& get_ProgramFiles_32_bit(); + const fs::path& get_program_files_32_bit(); - const fs::path& get_ProgramFiles_platform_bitness(); + const fs::path& get_program_files_platform_bitness(); } namespace vcpkg::Debug diff --git a/toolsrc/include/vcpkg_Util.h b/toolsrc/include/vcpkg_Util.h index c76ca01ac..facb7dd26 100644 --- a/toolsrc/include/vcpkg_Util.h +++ b/toolsrc/include/vcpkg_Util.h @@ -38,6 +38,12 @@ namespace vcpkg::Util } template<class Container, class Pred> + void stable_keep_if(Container& cont, Pred pred) + { + cont.erase(std::stable_partition(cont.begin(), cont.end(), pred), cont.end()); + } + + template<class Container, class Pred> void unstable_keep_if(Container& cont, Pred pred) { cont.erase(std::partition(cont.begin(), cont.end(), pred), cont.end()); @@ -61,6 +67,15 @@ namespace vcpkg::Util return std::find_if(cont.cbegin(), cont.cend(), pred); } + template<class Container> + using ElementT = std::remove_reference_t<decltype(*begin(std::declval<Container>()))>; + + template<class Container, class T = ElementT<Container>> + std::vector<T*> element_pointers(Container&& cont) + { + return fmap(cont, [](auto&& x) { return &x; }); + } + template<class Container, class Pred> auto find_if_not(const Container& cont, Pred pred) { |
