From 91e02dc2c44ed8a915a67b83c86b508ac0f4a82a Mon Sep 17 00:00:00 2001 From: Steffen Schuemann Date: Tue, 14 May 2019 08:42:29 +0200 Subject: [PATCH] Work on CI support for MingW, fixing some MingW issues --- .appveyor.yml | 67 +++++++++++++++++++++++++++++--------- .clang-format | 2 +- README.md | 11 +++++-- include/ghc/filesystem.hpp | 29 ++++++++--------- test/filesystem_test.cpp | 2 +- 5 files changed, 75 insertions(+), 36 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 08ee404..5cf09e1 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,13 +1,47 @@ -image: Visual Studio 2017 +environment: + matrix: + - platform: x86 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + generator: "Visual Studio 14 2015" + compiler: msvc + configuration: Release -platform: - - Win32 - - x64 + - platform: x64 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + generator: "Visual Studio 14 2015 Win64" + compiler: msvc + configuration: Release + + - platform: x86 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + generator: "Visual Studio 15 2017" + compiler: msvc + configuration: Release + + - platform: x64 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + generator: "Visual Studio 15 2017 Win64" + compiler: msvc + configuration: Release + + - platform: x86 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + generator: "MinGW Makefiles" + compiler: mingw + TOOLCHAIN_PATH: C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1/mingw32\bin + CC: C:/mingw-w64/i686-6.3.0-posix-dwarf-rt_v5-rev1/mingw32/bin/gcc.exe + CXX: C:/mingw-w64/i686-6.3.0-posix-dwarf-rt_v5-rev1/mingw32/bin/g++.exe + configuration: Release + + - platform: x64 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + generator: "MinGW Makefiles" + compiler: mingw + TOOLCHAIN_PATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin + CC: C:/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcc.exe + CXX: C:/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/g++.exe + configuration: Release -configuration: - - Debug - - Release - matrix: fast_finish: false @@ -17,17 +51,18 @@ init: install: - cmd: reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1" + - cmd: ren "C:\Program Files\Git\usr\bin\sh.exe" _sh.exe -before_build: - - cmake . -Bbuild -A%PLATFORM% -DCMAKE_BUILD_TYPE=%configuration% - -build: - project: build/ghcfilesystem.sln - parallel: true - verbosity: minimal +build_script: + - mkdir build + - cd build + - if [%compiler%]==[msvc] cmake -G"%generator%" .. + - if [%compiler%]==[mingw] set PATH=%TOOLCHAIN_PATH%;%PATH% + - if [%compiler%]==[mingw] cmake -G"%generator%" -DCMAKE_C_COMPILER=%CC% -DCMAKE_CXX_COMPILER=%CXX% -DCMAKE_SH=CMAKE_SH-NOTFOUND -DCMAKE_BUILD_TYPE=%configuration% .. + - cmake --build . --config %configuration% test_script: - - cd build + - cd %APPVEYOR_BUILD_FOLDER%\build - set CTEST_OUTPUT_ON_FAILURE=1 - ctest -C %configuration% - cd .. diff --git a/.clang-format b/.clang-format index c1c70f1..b24fe34 100644 --- a/.clang-format +++ b/.clang-format @@ -21,5 +21,5 @@ BraceWrapping: SplitEmptyNamespace: true BreakConstructorInitializers: BeforeComma ConstructorInitializerAllOnOneLineOrOnePerLine: false - +IndentPPDirectives: None ... diff --git a/README.md b/README.md index 5c16741..92585aa 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,8 @@ of the UTF-8 preference on Windows). Unit tests are currently run with: -* macOS 10.12: XCode 9.2 (clang-900.0.39.2), GCC 8.1.0, Clang 7.0.0 -* Windows 10: Visual Studio 2017 15.8.5, MingW GCC 5.3 +* macOS 10.12: Xcode 9.2 (clang-900.0.39.2), Xcode 10.2, GCC 8.1.0, Clang 7.0.0 +* Windows: Visual Studio 2017, Visual Studio 2015, MingW GCC 6.3 (Win32), GCC 7.2 (Win64) * Linux (Ubuntu): GCC (5.5, 6.5, 7.4, 8.1, 8.2), Clang (5.0, 6.0, 7.1, 8.0) @@ -410,7 +410,7 @@ just a more complicated syntax for the `fs::create_symlink` or `fs::create_hardl and I don't want to believe, that this was the intention of the original writing. As there is another issue related to copy, with a different take on the description. -*Note:* With v1.1.2 I decided to integrate a behavior switch for this and make the LWG #2682 +**Note:** With v1.1.2 I decided to integrate a behavior switch for this and make the LWG #2682 the default. ## Open Issues @@ -445,6 +445,11 @@ to the expected behavior. ## Release Notes +### v1.1.5 (wip) + +* Added MingW 32/64 and Visual Studio 2015 builds to the CI configuration. +* Fixed additional compilation issues on MingW. + ### [v1.1.4](https://github.com/gulrak/filesystem/releases/tag/v1.1.4) * Additional Bugfix for ([#12](https://github.com/gulrak/filesystem/issues/12)), diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index c9562d9..c8d53ee 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -1057,7 +1057,7 @@ GHC_INLINE std::error_code make_error_code(portable_error err) return std::error_code(ERROR_INVALID_PARAMETER, std::system_category()); case portable_error::is_a_directory: #ifdef ERROR_DIRECTORY_NOT_SUPPORTED - return std::error_code(ERROR_DIRECTORY_NOT_SUPPORTED, std::system_category()); + return std::error_code(ERROR_DIRECTORY_NOT_SUPPORTED, std::system_category()); #else return std::error_code(ERROR_NOT_SUPPORTED, std::system_category()); #endif @@ -1388,15 +1388,15 @@ namespace detail { GHC_INLINE bool equals_simple_insensitive(const char* str1, const char* str2) { #ifdef GHC_OS_WINDOWS -# ifdef __GNUC__ +#ifdef __GNUC__ while (::tolower((unsigned char)*str1) == ::tolower((unsigned char)*str2++)) { if (*str1++ == 0) return true; } return false; -# else +#else return 0 == ::_stricmp(str1, str2); -# endif +#endif #else return 0 == ::strcasecmp(str1, str2); #endif @@ -1555,7 +1555,7 @@ GHC_INLINE path resolveSymlink(const path& p, std::error_code& ec) UCHAR DataBuffer[1]; } GenericReparseBuffer; } DUMMYUNIONNAME; - } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; + } REPARSE_DATA_BUFFER; #ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE #define MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024) #endif @@ -1567,18 +1567,17 @@ GHC_INLINE path resolveSymlink(const path& p, std::error_code& ec) return path(); } - char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE] = {0}; - REPARSE_DATA_BUFFER& reparseData = *(REPARSE_DATA_BUFFER*)buffer; + std::shared_ptr reparseData((REPARSE_DATA_BUFFER*)std::calloc(1, MAXIMUM_REPARSE_DATA_BUFFER_SIZE), std::free); ULONG bufferUsed; path result; - if (DeviceIoControl(file.get(), FSCTL_GET_REPARSE_POINT, 0, 0, &reparseData, sizeof(buffer), &bufferUsed, 0)) { - if (IsReparseTagMicrosoft(reparseData.ReparseTag)) { - switch (reparseData.ReparseTag) { + if (DeviceIoControl(file.get(), FSCTL_GET_REPARSE_POINT, 0, 0, reparseData.get(), MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bufferUsed, 0)) { + if (IsReparseTagMicrosoft(reparseData->ReparseTag)) { + switch (reparseData->ReparseTag) { case IO_REPARSE_TAG_SYMLINK: - result = std::wstring(&reparseData.SymbolicLinkReparseBuffer.PathBuffer[reparseData.SymbolicLinkReparseBuffer.PrintNameOffset / sizeof(WCHAR)], reparseData.SymbolicLinkReparseBuffer.PrintNameLength / sizeof(WCHAR)); + result = std::wstring(&reparseData->SymbolicLinkReparseBuffer.PathBuffer[reparseData->SymbolicLinkReparseBuffer.PrintNameOffset / sizeof(WCHAR)], reparseData->SymbolicLinkReparseBuffer.PrintNameLength / sizeof(WCHAR)); break; case IO_REPARSE_TAG_MOUNT_POINT: - result = std::wstring(&reparseData.MountPointReparseBuffer.PathBuffer[reparseData.MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR)], reparseData.MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR)); + result = std::wstring(&reparseData->MountPointReparseBuffer.PathBuffer[reparseData->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR)], reparseData->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR)); break; default: break; @@ -3772,7 +3771,7 @@ GHC_INLINE void permissions(const path& p, perms prms, perm_options opts, std::e } } #ifdef GHC_OS_WINDOWS -# ifdef __GNUC__ +#ifdef __GNUC__ auto oldAttr = GetFileAttributesW(p.wstring().c_str()); if (oldAttr != INVALID_FILE_ATTRIBUTES) { DWORD newAttr = ((prms & perms::owner_write) == perms::owner_write) ? oldAttr & ~FILE_ATTRIBUTE_READONLY : oldAttr | FILE_ATTRIBUTE_READONLY; @@ -3781,7 +3780,7 @@ GHC_INLINE void permissions(const path& p, perms prms, perm_options opts, std::e } } ec = std::error_code(::GetLastError(), std::system_category()); -# else +#else int mode = 0; if ((prms & perms::owner_read) == perms::owner_read) { mode |= _S_IREAD; @@ -3792,7 +3791,7 @@ GHC_INLINE void permissions(const path& p, perms prms, perm_options opts, std::e if (::_wchmod(p.wstring().c_str(), mode) != 0) { ec = std::error_code(::GetLastError(), std::system_category()); } -# endif +#endif #else if ((opts & perm_options::nofollow) != perm_options::nofollow) { if (::chmod(p.c_str(), static_cast(prms)) != 0) { diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index f00dc8f..a4a5ef9 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -212,7 +212,7 @@ inline bool isWow64Proc() bIsWow64 = FALSE; } } - return bIsWow64; + return bIsWow64 == TRUE; } static bool is_symlink_creation_supported()