aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--third-party/cmake/BuildLuv.cmake12
-rw-r--r--third-party/cmake/PatchLuv.cmake29
-rw-r--r--third-party/patches/luv-Add-missing-definitions-for-MinGW.patch24
3 files changed, 34 insertions, 31 deletions
diff --git a/third-party/cmake/BuildLuv.cmake b/third-party/cmake/BuildLuv.cmake
index 2a786dd8f3..bc1e989cc2 100644
--- a/third-party/cmake/BuildLuv.cmake
+++ b/third-party/cmake/BuildLuv.cmake
@@ -37,9 +37,17 @@ set(LUV_SRC_DIR ${DEPS_BUILD_DIR}/src/luv)
set(LUV_INCLUDE_FLAGS
"-I${DEPS_INSTALL_DIR}/include -I${DEPS_INSTALL_DIR}/include/luajit-2.0")
+# Replace luv default rockspec with the alternate one under the "rockspecs"
+# directory
set(LUV_PATCH_COMMAND
- ${CMAKE_COMMAND} -DLUV_SRC_DIR=${LUV_SRC_DIR}
- -P ${PROJECT_SOURCE_DIR}/cmake/PatchLuv.cmake)
+ ${CMAKE_COMMAND} -E copy_directory ${LUV_SRC_DIR}/rockspecs ${LUV_SRC_DIR})
+if(MINGW)
+ set(LUV_PATCH_COMMAND
+ ${LUV_PATCH_COMMAND}
+ COMMAND ${GIT_EXECUTABLE} -C ${LUV_SRC_DIR} init
+ COMMAND ${GIT_EXECUTABLE} -C ${LUV_SRC_DIR} apply --ignore-whitespace
+ ${CMAKE_CURRENT_SOURCE_DIR}/patches/luv-Add-missing-definitions-for-MinGW.patch)
+endif()
set(LUV_CONFIGURE_COMMAND_COMMON
${CMAKE_COMMAND} ${LUV_SRC_DIR}
diff --git a/third-party/cmake/PatchLuv.cmake b/third-party/cmake/PatchLuv.cmake
deleted file mode 100644
index 96595a2f30..0000000000
--- a/third-party/cmake/PatchLuv.cmake
+++ /dev/null
@@ -1,29 +0,0 @@
-# replace luv default rockspec with the alternate one under the "rockspecs"
-# directory
-file(GLOB LUV_ROCKSPEC RELATIVE ${LUV_SRC_DIR} ${LUV_SRC_DIR}/*.rockspec)
-file(RENAME ${LUV_SRC_DIR}/rockspecs/${LUV_ROCKSPEC} ${LUV_SRC_DIR}/${LUV_ROCKSPEC})
-
-# Some versions of mingw are missing defines required by luv dns module, add
-# them now
-set(LUV_SRC_DNS_C_DEFS
-"#ifndef AI_NUMERICSERV
-# define AI_NUMERICSERV 0x0008
-#endif
-#ifndef AI_ALL
-# define AI_ALL 0x00000100
-#endif
-#ifndef AI_ADDRCONFIG
-# define AI_ADDRCONFIG 0x00000400
-#endif
-#ifndef AI_V4MAPPED
-# define AI_V4MAPPED 0x00000800
-#endif")
-
-file(READ ${LUV_SRC_DIR}/src/dns.c LUV_SRC_DNS_C)
-string(REPLACE
- "\n#include <netdb.h>"
- "\n#include <netdb.h>\n#else\n${LUV_SRC_DNS_C_DEFS}"
- LUV_SRC_DNS_C_PATCHED
- "${LUV_SRC_DNS_C}")
-file(WRITE ${LUV_SRC_DIR}/src/dns.c "${LUV_SRC_DNS_C_PATCHED}")
-
diff --git a/third-party/patches/luv-Add-missing-definitions-for-MinGW.patch b/third-party/patches/luv-Add-missing-definitions-for-MinGW.patch
new file mode 100644
index 0000000000..8954ae21c3
--- /dev/null
+++ b/third-party/patches/luv-Add-missing-definitions-for-MinGW.patch
@@ -0,0 +1,24 @@
+diff --git a/src/dns.c b/src/dns.c
+index 8634157..5f36625 100644
+--- a/src/dns.c
++++ b/src/dns.c
+@@ -20,6 +20,19 @@
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <netdb.h>
++#elif __MINGW32__
++# ifndef AI_NUMERICSERV
++# define AI_NUMERICSERV 0x0008
++# endif
++# ifndef AI_ALL
++# define AI_ALL 0x00000100
++# endif
++# ifndef AI_ADDRCONFIG
++# define AI_ADDRCONFIG 0x00000400
++# endif
++# ifndef AI_V4MAPPED
++# define AI_V4MAPPED 0x00000800
++# endif
+ #endif
+
+ static void luv_pushaddrinfo(lua_State* L, struct addrinfo* res) {