diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-10-16 11:44:04 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-10-16 11:44:04 -0700 |
| commit | 7214c3583bdf569bc873305908ec109a6c8716cc (patch) | |
| tree | cbd06492bf0cde4030977dd498bd3345a035df84 /toolsrc/include | |
| parent | 81613fa0ff506852fbb90757fc27f87ffe591fee (diff) | |
| download | vcpkg-7214c3583bdf569bc873305908ec109a6c8716cc.tar.gz vcpkg-7214c3583bdf569bc873305908ec109a6c8716cc.zip | |
[vcpkg] Push use of UTF-16 to only around Win32 call boundaries.
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/pch.h | 18 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/cstringview.h | 1 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/expected.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/files.h | 14 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/graphs.h | 6 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/strings.h | 19 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/system.h | 15 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/util.h | 3 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/build.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/dependencies.h | 5 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/packagespec.h | 33 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/packagespecparseresult.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/paragraphparseresult.h | 11 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/sourceparagraph.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/triplet.h | 11 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/vcpkgcmdarguments.h | 4 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/vcpkglib.h | 15 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/vcpkgpaths.h | 8 |
18 files changed, 100 insertions, 71 deletions
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 <Shlobj.h> +#include <process.h> +#include <shellapi.h> +#include <winhttp.h> +#else +#include <unistd.h> +#endif + #include <algorithm> #include <array> #include <atomic> @@ -19,7 +27,12 @@ #include <cstdarg> #include <cstddef> #include <cstdint> +#if defined(_WIN32) #include <filesystem> +#else +#include <experimental/filesystem> +#endif +#include <cstring> #include <fstream> #include <functional> #include <iomanip> @@ -28,18 +41,17 @@ #include <map> #include <memory> #include <mutex> -#include <process.h> #include <regex> #include <set> -#include <shellapi.h> #include <stdexcept> #include <string> #include <sys/timeb.h> +#include <sys/types.h> #include <system_error> +#include <thread> #include <time.h> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> -#include <winhttp.h> 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 <string.h> #include <string> 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 <vcpkg/base/expected.h> +#if defined(_WIN32) #include <filesystem> +#else +#include <experimental/filesystem> +#endif namespace fs { @@ -19,7 +23,7 @@ namespace fs namespace vcpkg::Files { - __interface Filesystem + struct Filesystem { virtual Expected<std::string> read_contents(const fs::path& file_path) const = 0; virtual Expected<std::vector<std::string>> 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<fs::path>& paths); - std::vector<fs::path> find_from_PATH(const std::wstring& name); + std::vector<fs::path> 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<class V, class U> - __interface AdjacencyProvider + struct AdjacencyProvider { - std::vector<V> adjacency_list(const U& vertex) const; + virtual std::vector<V> 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<class V, class U> 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<class T, class = std::enable_if_t<std::is_arithmetic<T>::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<class... Args> 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 <vcpkg/base/optional.h> #include <vcpkg/base/strings.h> -#include <Windows.h> 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<std::wstring> get_environment_variable(const CWStringView varname) noexcept; + Optional<std::string> get_environment_variable(const CStringView varname) noexcept; - Optional<std::wstring> get_registry_string(HKEY base, const CWStringView subkey, const CWStringView valuename); + Optional<std::wstring> 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 <algorithm> #include <map> #include <mutex> #include <utility> @@ -98,7 +99,7 @@ namespace vcpkg::Util } template<class K, class V, class Container, class Func> - void group_by(const Container& cont, _Inout_ std::map<K, std::vector<const V*>>* output, Func&& f) + void group_by(const Container& cont, std::map<K, std::vector<const V*>>* 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<fs::path> 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<vcpkg::PackageSpec> +namespace std { - size_t operator()(const vcpkg::PackageSpec& value) const + template<> + struct hash<vcpkg::PackageSpec> { - size_t hash = 17; - hash = hash * 31 + std::hash<std::string>()(value.name()); - hash = hash * 31 + std::hash<vcpkg::Triplet>()(value.triplet()); - return hash; - } -}; - -template<> -struct std::equal_to<vcpkg::PackageSpec> -{ - 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<std::string>()(value.name()); + hash = hash * 31 + std::hash<vcpkg::Triplet>()(value.triplet()); + return hash; + } + }; + + template<> + struct equal_to<vcpkg::PackageSpec> + { + 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<vcpkg::ParagraphParseResult> : ::std::true_type +namespace std { -}; + // Enable implicit conversion to std::error_code + template<> + struct is_error_code_enum<vcpkg::ParagraphParseResult> : ::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 <vcpkg/packagespec.h> #include <vcpkg/parse.h> -#include <vcpkg/base/Span.h> #include <vcpkg/base/expected.h> +#include <vcpkg/base/span.h> #include <vcpkg/base/system.h> #include <string> 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<vcpkg::Triplet> +namespace std { - size_t operator()(const vcpkg::Triplet& t) const { return t.hash_code(); } -}; + template<> + struct hash<vcpkg::Triplet> + { + 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<std::string> 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<CMakeVariable>& pass_variables); + std::string make_cmake_cmd(const fs::path& cmake_exe, + const fs::path& cmake_script, + const std::vector<CMakeVariable>& 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 <vcpkg/binaryparagraph.h> #include <vcpkg/packagespec.h> -#include <vcpkg/base/Lazy.h> #include <vcpkg/base/expected.h> #include <vcpkg/base/files.h> +#include <vcpkg/base/lazy.h> 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<std::wstring> vcvarsall_options; - CWStringView version; + std::vector<std::string> vcvarsall_options; + CStringView version; std::vector<ToolsetArchOption> supported_architectures; }; |
