diff --git a/.github/workflows/build-matrix.yml b/.github/workflows/build-matrix.yml index dd6024b..ee63705 100644 --- a/.github/workflows/build-matrix.yml +++ b/.github/workflows/build-matrix.yml @@ -22,6 +22,15 @@ jobs: arch: x86_64 test-bin-suffix: .md.exe + - identifier: windows-debug-mingw + os: windows-latest + name: 🏁 Windows Debug (MinGW) + target: template_debug + platform: windows + arch: x86_64 + mingw: true + test-bin-suffix: .md.exe + - identifier: windows-debug-replace os: windows-latest name: 🏁 Windows Debug (Replace Error UTF Compliance) @@ -39,6 +48,15 @@ jobs: arch: x86_64 test-bin-suffix: .md.exe + - identifier: windows-release-mingw + os: windows-latest + name: 🏁 Windows Release (MinGW) + target: template_release + platform: windows + arch: x86_64 + mingw: true + test-bin-suffix: .md.exe + - identifier: macos-debug os: macos-latest name: 🍎 macOS (universal) Debug @@ -98,6 +116,10 @@ jobs: submodules: recursive persist-credentials: false + - name: Setup MinGW for Windows/MinGW build + if: matrix.platform == 'windows' && (matrix.mingw || false) + uses: egor-tensin/setup-mingw@ef0952fadae6794e225c0c1654887408bcadbf64 + - name: Build uses: ./.github/actions/openvic-dl-build with: diff --git a/src/openvic-dataloader/detail/ConvertGbk.hpp b/src/openvic-dataloader/detail/ConvertGbk.hpp index 8ddd9a2..cba9791 100644 --- a/src/openvic-dataloader/detail/ConvertGbk.hpp +++ b/src/openvic-dataloader/detail/ConvertGbk.hpp @@ -11,12 +11,14 @@ #include #include -#ifdef _WIN32 +#if __has_include() +#include +#elif defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN -#elif defined(__unix__) || defined(__APPLE__) || __has_include() -#include +#elif defined(__unix__) || defined(__APPLE__) +#error " not found on POSIX system" #endif namespace ovdl::convert::gbk { @@ -42,7 +44,7 @@ namespace ovdl::convert::gbk { default: break; } -#if defined(__unix__) || defined(__APPLE__) || __has_include() +#if __has_include() iconv_t cd = ::iconv_open("UTF-8", "WINDOWS-936"); if (cd == (iconv_t)-1) { return lexy::buffer { resource }; @@ -102,7 +104,7 @@ namespace ovdl::convert::gbk { } return false; }; -#if defined(_WIN32) +#if !__has_include() && defined(_WIN32) auto iconv_mimic = [&]() -> int64_t { static constexpr size_t CP_GBK = 936; static constexpr size_t MB_CHAR_MAX = 16; @@ -205,7 +207,7 @@ namespace ovdl::convert::gbk { } } } -#elif defined(__unix__) || defined(__APPLE__) || __has_include() +#elif __has_include() const auto end = in_buffer + size; while (in_size > 0 && out_size > 0 && in_buffer != end) { if (::iconv(cd, &in_buffer, &in_size, &out_buffer, &out_size) == -1) {