From b486be5eb3b12c0a6fa0a81992768340317ec5c2 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sun, 15 Oct 2017 23:24:34 -0700 Subject: Introduce VcpkgPaths::get_available_triplets() --- toolsrc/include/vcpkg/vcpkgpaths.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h index fb9285a84..32dd2e833 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -36,6 +36,7 @@ namespace vcpkg fs::path build_info_file_path(const PackageSpec& spec) const; fs::path listfile_path(const BinaryParagraph& pgh) const; + const std::vector& get_available_triplets() const; bool is_valid_triplet(const Triplet& t) const; fs::path root; @@ -74,6 +75,7 @@ namespace vcpkg Files::Filesystem& get_filesystem() const; private: + Lazy> available_triplets; Lazy cmake_exe; Lazy git_exe; Lazy nuget_exe; -- cgit v1.2.3 From 798f8a91e43bfdeda8113639ff262f42e5ab6f84 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sun, 15 Oct 2017 23:53:35 -0700 Subject: Introduce Vectors::concatenate() --- toolsrc/include/vcpkg/base/util.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/util.h b/toolsrc/include/vcpkg/base/util.h index 3834580b6..4f06a8231 100644 --- a/toolsrc/include/vcpkg/base/util.h +++ b/toolsrc/include/vcpkg/base/util.h @@ -7,6 +7,18 @@ namespace vcpkg::Util { + template + using ElementT = std::remove_reference_t()))>; + + namespace Vectors + { + template> + void concatenate(std::vector* augend, const Container& addend) + { + augend->insert(augend->end(), addend.begin(), addend.end()); + } + } + template using FmapOut = decltype(std::declval()(*begin(std::declval()))); @@ -71,9 +83,6 @@ namespace vcpkg::Util return std::find_if(begin(cont), end(cont), pred); } - template - using ElementT = std::remove_reference_t()))>; - template> std::vector element_pointers(Container&& cont) { @@ -153,4 +162,4 @@ namespace vcpkg::Util std::unique_lock m_lock; T& m_ptr; }; -} \ No newline at end of file +} -- cgit v1.2.3 From 7214c3583bdf569bc873305908ec109a6c8716cc Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Mon, 16 Oct 2017 11:44:04 -0700 Subject: [vcpkg] Push use of UTF-16 to only around Win32 call boundaries. --- toolsrc/include/pch.h | 18 +++++++++++--- toolsrc/include/vcpkg/base/cstringview.h | 1 + toolsrc/include/vcpkg/base/expected.h | 2 +- toolsrc/include/vcpkg/base/files.h | 14 +++++++---- toolsrc/include/vcpkg/base/graphs.h | 6 ++--- toolsrc/include/vcpkg/base/strings.h | 19 +++++---------- toolsrc/include/vcpkg/base/system.h | 15 ++++++------ toolsrc/include/vcpkg/base/util.h | 3 ++- toolsrc/include/vcpkg/build.h | 2 +- toolsrc/include/vcpkg/dependencies.h | 5 +++- toolsrc/include/vcpkg/packagespec.h | 33 ++++++++++++++------------ toolsrc/include/vcpkg/packagespecparseresult.h | 2 +- toolsrc/include/vcpkg/paragraphparseresult.h | 11 +++++---- toolsrc/include/vcpkg/sourceparagraph.h | 2 +- toolsrc/include/vcpkg/triplet.h | 11 +++++---- toolsrc/include/vcpkg/vcpkgcmdarguments.h | 4 ++++ toolsrc/include/vcpkg/vcpkglib.h | 15 ++++++------ toolsrc/include/vcpkg/vcpkgpaths.h | 8 +++---- 18 files changed, 100 insertions(+), 71 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/pch.h b/toolsrc/include/pch.h index 8333eb927..5c31fbbd1 100644 --- a/toolsrc/include/pch.h +++ b/toolsrc/include/pch.h @@ -1,5 +1,6 @@ #pragma once +#if defined(_WIN32) #define NOMINMAX #define WIN32_LEAN_AND_MEAN @@ -9,6 +10,13 @@ #pragma warning(suppress : 4768) #include +#include +#include +#include +#else +#include +#endif + #include #include #include @@ -19,7 +27,12 @@ #include #include #include +#if defined(_WIN32) #include +#else +#include +#endif +#include #include #include #include @@ -28,18 +41,17 @@ #include #include #include -#include #include #include -#include #include #include #include +#include #include +#include #include #include #include #include #include #include -#include diff --git a/toolsrc/include/vcpkg/base/cstringview.h b/toolsrc/include/vcpkg/base/cstringview.h index 341830f05..eac204f97 100644 --- a/toolsrc/include/vcpkg/base/cstringview.h +++ b/toolsrc/include/vcpkg/base/cstringview.h @@ -1,5 +1,6 @@ #pragma once +#include #include namespace vcpkg diff --git a/toolsrc/include/vcpkg/base/expected.h b/toolsrc/include/vcpkg/base/expected.h index a946c442e..b3b81ae81 100644 --- a/toolsrc/include/vcpkg/base/expected.h +++ b/toolsrc/include/vcpkg/base/expected.h @@ -33,7 +33,7 @@ namespace vcpkg ErrorHolder() = default; ErrorHolder(const std::error_code& err) : m_err(err) {} - constexpr bool has_error() const { return bool(m_err); } + bool has_error() const { return bool(m_err); } const std::error_code& error() const { return m_err; } std::error_code& error() { return m_err; } diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h index f4bcf742c..63cf3c6fd 100644 --- a/toolsrc/include/vcpkg/base/files.h +++ b/toolsrc/include/vcpkg/base/files.h @@ -2,7 +2,11 @@ #include +#if defined(_WIN32) #include +#else +#include +#endif namespace fs { @@ -19,7 +23,7 @@ namespace fs namespace vcpkg::Files { - __interface Filesystem + struct Filesystem { virtual Expected read_contents(const fs::path& file_path) const = 0; virtual Expected> read_lines(const fs::path& file_path) const = 0; @@ -40,8 +44,10 @@ namespace vcpkg::Files virtual bool create_directory(const fs::path& path, std::error_code& ec) = 0; virtual bool create_directories(const fs::path& path, std::error_code& ec) = 0; virtual void copy(const fs::path& oldpath, const fs::path& newpath, fs::copy_options opts) = 0; - virtual bool copy_file( - const fs::path& oldpath, const fs::path& newpath, fs::copy_options opts, std::error_code& ec) = 0; + virtual bool copy_file(const fs::path& oldpath, + const fs::path& newpath, + fs::copy_options opts, + std::error_code& ec) = 0; virtual fs::file_status status(const fs::path& path, std::error_code& ec) const = 0; }; @@ -53,5 +59,5 @@ namespace vcpkg::Files void print_paths(const std::vector& paths); - std::vector find_from_PATH(const std::wstring& name); + std::vector find_from_PATH(const std::string& name); } diff --git a/toolsrc/include/vcpkg/base/graphs.h b/toolsrc/include/vcpkg/base/graphs.h index ff56cb298..b585d2bb9 100644 --- a/toolsrc/include/vcpkg/base/graphs.h +++ b/toolsrc/include/vcpkg/base/graphs.h @@ -20,11 +20,11 @@ namespace vcpkg::Graphs }; template - __interface AdjacencyProvider + struct AdjacencyProvider { - std::vector adjacency_list(const U& vertex) const; + virtual std::vector adjacency_list(const U& vertex) const = 0; - U load_vertex_data(const V& vertex) const; + virtual U load_vertex_data(const V& vertex) const = 0; }; template diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h index 59823deb8..93b36a29d 100644 --- a/toolsrc/include/vcpkg/base/strings.h +++ b/toolsrc/include/vcpkg/base/strings.h @@ -16,15 +16,11 @@ namespace vcpkg::Strings::details inline const char* to_printf_arg(const char* s) { return s; } - inline int to_printf_arg(const int s) { return s; } - - inline long long to_printf_arg(const long long s) { return s; } - - inline unsigned long to_printf_arg(const unsigned long s) { return s; } - - inline size_t to_printf_arg(const size_t s) { return s; } - - inline double to_printf_arg(const double s) { return s; } + template::value>> + inline T to_printf_arg(T s) + { + return s; + } std::string format_internal(const char* fmtstr, ...); @@ -37,9 +33,6 @@ namespace vcpkg::Strings::details namespace vcpkg::Strings { - static constexpr const char* EMPTY = ""; - static constexpr const wchar_t* WEMPTY = L""; - template std::string format(const char* fmtstr, const Args&... args) { @@ -62,7 +55,7 @@ namespace vcpkg::Strings bool case_insensitive_ascii_contains(const std::string& s, const std::string& pattern); - bool case_insensitive_ascii_compare(const CStringView left, const CStringView right); + bool case_insensitive_ascii_equals(const CStringView left, const CStringView right); std::string ascii_to_lowercase(const std::string& input); diff --git a/toolsrc/include/vcpkg/base/system.h b/toolsrc/include/vcpkg/base/system.h index a2e8f3f45..f2344c919 100644 --- a/toolsrc/include/vcpkg/base/system.h +++ b/toolsrc/include/vcpkg/base/system.h @@ -4,7 +4,6 @@ #include #include -#include namespace vcpkg::System { @@ -18,13 +17,13 @@ namespace vcpkg::System std::string output; }; - int cmd_execute_clean(const CWStringView cmd_line); + int cmd_execute_clean(const CStringView cmd_line); - int cmd_execute(const CWStringView cmd_line); + int cmd_execute(const CStringView cmd_line); - ExitCodeAndOutput cmd_execute_and_capture_output(const CWStringView cmd_line); + ExitCodeAndOutput cmd_execute_and_capture_output(const CStringView cmd_line); - std::wstring create_powershell_script_cmd(const fs::path& script_path, const CWStringView args = Strings::WEMPTY); + std::string create_powershell_script_cmd(const fs::path& script_path, const CStringView args = ""); enum class Color { @@ -63,9 +62,11 @@ namespace vcpkg::System return System::println(c, Strings::format(messageTemplate, messageArg1, messageArgs...)); } - Optional get_environment_variable(const CWStringView varname) noexcept; + Optional get_environment_variable(const CStringView varname) noexcept; - Optional get_registry_string(HKEY base, const CWStringView subkey, const CWStringView valuename); + Optional get_registry_string(void* base_hkey, + const CWStringView subkey, + const CWStringView valuename); enum class CPUArchitecture { diff --git a/toolsrc/include/vcpkg/base/util.h b/toolsrc/include/vcpkg/base/util.h index 4f06a8231..d5db6b6ee 100644 --- a/toolsrc/include/vcpkg/base/util.h +++ b/toolsrc/include/vcpkg/base/util.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -98,7 +99,7 @@ namespace vcpkg::Util } template - void group_by(const Container& cont, _Inout_ std::map>* output, Func&& f) + void group_by(const Container& cont, std::map>* output, Func&& f) { for (const V& element : cont) { diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h index f146e9951..774e25922 100644 --- a/toolsrc/include/vcpkg/build.h +++ b/toolsrc/include/vcpkg/build.h @@ -96,7 +96,7 @@ namespace vcpkg::Build Optional visual_studio_path; }; - std::wstring make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset); + std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset); struct ExtendedBuildResult { diff --git a/toolsrc/include/vcpkg/dependencies.h b/toolsrc/include/vcpkg/dependencies.h index 2301dbc36..585338ae2 100644 --- a/toolsrc/include/vcpkg/dependencies.h +++ b/toolsrc/include/vcpkg/dependencies.h @@ -115,7 +115,10 @@ namespace vcpkg::Dependencies RequestType request_type; }; - __interface PortFileProvider { virtual const SourceControlFile& get_control_file(const std::string& spec) const; }; + struct PortFileProvider + { + virtual const SourceControlFile& get_control_file(const std::string& spec) const = 0; + }; struct MapPortFile : Util::ResourceBase, PortFileProvider { diff --git a/toolsrc/include/vcpkg/packagespec.h b/toolsrc/include/vcpkg/packagespec.h index ee34f14a3..60c99782e 100644 --- a/toolsrc/include/vcpkg/packagespec.h +++ b/toolsrc/include/vcpkg/packagespec.h @@ -76,20 +76,23 @@ namespace vcpkg bool operator!=(const PackageSpec& left, const PackageSpec& right); } -template<> -struct std::hash +namespace std { - size_t operator()(const vcpkg::PackageSpec& value) const + template<> + struct hash { - size_t hash = 17; - hash = hash * 31 + std::hash()(value.name()); - hash = hash * 31 + std::hash()(value.triplet()); - return hash; - } -}; - -template<> -struct std::equal_to -{ - bool operator()(const vcpkg::PackageSpec& left, const vcpkg::PackageSpec& right) const { return left == right; } -}; + size_t operator()(const vcpkg::PackageSpec& value) const + { + size_t hash = 17; + hash = hash * 31 + std::hash()(value.name()); + hash = hash * 31 + std::hash()(value.triplet()); + return hash; + } + }; + + template<> + struct equal_to + { + bool operator()(const vcpkg::PackageSpec& left, const vcpkg::PackageSpec& right) const { return left == right; } + }; +} diff --git a/toolsrc/include/vcpkg/packagespecparseresult.h b/toolsrc/include/vcpkg/packagespecparseresult.h index 8a56574fd..dd91c9a67 100644 --- a/toolsrc/include/vcpkg/packagespecparseresult.h +++ b/toolsrc/include/vcpkg/packagespecparseresult.h @@ -20,7 +20,7 @@ namespace vcpkg ErrorHolder() : m_err(PackageSpecParseResult::SUCCESS) {} ErrorHolder(PackageSpecParseResult err) : m_err(err) {} - constexpr bool has_error() const { return m_err != PackageSpecParseResult::SUCCESS; } + bool has_error() const { return m_err != PackageSpecParseResult::SUCCESS; } const PackageSpecParseResult& error() const { return m_err; } PackageSpecParseResult& error() { return m_err; } diff --git a/toolsrc/include/vcpkg/paragraphparseresult.h b/toolsrc/include/vcpkg/paragraphparseresult.h index abdd9eecd..558715bbc 100644 --- a/toolsrc/include/vcpkg/paragraphparseresult.h +++ b/toolsrc/include/vcpkg/paragraphparseresult.h @@ -26,8 +26,11 @@ namespace vcpkg ParagraphParseResult to_paragraph_parse_result(std::error_code ec); } -// Enable implicit conversion to std::error_code -template<> -struct std::is_error_code_enum : ::std::true_type +namespace std { -}; + // Enable implicit conversion to std::error_code + template<> + struct is_error_code_enum : ::std::true_type + { + }; +} \ No newline at end of file diff --git a/toolsrc/include/vcpkg/sourceparagraph.h b/toolsrc/include/vcpkg/sourceparagraph.h index 0a02e4cda..dcbbc1c3b 100644 --- a/toolsrc/include/vcpkg/sourceparagraph.h +++ b/toolsrc/include/vcpkg/sourceparagraph.h @@ -3,8 +3,8 @@ #include #include -#include #include +#include #include #include diff --git a/toolsrc/include/vcpkg/triplet.h b/toolsrc/include/vcpkg/triplet.h index 46a52f8e6..50d731593 100644 --- a/toolsrc/include/vcpkg/triplet.h +++ b/toolsrc/include/vcpkg/triplet.h @@ -36,8 +36,11 @@ namespace vcpkg bool operator!=(const Triplet& left, const Triplet& right); } -template<> -struct std::hash +namespace std { - size_t operator()(const vcpkg::Triplet& t) const { return t.hash_code(); } -}; + template<> + struct hash + { + size_t operator()(const vcpkg::Triplet& t) const { return t.hash_code(); } + }; +} \ No newline at end of file diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h index 8b1d766b6..d9895f4b8 100644 --- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h +++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h @@ -19,7 +19,11 @@ namespace vcpkg struct VcpkgCmdArguments { +#if defined(_WIN32) static VcpkgCmdArguments create_from_command_line(const int argc, const wchar_t* const* const argv); +#else + static VcpkgCmdArguments create_from_command_line(const int argc, const char* const* const argv); +#endif static VcpkgCmdArguments create_from_arg_sequence(const std::string* arg_begin, const std::string* arg_end); std::unique_ptr vcpkg_root_dir; diff --git a/toolsrc/include/vcpkg/vcpkglib.h b/toolsrc/include/vcpkg/vcpkglib.h index b2aad8d7b..9a7fdb861 100644 --- a/toolsrc/include/vcpkg/vcpkglib.h +++ b/toolsrc/include/vcpkg/vcpkglib.h @@ -22,17 +22,16 @@ namespace vcpkg struct CMakeVariable { - CMakeVariable(const CWStringView varname, const wchar_t* varvalue); - CMakeVariable(const CWStringView varname, const std::string& varvalue); - CMakeVariable(const CWStringView varname, const std::wstring& varvalue); - CMakeVariable(const CWStringView varname, const fs::path& path); + CMakeVariable(const CStringView varname, const char* varvalue); + CMakeVariable(const CStringView varname, const std::string& varvalue); + CMakeVariable(const CStringView varname, const fs::path& path); - std::wstring s; + std::string s; }; - std::wstring make_cmake_cmd(const fs::path& cmake_exe, - const fs::path& cmake_script, - const std::vector& pass_variables); + std::string make_cmake_cmd(const fs::path& cmake_exe, + const fs::path& cmake_script, + const std::vector& pass_variables); std::string shorten_text(const std::string& desc, size_t length); } // namespace vcpkg diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h index 32dd2e833..781dabd1a 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -3,15 +3,15 @@ #include #include -#include #include #include +#include namespace vcpkg { struct ToolsetArchOption { - CWStringView name; + CStringView name; System::CPUArchitecture host_arch; System::CPUArchitecture target_arch; }; @@ -21,8 +21,8 @@ namespace vcpkg fs::path visual_studio_root_path; fs::path dumpbin; fs::path vcvarsall; - std::vector vcvarsall_options; - CWStringView version; + std::vector vcvarsall_options; + CStringView version; std::vector supported_architectures; }; -- cgit v1.2.3 From ced047ad78734aed239669a0fd9eca9e81718966 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 16 Oct 2017 13:50:28 -0700 Subject: Remove usages of CWStringView, except in Strings::to_utf8() --- toolsrc/include/vcpkg/base/cstringview.h | 89 +++++++++++--------------------- toolsrc/include/vcpkg/base/strings.h | 4 +- toolsrc/include/vcpkg/base/system.h | 7 +-- toolsrc/include/vcpkg/metrics.h | 2 +- 4 files changed, 35 insertions(+), 67 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/cstringview.h b/toolsrc/include/vcpkg/base/cstringview.h index eac204f97..342455402 100644 --- a/toolsrc/include/vcpkg/base/cstringview.h +++ b/toolsrc/include/vcpkg/base/cstringview.h @@ -5,94 +5,65 @@ namespace vcpkg { - template - struct BasicCStringView + struct CStringView { - constexpr BasicCStringView() : cstr(nullptr) {} - constexpr BasicCStringView(const CharType* cstr) : cstr(cstr) {} - constexpr BasicCStringView(const BasicCStringView&) = default; - BasicCStringView(const std::basic_string& str) : cstr(str.c_str()) {} + constexpr CStringView() : cstr(nullptr) {} + constexpr CStringView(const char* cstr) : cstr(cstr) {} + constexpr CStringView(const CStringView&) = default; + CStringView(const std::string& str) : cstr(str.c_str()) {} - constexpr const CharType* c_str() const { return cstr; } + constexpr const char* c_str() const { return cstr; } private: - const CharType* cstr; + const char* cstr; + }; + + struct CWStringView + { + constexpr CWStringView() : cstr(nullptr) {} + constexpr CWStringView(const wchar_t* cstr) : cstr(cstr) {} + constexpr CWStringView(const CWStringView&) = default; + CWStringView(const std::wstring& str) : cstr(str.c_str()) {} + + constexpr const wchar_t* c_str() const { return cstr; } + + private: + const wchar_t* 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 - bool operator==(const BasicCStringView& l, const BasicCStringView& r) + inline bool operator==(const CStringView& l, const CStringView& r) { return details::vcpkg_strcmp(l.c_str(), r.c_str()); } - template - bool operator==(const CharType* l, const BasicCStringView& r) - { - return details::vcpkg_strcmp(l, r.c_str()); - } + inline bool operator==(const char* l, const CStringView& r) { return details::vcpkg_strcmp(l, r.c_str()); } - template - bool operator==(const BasicCStringView& r, const CharType* l) - { - return details::vcpkg_strcmp(l, r.c_str()); - } + inline bool operator==(const CStringView& r, const char* l) { return details::vcpkg_strcmp(l, r.c_str()); } - template - bool operator==(const std::basic_string& l, const BasicCStringView& r) - { - return l == r.c_str(); - } + inline bool operator==(const std::string& l, const CStringView& r) { return l == r.c_str(); } - template - bool operator==(const BasicCStringView& r, const std::basic_string& l) - { - return l == r.c_str(); - } + inline bool operator==(const CStringView& r, const std::string& l) { return l == r.c_str(); } // notequals - template - bool operator!=(const BasicCStringView& l, const BasicCStringView& r) + inline bool operator!=(const CStringView& l, const CStringView& r) { return !details::vcpkg_strcmp(l.c_str(), r.c_str()); } - template - bool operator!=(const CharType* l, const BasicCStringView& r) - { - return !details::vcpkg_strcmp(l, r.c_str()); - } - - template - bool operator!=(const BasicCStringView& r, const CharType* l) - { - return !details::vcpkg_strcmp(l, r.c_str()); - } + inline bool operator!=(const char* l, const CStringView& r) { return !details::vcpkg_strcmp(l, r.c_str()); } - template - bool operator!=(const BasicCStringView& r, const std::basic_string& l) - { - return l != r.c_str(); - } + inline bool operator!=(const CStringView& r, const char* l) { return !details::vcpkg_strcmp(l, r.c_str()); } - template - bool operator!=(const std::basic_string& l, const BasicCStringView& r) - { - return l != r.c_str(); - } + inline bool operator!=(const CStringView& r, const std::string& l) { return l != r.c_str(); } - using CStringView = BasicCStringView; - using CWStringView = BasicCStringView; + inline bool operator!=(const std::string& l, const CStringView& r) { return l != r.c_str(); } inline const char* to_printf_arg(const CStringView string_view) { return string_view.c_str(); } - inline const wchar_t* to_wprintf_arg(const CWStringView string_view) { return string_view.c_str(); } - static_assert(sizeof(CStringView) == sizeof(void*), "CStringView must be a simple wrapper around char*"); - static_assert(sizeof(CWStringView) == sizeof(void*), "CWStringView must be a simple wrapper around wchar_t*"); } diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h index 93b36a29d..4adcadb0d 100644 --- a/toolsrc/include/vcpkg/base/strings.h +++ b/toolsrc/include/vcpkg/base/strings.h @@ -47,9 +47,9 @@ namespace vcpkg::Strings return details::wformat_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...); } - std::wstring to_utf16(const CStringView s); + std::wstring to_utf16(const CStringView& s); - std::string to_utf8(const CWStringView w); + std::string to_utf8(const CWStringView& w); std::string::const_iterator case_insensitive_ascii_find(const std::string& s, const std::string& pattern); diff --git a/toolsrc/include/vcpkg/base/system.h b/toolsrc/include/vcpkg/base/system.h index f2344c919..b396ef293 100644 --- a/toolsrc/include/vcpkg/base/system.h +++ b/toolsrc/include/vcpkg/base/system.h @@ -4,7 +4,6 @@ #include #include - namespace vcpkg::System { tm get_current_date_time(); @@ -64,9 +63,7 @@ namespace vcpkg::System Optional get_environment_variable(const CStringView varname) noexcept; - Optional get_registry_string(void* base_hkey, - const CWStringView subkey, - const CWStringView valuename); + Optional get_registry_string(void* base_hkey, const CStringView subkey, const CStringView valuename); enum class CPUArchitecture { @@ -76,7 +73,7 @@ namespace vcpkg::System ARM64, }; - Optional to_cpu_architecture(CStringView arch); + Optional to_cpu_architecture(const CStringView& arch); CPUArchitecture get_host_processor(); diff --git a/toolsrc/include/vcpkg/metrics.h b/toolsrc/include/vcpkg/metrics.h index 41be5002d..d570624eb 100644 --- a/toolsrc/include/vcpkg/metrics.h +++ b/toolsrc/include/vcpkg/metrics.h @@ -23,6 +23,6 @@ namespace vcpkg::Metrics extern Util::LockGuarded g_metrics; - std::wstring get_SQM_user(); + std::string get_SQM_user(); bool get_compiled_metrics_enabled(); } -- cgit v1.2.3 From c797ab4794b022f9f2a53f9a80bd6a451bd6d1ee Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 16 Oct 2017 13:52:35 -0700 Subject: Remove Strings::wformat() --- toolsrc/include/vcpkg/base/strings.h | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h index 4adcadb0d..6a4d4ef08 100644 --- a/toolsrc/include/vcpkg/base/strings.h +++ b/toolsrc/include/vcpkg/base/strings.h @@ -17,18 +17,12 @@ namespace vcpkg::Strings::details inline const char* to_printf_arg(const char* s) { return s; } template::value>> - inline T to_printf_arg(T s) + T to_printf_arg(T s) { return s; } std::string format_internal(const char* fmtstr, ...); - - inline const wchar_t* to_wprintf_arg(const std::wstring& s) { return s.c_str(); } - - inline const wchar_t* to_wprintf_arg(const wchar_t* s) { return s; } - - std::wstring wformat_internal(const wchar_t* fmtstr, ...); } namespace vcpkg::Strings @@ -40,13 +34,6 @@ namespace vcpkg::Strings return details::format_internal(fmtstr, to_printf_arg(to_printf_arg(args))...); } - template - std::wstring wformat(const wchar_t* fmtstr, const Args&... args) - { - using vcpkg::Strings::details::to_wprintf_arg; - return details::wformat_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...); - } - std::wstring to_utf16(const CStringView& s); std::string to_utf8(const CWStringView& w); -- cgit v1.2.3 From 61777425db2c5f59eb3a44f4439b734c27932cba Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 16 Oct 2017 13:54:38 -0700 Subject: Remove CharType template paramter from Strings::join() --- toolsrc/include/vcpkg/base/strings.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h index 6a4d4ef08..d263e3b6b 100644 --- a/toolsrc/include/vcpkg/base/strings.h +++ b/toolsrc/include/vcpkg/base/strings.h @@ -48,18 +48,18 @@ namespace vcpkg::Strings bool case_insensitive_ascii_starts_with(const std::string& s, const std::string& pattern); - template - std::basic_string join(const CharType* delimiter, const Container& v, Transformer transformer) + template + std::string join(const char* delimiter, const Container& v, Transformer transformer) { const auto begin = v.begin(); const auto end = v.end(); if (begin == end) { - return std::basic_string(); + return std::string(); } - std::basic_string output; + std::string output; output.append(transformer(*begin)); for (auto it = std::next(begin); it != end; ++it) { @@ -69,8 +69,8 @@ namespace vcpkg::Strings return output; } - template - std::basic_string join(const CharType* delimiter, const Container& v) + template + std::string join(const char* delimiter, const Container& v) { using Element = decltype(*v.begin()); return join(delimiter, v, [](const Element& x) -> const Element& { return x; }); -- cgit v1.2.3 From 70b458f5d97d5c189379b3d6b8913b27a2878661 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 16 Oct 2017 13:56:05 -0700 Subject: Remove Metrics::track_property(std::wstring) --- toolsrc/include/vcpkg/metrics.h | 1 - 1 file changed, 1 deletion(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/metrics.h b/toolsrc/include/vcpkg/metrics.h index d570624eb..f73c636cf 100644 --- a/toolsrc/include/vcpkg/metrics.h +++ b/toolsrc/include/vcpkg/metrics.h @@ -15,7 +15,6 @@ namespace vcpkg::Metrics void track_metric(const std::string& name, double value); void track_property(const std::string& name, const std::string& value); - void track_property(const std::string& name, const std::wstring& value); void upload(const std::string& payload); void flush(); -- cgit v1.2.3 From 3c4f620dbc7ef0005c694ab758c6c7d5e42dbe93 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 17 Oct 2017 02:59:55 -0700 Subject: `autocomplete` Add autocompletion for `vcpkg integrate` --- toolsrc/include/vcpkg/commands.h | 1 + 1 file changed, 1 insertion(+) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/commands.h b/toolsrc/include/vcpkg/commands.h index e00812c98..d9ebad2c4 100644 --- a/toolsrc/include/vcpkg/commands.h +++ b/toolsrc/include/vcpkg/commands.h @@ -75,6 +75,7 @@ namespace vcpkg::Commands namespace Integrate { extern const char* const INTEGRATE_COMMAND_HELPSTRING; + extern const CommandStructure COMMAND_STRUCTURE; void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); } -- cgit v1.2.3 From ecdfd3c8e3a4b924bfad5b70f6557dd9f337bd1c Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 18 Oct 2017 19:04:14 -0700 Subject: ci now accepts multiple triplets. Refactoring to accomodate --- toolsrc/include/vcpkg/install.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/install.h b/toolsrc/include/vcpkg/install.h index db6055f4f..809befb16 100644 --- a/toolsrc/include/vcpkg/install.h +++ b/toolsrc/include/vcpkg/install.h @@ -17,13 +17,22 @@ namespace vcpkg::Install inline KeepGoing to_keep_going(const bool value) { return value ? KeepGoing::YES : KeepGoing::NO; } - enum class PrintSummary + struct SpecSummary { - NO = 0, - YES + explicit SpecSummary(const PackageSpec& spec); + + PackageSpec spec; + Build::BuildResult result; + std::string timing; }; - inline PrintSummary to_print_summary(const bool value) { return value ? PrintSummary::YES : PrintSummary::NO; } + struct InstallSummary + { + std::vector results; + std::string total_elapsed_time; + + void print() const; + }; struct InstallDir { @@ -58,12 +67,11 @@ namespace vcpkg::Install const BinaryControlFile& binary_paragraph, StatusParagraphs* status_db); - void perform_and_exit_ex(const std::vector& action_plan, - const Build::BuildPackageOptions& install_plan_options, - const KeepGoing keep_going, - const PrintSummary print_summary, - const VcpkgPaths& paths, - StatusParagraphs& status_db); + InstallSummary perform(const std::vector& action_plan, + const Build::BuildPackageOptions& install_plan_options, + const KeepGoing keep_going, + const VcpkgPaths& paths, + StatusParagraphs& status_db); extern const CommandStructure COMMAND_STRUCTURE; -- cgit v1.2.3 From b1d5d8e8baf4bd5132de4415a0168432600ce998 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 19 Oct 2017 19:38:23 -0700 Subject: Introduce Strings::replace_all() --- toolsrc/include/vcpkg/base/strings.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h index d263e3b6b..5b03286de 100644 --- a/toolsrc/include/vcpkg/base/strings.h +++ b/toolsrc/include/vcpkg/base/strings.h @@ -76,6 +76,8 @@ namespace vcpkg::Strings return join(delimiter, v, [](const Element& x) -> const Element& { return x; }); } + std::string replace_all(std::string&& s, const std::string& search, const std::string& rep); + void trim(std::string* s); std::string trimmed(const std::string& s); -- cgit v1.2.3 From 50ae9eec872a0802d2450b4ae2d640475d0d7889 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 19 Oct 2017 19:50:23 -0700 Subject: Do not depend on newlines when getting output from powershell --- toolsrc/include/vcpkg/base/system.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/system.h b/toolsrc/include/vcpkg/base/system.h index b396ef293..e0d3264e2 100644 --- a/toolsrc/include/vcpkg/base/system.h +++ b/toolsrc/include/vcpkg/base/system.h @@ -22,7 +22,7 @@ namespace vcpkg::System ExitCodeAndOutput cmd_execute_and_capture_output(const CStringView cmd_line); - std::string create_powershell_script_cmd(const fs::path& script_path, const CStringView args = ""); + ExitCodeAndOutput powershell_execute_and_capture_output(const fs::path& script_path, const CStringView args = ""); enum class Color { -- cgit v1.2.3 From 7fb0342b8a16b43ce9887fcc879a2321954646be Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 19 Oct 2017 21:34:58 -0700 Subject: [system.h] Naming scheme fixes --- toolsrc/include/vcpkg/base/system.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/system.h b/toolsrc/include/vcpkg/base/system.h index e0d3264e2..a696bf3ae 100644 --- a/toolsrc/include/vcpkg/base/system.h +++ b/toolsrc/include/vcpkg/base/system.h @@ -38,27 +38,27 @@ namespace vcpkg::System void println(const Color c, const CStringView message); template - void print(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs) + void print(const char* message_template, const Arg1& message_arg1, const Args&... message_args) { - return System::print(Strings::format(messageTemplate, messageArg1, messageArgs...)); + return System::print(Strings::format(message_template, message_arg1, message_args...)); } template - void print(const Color c, const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs) + void print(const Color c, const char* message_template, const Arg1& message_arg1, const Args&... message_args) { - return System::print(c, Strings::format(messageTemplate, messageArg1, messageArgs...)); + return System::print(c, Strings::format(message_template, message_arg1, message_args...)); } template - void println(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs) + void println(const char* message_template, const Arg1& message_arg1, const Args&... message_args) { - return System::println(Strings::format(messageTemplate, messageArg1, messageArgs...)); + return System::println(Strings::format(message_template, message_arg1, message_args...)); } template - void println(const Color c, const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs) + void println(const Color c, const char* message_template, const Arg1& message_arg1, const Args&... message_args) { - return System::println(c, Strings::format(messageTemplate, messageArg1, messageArgs...)); + return System::println(c, Strings::format(message_template, message_arg1, message_args...)); } Optional get_environment_variable(const CStringView varname) noexcept; @@ -90,17 +90,17 @@ namespace vcpkg::Debug void println(const System::Color c, const CStringView message); template - void println(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs) + void println(const char* message_template, const Arg1& message_arg1, const Args&... message_args) { - return Debug::println(Strings::format(messageTemplate, messageArg1, messageArgs...)); + return Debug::println(Strings::format(message_template, message_arg1, message_args...)); } template void println(const System::Color c, - const char* messageTemplate, - const Arg1& messageArg1, - const Args&... messageArgs) + const char* message_template, + const Arg1& message_arg1, + const Args&... message_args) { - return Debug::println(c, Strings::format(messageTemplate, messageArg1, messageArgs...)); + return Debug::println(c, Strings::format(message_template, message_arg1, message_args...)); } } -- cgit v1.2.3 From 92d1a53215b2cc23dc090368d5218d42e195c478 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 20 Oct 2017 16:43:05 -0700 Subject: [LineInfo] Store empty string instead of null in default construction --- toolsrc/include/vcpkg/base/lineinfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/lineinfo.h b/toolsrc/include/vcpkg/base/lineinfo.h index 62973462a..e7e8c3031 100644 --- a/toolsrc/include/vcpkg/base/lineinfo.h +++ b/toolsrc/include/vcpkg/base/lineinfo.h @@ -9,7 +9,7 @@ namespace vcpkg int line_number; const char* file_name; - constexpr LineInfo() : line_number(0), file_name(nullptr) {} + constexpr LineInfo() : line_number(0), file_name("") {} constexpr LineInfo(const int lineno, const char* filename) : line_number(lineno), file_name(filename) {} std::string to_string() const; -- cgit v1.2.3 From 23702360ce912b1827afe5559de936cc9a24cd0c Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 20 Oct 2017 16:43:44 -0700 Subject: Merge trim() and trimmed() functions --- toolsrc/include/vcpkg/base/strings.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h index 5b03286de..ee1b2fc28 100644 --- a/toolsrc/include/vcpkg/base/strings.h +++ b/toolsrc/include/vcpkg/base/strings.h @@ -78,9 +78,7 @@ namespace vcpkg::Strings std::string replace_all(std::string&& s, const std::string& search, const std::string& rep); - void trim(std::string* s); - - std::string trimmed(const std::string& s); + std::string trim(std::string&& s); void trim_all_and_remove_whitespace_strings(std::vector* strings); -- cgit v1.2.3 From 8a952743a3a3f856f6be6b985158ea1c1ffb2c6f Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 26 Oct 2017 18:59:11 -0700 Subject: Introduce Util::Sets::contains() --- toolsrc/include/vcpkg/base/util.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/util.h b/toolsrc/include/vcpkg/base/util.h index d5db6b6ee..7ffd027f0 100644 --- a/toolsrc/include/vcpkg/base/util.h +++ b/toolsrc/include/vcpkg/base/util.h @@ -20,6 +20,15 @@ namespace vcpkg::Util } } + namespace Sets + { + template> + bool contains(const Container& container, const T& item) + { + return container.find(item) != container.cend(); + } + } + template using FmapOut = decltype(std::declval()(*begin(std::declval()))); -- cgit v1.2.3 From 2c9536ce4fe0ac755e188617ce61076b26646100 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 26 Oct 2017 19:00:30 -0700 Subject: [vcpkg ci] Introduce --exclude option --- toolsrc/include/vcpkg/build.h | 8 +++++--- toolsrc/include/vcpkg/dependencies.h | 3 ++- toolsrc/include/vcpkg/install.h | 2 ++ toolsrc/include/vcpkg/packagespec.h | 2 ++ 4 files changed, 11 insertions(+), 4 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h index 774e25922..bf52e54b2 100644 --- a/toolsrc/include/vcpkg/build.h +++ b/toolsrc/include/vcpkg/build.h @@ -65,15 +65,17 @@ namespace vcpkg::Build BUILD_FAILED, POST_BUILD_CHECKS_FAILED, FILE_CONFLICTS, - CASCADED_DUE_TO_MISSING_DEPENDENCIES + CASCADED_DUE_TO_MISSING_DEPENDENCIES, + EXCLUDED, }; - static constexpr std::array BUILD_RESULT_VALUES = { + static constexpr std::array BUILD_RESULT_VALUES = { BuildResult::SUCCEEDED, BuildResult::BUILD_FAILED, BuildResult::POST_BUILD_CHECKS_FAILED, BuildResult::FILE_CONFLICTS, - BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES}; + BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES, + BuildResult::EXCLUDED}; const std::string& to_string(const BuildResult build_result); std::string create_error_message(const BuildResult build_result, const PackageSpec& spec); diff --git a/toolsrc/include/vcpkg/dependencies.h b/toolsrc/include/vcpkg/dependencies.h index 585338ae2..60c83fcca 100644 --- a/toolsrc/include/vcpkg/dependencies.h +++ b/toolsrc/include/vcpkg/dependencies.h @@ -38,7 +38,8 @@ namespace vcpkg::Dependencies UNKNOWN, BUILD_AND_INSTALL, INSTALL, - ALREADY_INSTALLED + ALREADY_INSTALLED, + EXCLUDED }; struct InstallPlanAction : Util::MoveOnlyBase diff --git a/toolsrc/include/vcpkg/install.h b/toolsrc/include/vcpkg/install.h index 809befb16..895028865 100644 --- a/toolsrc/include/vcpkg/install.h +++ b/toolsrc/include/vcpkg/install.h @@ -62,6 +62,8 @@ namespace vcpkg::Install SUCCESS, }; + std::vector get_all_port_names(const VcpkgPaths& paths); + void install_files_and_write_listfile(Files::Filesystem& fs, const fs::path& source_dir, const InstallDir& dirs); InstallResult install_package(const VcpkgPaths& paths, const BinaryControlFile& binary_paragraph, diff --git a/toolsrc/include/vcpkg/packagespec.h b/toolsrc/include/vcpkg/packagespec.h index 60c99782e..99aaaf0d7 100644 --- a/toolsrc/include/vcpkg/packagespec.h +++ b/toolsrc/include/vcpkg/packagespec.h @@ -20,6 +20,8 @@ namespace vcpkg static ExpectedT from_name_and_triplet(const std::string& name, const Triplet& triplet); + static std::vector to_package_specs(const std::vector& ports, const Triplet& triplet); + const std::string& name() const; const Triplet& triplet() const; -- cgit v1.2.3 From 79ebd26605e0f621f848206000a5b1c7239d5f37 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 26 Oct 2017 19:14:32 -0700 Subject: Remove VcpkgCmdArguments.check_and_get_optional_command_arguments() overload Also, use Util::Sets::contains() where possible. --- toolsrc/include/vcpkg/build.h | 2 +- toolsrc/include/vcpkg/vcpkgcmdarguments.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h index bf52e54b2..94d9fddf5 100644 --- a/toolsrc/include/vcpkg/build.h +++ b/toolsrc/include/vcpkg/build.h @@ -20,7 +20,7 @@ namespace vcpkg::Build { void perform_and_exit(const FullPackageSpec& full_spec, const fs::path& port_dir, - const std::unordered_set& options, + const ParsedArguments& options, const VcpkgPaths& paths); void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet); diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h index d9895f4b8..e59979ad1 100644 --- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h +++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h @@ -34,11 +34,6 @@ namespace vcpkg std::string command; std::vector command_arguments; - std::unordered_set check_and_get_optional_command_arguments( - const std::vector& valid_options) const - { - return std::move(check_and_get_optional_command_arguments(valid_options, {}).switches); - } ParsedArguments check_and_get_optional_command_arguments(const std::vector& valid_switches, const std::vector& valid_settings) const; -- cgit v1.2.3 From 5f4221420701ff7d78e02b11622a00ee12a8e64a Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Mon, 30 Oct 2017 23:06:04 -0700 Subject: [vcpkg] Enable pkg[*] as alias for all features. --- toolsrc/include/vcpkg/base/util.h | 16 ++++++++++++++++ toolsrc/include/vcpkg/packagespec.h | 16 ++++++++++++++++ toolsrc/include/vcpkg/triplet.h | 1 + 3 files changed, 33 insertions(+) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/util.h b/toolsrc/include/vcpkg/base/util.h index 7ffd027f0..e67d38ad8 100644 --- a/toolsrc/include/vcpkg/base/util.h +++ b/toolsrc/include/vcpkg/base/util.h @@ -117,6 +117,22 @@ namespace vcpkg::Util } } + template + void sort(Range& cont) + { + using std::begin; + using std::end; + std::sort(begin(cont), end(cont)); + } + + template + bool all_equal(const Range1& r1, const Range2& r2) + { + using std::begin; + using std::end; + return std::equal(begin(r1), end(r1), begin(r2), end(r2)); + } + template())->first)>> std::vector extract_keys(AssocContainer&& input_map) { diff --git a/toolsrc/include/vcpkg/packagespec.h b/toolsrc/include/vcpkg/packagespec.h index 99aaaf0d7..0487ae6b8 100644 --- a/toolsrc/include/vcpkg/packagespec.h +++ b/toolsrc/include/vcpkg/packagespec.h @@ -50,6 +50,22 @@ namespace vcpkg static std::vector from_strings_and_triplet(const std::vector& depends, const Triplet& t); + bool operator<(const FeatureSpec& other) const + { + if (name() < other.name()) return true; + if (name() > other.name()) return false; + if (feature() < other.feature()) return true; + if (feature() > other.feature()) return false; + return triplet() < other.triplet(); + } + + bool operator==(const FeatureSpec& other) const + { + return triplet() == other.triplet() && name() == other.name() && feature() == other.feature(); + } + + bool operator!=(const FeatureSpec& other) const { return !(*this == other); } + private: PackageSpec m_spec; std::string m_feature; diff --git a/toolsrc/include/vcpkg/triplet.h b/toolsrc/include/vcpkg/triplet.h index 50d731593..2cfc2d02a 100644 --- a/toolsrc/include/vcpkg/triplet.h +++ b/toolsrc/include/vcpkg/triplet.h @@ -24,6 +24,7 @@ namespace vcpkg size_t hash_code() const; bool operator==(const Triplet& other) const; + bool operator<(const Triplet& other) const { return canonical_name() < other.canonical_name(); } private: static const TripletInstance DEFAULT_INSTANCE; -- cgit v1.2.3 From 33fc44a0e3ade2c7e9369723b2ee4965ee8795e6 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 31 Oct 2017 02:13:49 -0700 Subject: [vcpkg] Add optional Abi field to BinaryParagraph for future use. --- toolsrc/include/vcpkg/binaryparagraph.h | 1 + 1 file changed, 1 insertion(+) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/binaryparagraph.h b/toolsrc/include/vcpkg/binaryparagraph.h index 7eb50a6d7..f59bf693a 100644 --- a/toolsrc/include/vcpkg/binaryparagraph.h +++ b/toolsrc/include/vcpkg/binaryparagraph.h @@ -30,6 +30,7 @@ namespace vcpkg std::string feature; std::vector default_features; std::vector depends; + std::string abi; }; struct BinaryControlFile -- cgit v1.2.3 From 925fab565a76c23e76329193bc25158608bc9fc6 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 31 Oct 2017 03:04:28 -0700 Subject: [vcpkg] --head should only apply to USER_REQUESTED packages. --- toolsrc/include/vcpkg/dependencies.h | 5 +++++ toolsrc/include/vcpkg/install.h | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/dependencies.h b/toolsrc/include/vcpkg/dependencies.h index 60c83fcca..5411ee166 100644 --- a/toolsrc/include/vcpkg/dependencies.h +++ b/toolsrc/include/vcpkg/dependencies.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,9 @@ namespace vcpkg::Dependencies AUTO_SELECTED }; + std::string to_output_string(RequestType request_type, + const CStringView s, + const Build::BuildPackageOptions& options); std::string to_output_string(RequestType request_type, const CStringView s); struct AnyParagraph @@ -63,6 +67,7 @@ namespace vcpkg::Dependencies AnyParagraph any_paragraph; InstallPlanType plan_type; RequestType request_type; + Build::BuildPackageOptions build_options; std::unordered_set feature_list; }; diff --git a/toolsrc/include/vcpkg/install.h b/toolsrc/include/vcpkg/install.h index 895028865..7bf823e99 100644 --- a/toolsrc/include/vcpkg/install.h +++ b/toolsrc/include/vcpkg/install.h @@ -53,7 +53,6 @@ namespace vcpkg::Install Build::BuildResult perform_install_plan_action(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action, - const Build::BuildPackageOptions& install_plan_options, StatusParagraphs& status_db); enum class InstallResult @@ -70,7 +69,6 @@ namespace vcpkg::Install StatusParagraphs* status_db); InstallSummary perform(const std::vector& action_plan, - const Build::BuildPackageOptions& install_plan_options, const KeepGoing keep_going, const VcpkgPaths& paths, StatusParagraphs& status_db); -- cgit v1.2.3 From a705df80b0f8db81b201492b4012e23e08a53694 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 31 Oct 2017 03:47:35 -0700 Subject: [vcpkg] Fix bug where packages with uninstalled features appear to be uninstalled. --- toolsrc/include/vcpkg/statusparagraphs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/statusparagraphs.h b/toolsrc/include/vcpkg/statusparagraphs.h index c2f3b7b8e..747a0c1ab 100644 --- a/toolsrc/include/vcpkg/statusparagraphs.h +++ b/toolsrc/include/vcpkg/statusparagraphs.h @@ -16,10 +16,10 @@ namespace vcpkg using const_iterator = container::const_reverse_iterator; 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); + iterator find(const std::string& name, const Triplet& triplet, const std::string& feature = ""); + const_iterator find(const std::string& name, const Triplet& triplet, const std::string& feature = "") const; + std::vector*> 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 { -- cgit v1.2.3 From 6a91d1ece10ce0aeda89c44611d5335a07b8e40d Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Thu, 2 Nov 2017 15:20:42 -0700 Subject: [vcpkg] Refactor argument parsing to use common code paths. --- toolsrc/include/vcpkg/base/span.h | 12 ++++++ toolsrc/include/vcpkg/base/util.h | 2 +- toolsrc/include/vcpkg/build.h | 8 ++-- toolsrc/include/vcpkg/commands.h | 7 ++++ toolsrc/include/vcpkg/vcpkgcmdarguments.h | 65 ++++++++++++++++++------------- 5 files changed, 62 insertions(+), 32 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/span.h b/toolsrc/include/vcpkg/base/span.h index 6be546351..158f1ac74 100644 --- a/toolsrc/include/vcpkg/base/span.h +++ b/toolsrc/include/vcpkg/base/span.h @@ -57,4 +57,16 @@ namespace vcpkg { return {v.data(), v.size()}; } + + template + constexpr T* begin(Span sp) + { + return sp.begin(); + } + + template + constexpr T* end(Span sp) + { + return sp.end(); + } } \ No newline at end of file diff --git a/toolsrc/include/vcpkg/base/util.h b/toolsrc/include/vcpkg/base/util.h index e67d38ad8..155b16cf7 100644 --- a/toolsrc/include/vcpkg/base/util.h +++ b/toolsrc/include/vcpkg/base/util.h @@ -30,7 +30,7 @@ namespace vcpkg::Util } template - using FmapOut = decltype(std::declval()(*begin(std::declval()))); + using FmapOut = decltype(std::declval()(*begin(std::declval()))); template> std::vector fmap(Cont&& xs, Func&& f) diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h index 94d9fddf5..824f3ccaf 100644 --- a/toolsrc/include/vcpkg/build.h +++ b/toolsrc/include/vcpkg/build.h @@ -18,10 +18,10 @@ namespace vcpkg::Build { namespace Command { - void perform_and_exit(const FullPackageSpec& full_spec, - const fs::path& port_dir, - const ParsedArguments& options, - const VcpkgPaths& paths); + void perform_and_exit_ex(const FullPackageSpec& full_spec, + const fs::path& port_dir, + const ParsedArguments& options, + const VcpkgPaths& paths); void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet); } diff --git a/toolsrc/include/vcpkg/commands.h b/toolsrc/include/vcpkg/commands.h index d9ebad2c4..74fd80c03 100644 --- a/toolsrc/include/vcpkg/commands.h +++ b/toolsrc/include/vcpkg/commands.h @@ -23,16 +23,19 @@ namespace vcpkg::Commands namespace CI { + extern const CommandStructure COMMAND_STRUCTURE; void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet); } namespace Env { + extern const CommandStructure COMMAND_STRUCTURE; void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet); } namespace Create { + extern const CommandStructure COMMAND_STRUCTURE; void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); } @@ -49,16 +52,19 @@ namespace vcpkg::Commands namespace Search { + extern const CommandStructure COMMAND_STRUCTURE; void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); } namespace List { + extern const CommandStructure COMMAND_STRUCTURE; void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); } namespace Owns { + extern const CommandStructure COMMAND_STRUCTURE; void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); } @@ -99,6 +105,7 @@ namespace vcpkg::Commands namespace Contact { + extern const CommandStructure COMMAND_STRUCTURE; const std::string& email(); void perform_and_exit(const VcpkgCmdArguments& args); } diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h index e59979ad1..a832caf04 100644 --- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h +++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h @@ -17,13 +17,47 @@ namespace vcpkg std::unordered_map settings; }; - struct VcpkgCmdArguments + struct VcpkgPaths; + + struct CommandSwitch + { + std::string name; + CStringView short_help_text; + }; + + struct CommandSetting { + std::string name; + CStringView short_help_text; + }; + + struct CommandOptionsStructure + { + Span switches; + Span settings; + }; + + struct CommandStructure + { + std::string example_text; + + size_t minimum_arity; + size_t maximum_arity; + + CommandOptionsStructure options; + + std::vector (*valid_arguments)(const VcpkgPaths& paths); + }; + #if defined(_WIN32) - static VcpkgCmdArguments create_from_command_line(const int argc, const wchar_t* const* const argv); + using CommandLineCharType = wchar_t; #else - static VcpkgCmdArguments create_from_command_line(const int argc, const char* const* const argv); + using CommandLineCharType = char; #endif + + struct VcpkgCmdArguments + { + static VcpkgCmdArguments create_from_command_line(const int argc, const CommandLineCharType* const* const argv); static VcpkgCmdArguments create_from_arg_sequence(const std::string* arg_begin, const std::string* arg_end); std::unique_ptr vcpkg_root_dir; @@ -35,32 +69,9 @@ namespace vcpkg std::string command; std::vector command_arguments; - ParsedArguments check_and_get_optional_command_arguments(const std::vector& valid_switches, - const std::vector& valid_settings) const; - - void check_max_arg_count(const size_t expected_arg_count) const; - void check_max_arg_count(const size_t expected_arg_count, const std::string& example_text) const; - void check_min_arg_count(const size_t expected_arg_count) const; - void check_min_arg_count(const size_t expected_arg_count, const std::string& example_text) const; - void check_exact_arg_count(const size_t expected_arg_count) const; - void check_exact_arg_count(const size_t expected_arg_count, const std::string& example_text) const; + ParsedArguments parse_arguments(const CommandStructure& command_structure) const; private: std::unordered_map> optional_command_arguments; }; - - struct VcpkgPaths; - - struct CommandStructure - { - CStringView example_text; - - size_t minimum_arity; - size_t maximum_arity; - - Span switches; - Span settings; - - std::vector (*valid_arguments)(const VcpkgPaths& paths); - }; } -- cgit v1.2.3 From 2feea0828ba94d2a365e8825fe799ed12acc6e6c Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Thu, 2 Nov 2017 18:17:21 -0700 Subject: [vcpkg] Improve `vcpkg help` -- now has per-command help! --- toolsrc/include/vcpkg/base/cstringview.h | 2 ++ toolsrc/include/vcpkg/export.h | 2 ++ toolsrc/include/vcpkg/help.h | 4 ++-- toolsrc/include/vcpkg/vcpkgcmdarguments.h | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/cstringview.h b/toolsrc/include/vcpkg/base/cstringview.h index 342455402..0441bc573 100644 --- a/toolsrc/include/vcpkg/base/cstringview.h +++ b/toolsrc/include/vcpkg/base/cstringview.h @@ -63,6 +63,8 @@ namespace vcpkg inline bool operator!=(const std::string& l, const CStringView& r) { return l != r.c_str(); } + inline std::string operator+(std::string&& l, const CStringView& r) { return std::move(l) + r.c_str(); } + inline const char* to_printf_arg(const CStringView string_view) { return string_view.c_str(); } static_assert(sizeof(CStringView) == sizeof(void*), "CStringView must be a simple wrapper around char*"); diff --git a/toolsrc/include/vcpkg/export.h b/toolsrc/include/vcpkg/export.h index f3285e187..eb99b4fb1 100644 --- a/toolsrc/include/vcpkg/export.h +++ b/toolsrc/include/vcpkg/export.h @@ -4,6 +4,8 @@ namespace vcpkg::Export { + extern const CommandStructure COMMAND_STRUCTURE; + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet); void export_integration_files(const fs::path& raw_exported_dir_path, const VcpkgPaths& paths); diff --git a/toolsrc/include/vcpkg/help.h b/toolsrc/include/vcpkg/help.h index 39ad6912d..73549efd7 100644 --- a/toolsrc/include/vcpkg/help.h +++ b/toolsrc/include/vcpkg/help.h @@ -7,13 +7,13 @@ namespace vcpkg::Help { + extern const CommandStructure COMMAND_STRUCTURE; + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); void help_topic_valid_triplet(const VcpkgPaths& paths); void print_usage(); - void print_example(const std::string& command_and_arguments); - std::string create_example_string(const std::string& command_and_arguments); } diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h index a832caf04..93eeb6ef5 100644 --- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h +++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h @@ -49,6 +49,8 @@ namespace vcpkg std::vector (*valid_arguments)(const VcpkgPaths& paths); }; + void display_usage(const CommandStructure& command_structure); + #if defined(_WIN32) using CommandLineCharType = wchar_t; #else -- cgit v1.2.3 From 61c0a337842b50d4b914893030193f3a1faaedf4 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sat, 4 Nov 2017 16:40:11 -0700 Subject: Improve error messages around calling powershell scripts --- toolsrc/include/vcpkg/base/system.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/system.h b/toolsrc/include/vcpkg/base/system.h index a696bf3ae..9f2d91435 100644 --- a/toolsrc/include/vcpkg/base/system.h +++ b/toolsrc/include/vcpkg/base/system.h @@ -22,7 +22,9 @@ namespace vcpkg::System ExitCodeAndOutput cmd_execute_and_capture_output(const CStringView cmd_line); - ExitCodeAndOutput powershell_execute_and_capture_output(const fs::path& script_path, const CStringView args = ""); + std::string powershell_execute_and_capture_output(const std::string& title, + const fs::path& script_path, + const CStringView args = ""); enum class Color { -- cgit v1.2.3