aboutsummaryrefslogtreecommitdiff
path: root/toolsrc
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc')
-rw-r--r--toolsrc/CMakeLists.txt30
-rw-r--r--toolsrc/include/pch.h4
-rw-r--r--toolsrc/include/vcpkg/base/files.h8
-rw-r--r--toolsrc/src/vcpkg.cpp13
-rw-r--r--toolsrc/src/vcpkg/base/hash.cpp8
-rw-r--r--toolsrc/src/vcpkg/base/system.cpp4
6 files changed, 58 insertions, 9 deletions
diff --git a/toolsrc/CMakeLists.txt b/toolsrc/CMakeLists.txt
index af6981155..9dcf95d14 100644
--- a/toolsrc/CMakeLists.txt
+++ b/toolsrc/CMakeLists.txt
@@ -65,7 +65,14 @@ if(CLANG AND NOT MSVC)
endif()
if(GCC OR (CLANG AND USES_LIBSTDCXX))
- link_libraries(stdc++fs)
+ include(CheckCXXSourceCompiles)
+ set(CMAKE_REQUIRED_LIBRARIES stdc++fs)
+ check_cxx_source_compiles("#include <experimental/filesystem>
+ int main() { return 0; }" LINKS_TO_STDCXX_FS)
+ unset(CMAKE_REQUIRED_LIBRARIES)
+ if (LINKS_TO_STDCXX_FS)
+ link_libraries(stdc++fs)
+ endif()
elseif(CLANG AND NOT MSVC AND NOT NO_LIBCXXFS)
link_libraries(c++fs)
endif()
@@ -94,7 +101,7 @@ elseif(GCC OR CLANG)
add_compile_options(-std=c++1z)
if(VCPKG_DEVELOPMENT_WARNINGS)
- add_compile_options(-Wall -Wextra -Wpedantic -Wno-unknown-pragmas -Wno-missing-field-initializers -Werror)
+ add_compile_options(-Wall -Wextra -Wpedantic -Wno-unknown-pragmas -Wno-missing-field-initializers -Wno-redundant-move -Werror)
# GCC and clang have different names for the same warning
if (GCC)
@@ -143,3 +150,22 @@ if(MSVC)
target_sources(vcpkg PRIVATE src/pch.cpp)
target_compile_options(vcpkg PRIVATE /Yupch.h /FIpch.h /Zm200)
endif()
+
+if (MINGW)
+ include(CheckCXXSourceCompiles)
+ check_cxx_source_compiles("#include <experimental/filesystem>
+ int main() { return 0; }" USES_EXPERIMENTAL_FS)
+
+ if (NOT USES_EXPERIMENTAL_FS)
+ add_compile_definitions(USE_STD_FILESYSTEM)
+ endif()
+
+ add_compile_definitions(
+ UNICODE
+ _WIN32_WINNT=0x0601
+ WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY=4
+ __fastfail=exit)
+ foreach(tgt vcpkg vcpkg-test)
+ target_link_libraries(${tgt} PRIVATE winhttp bcrypt version ole32 uuid)
+ endforeach()
+endif()
diff --git a/toolsrc/include/pch.h b/toolsrc/include/pch.h
index ce2a7c9c5..a6a442f0a 100644
--- a/toolsrc/include/pch.h
+++ b/toolsrc/include/pch.h
@@ -31,7 +31,11 @@
#include <cstdint>
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
#include <cstring>
+#if USE_STD_FILESYSTEM
+#include <filesystem>
+#else
#include <experimental/filesystem>
+#endif
#include <fstream>
#include <functional>
#include <iomanip>
diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h
index e9d3d33bf..bb4a10d49 100644
--- a/toolsrc/include/vcpkg/base/files.h
+++ b/toolsrc/include/vcpkg/base/files.h
@@ -2,12 +2,20 @@
#include <vcpkg/base/expected.h>
+#if USE_STD_FILESYSTEM
+#include <filesystem>
+#else
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
#include <experimental/filesystem>
+#endif
namespace fs
{
+#if USE_STD_FILESYSTEM
+ namespace stdfs = std::filesystem;
+#else
namespace stdfs = std::experimental::filesystem;
+#endif
using stdfs::copy_options;
using stdfs::path;
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp
index 2dd13f43d..1f212dd94 100644
--- a/toolsrc/src/vcpkg.cpp
+++ b/toolsrc/src/vcpkg.cpp
@@ -263,7 +263,18 @@ static void load_config()
#if defined(_WIN32)
// note: this prevents a false positive for -Wmissing-prototypes on clang-cl
-int wmain(int, const wchar_t* const*);
+int wmain(int, const wchar_t* const* const);
+
+#if !defined(_MSC_VER)
+#include <shellapi.h>
+int main(int argc, const char* const* const /*argv*/)
+{
+ wchar_t **wargv;
+ wargv = CommandLineToArgvW(GetCommandLineW(), &argc);
+ return wmain(argc, wargv);
+}
+#endif
+
int wmain(const int argc, const wchar_t* const* const argv)
#else
int main(const int argc, const char* const* const argv)
diff --git a/toolsrc/src/vcpkg/base/hash.cpp b/toolsrc/src/vcpkg/base/hash.cpp
index 11df3e329..81635b875 100644
--- a/toolsrc/src/vcpkg/base/hash.cpp
+++ b/toolsrc/src/vcpkg/base/hash.cpp
@@ -123,9 +123,9 @@ namespace vcpkg::Hash
void top_bits(T) = delete;
static constexpr uchar top_bits(uchar x) noexcept { return x; }
- static constexpr uchar top_bits(std::uint32_t x) noexcept { return (x >> 24) & 0xFF; }
- static constexpr uchar top_bits(std::uint64_t x) noexcept { return (x >> 56) & 0xFF; }
- static constexpr uchar top_bits(UInt128 x) noexcept { return top_bits(x.top); }
+ [[maybe_unused]] static constexpr uchar top_bits(std::uint32_t x) noexcept { return (x >> 24) & 0xFF; }
+ [[maybe_unused]] static constexpr uchar top_bits(std::uint64_t x) noexcept { return (x >> 56) & 0xFF; }
+ [[maybe_unused]] static constexpr uchar top_bits(UInt128 x) noexcept { return top_bits(x.top); }
// treats UIntTy as big endian for the purpose of this mapping
template<class UIntTy>
@@ -145,7 +145,7 @@ namespace vcpkg::Hash
for (uchar& ch : buff)
{
ch = top_bits(tmp);
- tmp <<= 8;
+ tmp = UIntTy(tmp << 8);
}
for (const auto byte : buff)
diff --git a/toolsrc/src/vcpkg/base/system.cpp b/toolsrc/src/vcpkg/base/system.cpp
index c84b7f8be..5a446a330 100644
--- a/toolsrc/src/vcpkg/base/system.cpp
+++ b/toolsrc/src/vcpkg/base/system.cpp
@@ -378,7 +378,7 @@ namespace vcpkg
g_ctrl_c_state.transition_to_spawn_process();
auto clean_env = compute_clean_environment(extra_env, prepend_to_path);
- windows_create_process(cmd_line, clean_env.data(), process_info, NULL);
+ windows_create_process(cmd_line, clean_env.data(), process_info, 0);
CloseHandle(process_info.hThread);
@@ -542,7 +542,7 @@ namespace vcpkg
{
HKEY k = nullptr;
const LSTATUS ec =
- RegOpenKeyExW(reinterpret_cast<HKEY>(base_hkey), Strings::to_utf16(sub_key).c_str(), NULL, KEY_READ, &k);
+ RegOpenKeyExW(reinterpret_cast<HKEY>(base_hkey), Strings::to_utf16(sub_key).c_str(), 0, KEY_READ, &k);
if (ec != ERROR_SUCCESS) return nullopt;
auto w_valuename = Strings::to_utf16(valuename);