From 33485fd9068881a1d00609a0f4fc4d28184f2090 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 1 May 2024 14:10:01 +0800 Subject: [PATCH] Auto-update enet to v1.3.18 (#3913) * Update enet to v1.3.18 * patch cmake --------- Co-authored-by: star-hengxing --- .../e/enet/patches/{ => v1.3.17}/cmake.patch | 0 packages/e/enet/patches/v1.3.18/cmake.patch | 40 +++++++++++++++++++ packages/e/enet/xmake.lua | 28 +++---------- 3 files changed, 45 insertions(+), 23 deletions(-) rename packages/e/enet/patches/{ => v1.3.17}/cmake.patch (100%) create mode 100644 packages/e/enet/patches/v1.3.18/cmake.patch diff --git a/packages/e/enet/patches/cmake.patch b/packages/e/enet/patches/v1.3.17/cmake.patch similarity index 100% rename from packages/e/enet/patches/cmake.patch rename to packages/e/enet/patches/v1.3.17/cmake.patch diff --git a/packages/e/enet/patches/v1.3.18/cmake.patch b/packages/e/enet/patches/v1.3.18/cmake.patch new file mode 100644 index 000000000..3b93b8461 --- /dev/null +++ b/packages/e/enet/patches/v1.3.18/cmake.patch @@ -0,0 +1,40 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c6459b62..66d67884 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -84,19 +84,26 @@ set(SOURCE_FILES + source_group(include FILES ${INCLUDE_FILES}) + source_group(source FILES ${SOURCE_FILES}) + +-add_library(enet STATIC ++if(WIN32 AND BUILD_SHARED_LIBS AND (MSVC OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")) ++ add_definitions(-DENET_DLL=1) ++ add_definitions(-DENET_BUILDING_LIB) ++endif() ++ ++add_library(enet + ${INCLUDE_FILES} + ${SOURCE_FILES} + ) + +-if (MINGW) ++if (WIN32) + target_link_libraries(enet winmm ws2_32) + endif() + ++include(GNUInstallDirs) + install(TARGETS enet +- RUNTIME DESTINATION bin +- ARCHIVE DESTINATION lib/static +- LIBRARY DESTINATION lib) +- +-install(DIRECTORY include/ +- DESTINATION include) ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++) ++install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/enet ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ++) +\ No newline at end of file diff --git a/packages/e/enet/xmake.lua b/packages/e/enet/xmake.lua index 8a6602d52..77cb48299 100644 --- a/packages/e/enet/xmake.lua +++ b/packages/e/enet/xmake.lua @@ -1,5 +1,4 @@ package("enet") - set_homepage("http://enet.bespin.org") set_description("Reliable UDP networking library.") set_license("MIT") @@ -7,8 +6,11 @@ package("enet") add_urls("https://github.com/lsalzman/enet/archive/refs/tags/$(version).tar.gz", "https://github.com/lsalzman/enet.git") + add_versions("v1.3.18", "28603c895f9ed24a846478180ee72c7376b39b4bb1287b73877e5eae7d96b0dd") add_versions("v1.3.17", "1e0b4bc0b7127a2d779dd7928f0b31830f5b3dcb7ec9588c5de70033e8d2434a") - add_patches("v1.3.17", path.join(os.scriptdir(), "patches", "cmake.patch"), "e77d2d129952443d67c1ec432de81843d72b854d25bbd6fb244b0f85804d21d1") + + add_patches("v1.3.18", "patches/v1.3.18/cmake.patch", "8feb51d3220d04c53d93aea053db522a0429bb3a0236039a2b62d8f01a3f638b") + add_patches("v1.3.17", "patches/v1.3.17/cmake.patch", "e77d2d129952443d67c1ec432de81843d72b854d25bbd6fb244b0f85804d21d1") if is_plat("mingw") and is_subhost("msys") then add_extsources("pacman::enet") @@ -38,25 +40,5 @@ package("enet") end) on_test(function (package) - assert(package:check_cxxsnippets({test = [[ - void test() - { - if (enet_initialize () != 0) - return; - - ENetAddress address; - ENetHost* server; - address.host = ENET_HOST_ANY; - address.port = 1234; - server = enet_host_create (&address, 32, 2, 0, 0); - if (server == NULL) - return; - - ENetEvent event; - while (enet_host_service (server, &event, 1000) > 0); - - enet_host_destroy(server); - enet_deinitialize(); - } - ]]}, {includes = {"enet/enet.h"}})) + assert(package:has_cfuncs("enet_initialize", {includes = "enet/enet.h"})) end)