From ded31e1b73d96c559e0ccd236382ad3b6b641870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= Date: Wed, 8 May 2024 06:51:18 +0100 Subject: [PATCH] Fix PDAL support on MinGW-w64 https://github.com/hobuinc/untwine/pull/162 https://github.com/PDAL/wrench/pull/35 --- .github/workflows/mingw-w64-msys2.yml | 2 +- external/pdal_wrench/tile/tile.cpp | 4 ++++ external/untwine/untwine/Common.cpp | 8 ++++++++ external/untwine/untwine/Untwine.cpp | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mingw-w64-msys2.yml b/.github/workflows/mingw-w64-msys2.yml index c667f99f521..159dfcaa9d3 100644 --- a/.github/workflows/mingw-w64-msys2.yml +++ b/.github/workflows/mingw-w64-msys2.yml @@ -71,7 +71,7 @@ jobs: -DPython_EXECUTABLE=${MINGW_PREFIX}/bin/python \ -DWITH_3D=ON \ -DWITH_DRACO=ON \ - -DWITH_PDAL=OFF \ + -DWITH_PDAL=ON \ -DWITH_CUSTOM_WIDGETS=ON \ -DWITH_BINDINGS=OFF \ -DWITH_GRASS=OFF \ diff --git a/external/pdal_wrench/tile/tile.cpp b/external/pdal_wrench/tile/tile.cpp index cbd85ed9fbd..e368c136f0a 100644 --- a/external/pdal_wrench/tile/tile.cpp +++ b/external/pdal_wrench/tile/tile.cpp @@ -51,7 +51,11 @@ std::vector directoryList(const std::string& dir) fs::directory_iterator end; while (it != end) { +#ifndef __MINGW32__ files.push_back(untwine::fromNative(it->path())); +#else + files.push_back(untwine::fromNative(it->path().string())); +#endif it++; } } diff --git a/external/untwine/untwine/Common.cpp b/external/untwine/untwine/Common.cpp index cd56816474f..21720c39e71 100644 --- a/external/untwine/untwine/Common.cpp +++ b/external/untwine/untwine/Common.cpp @@ -55,7 +55,11 @@ MapContext mapFile(const std::string& filename, bool readOnly, size_t pos, size_ #ifndef _WIN32 ctx.m_fd = ::open(filename.data(), readOnly ? O_RDONLY : O_RDWR); #else +#ifdef _MSC_VER ctx.m_fd = ::_wopen(toNative(filename).data(), readOnly ? _O_RDONLY : _O_RDWR); +#else + ctx.m_fd = ::_open(toNative(filename).data(), readOnly ? _O_RDONLY : _O_RDWR); +#endif #endif if (ctx.m_fd == -1) @@ -129,7 +133,11 @@ std::vector directoryList(const std::string& dir) fs::directory_iterator end; while (it != end) { +#ifndef __MINGW32__ files.push_back(untwine::fromNative(it->path())); +#else + files.push_back(untwine::fromNative(it->path().string())); +#endif it++; } } diff --git a/external/untwine/untwine/Untwine.cpp b/external/untwine/untwine/Untwine.cpp index 75c39710be9..e2b23193150 100644 --- a/external/untwine/untwine/Untwine.cpp +++ b/external/untwine/untwine/Untwine.cpp @@ -122,7 +122,7 @@ void cleanup(const std::string& dir, bool rmdir) } // namespace untwine -#ifdef _WIN32 +#ifdef _MSC_VER int wmain( int argc, wchar_t *argv[ ], wchar_t *envp[ ] ) #else int main(int argc, char *argv[])