From 8c64785e78d28e56ca5f8886ea572afa27ac0dfd Mon Sep 17 00:00:00 2001 From: Samuel Marks <807580+SamuelMarks@users.noreply.github.com> Date: Sun, 7 Jul 2019 07:52:53 +1000 Subject: [PATCH] [zookeeper] Add new port (#7000) * [zookeeper-mt] Add new port * [zookeeper-mt] Upgrade from 3.5.4-beta to 3.5.5 * [zookeeper-mt] Fix upgrade * disable warnings and add static library check * edit cmake file * add async feature * add back some changes for export * add sync feature, disable parallel configure --- ports/zookeeper/CONTROL | 7 +++++ ports/zookeeper/cmake.patch | 50 ++++++++++++++++++++++++++++++++++ ports/zookeeper/portfile.cmake | 43 +++++++++++++++++++++++++++++ ports/zookeeper/win32.patch | 29 ++++++++++++++++++++ 4 files changed, 129 insertions(+) create mode 100644 ports/zookeeper/CONTROL create mode 100644 ports/zookeeper/cmake.patch create mode 100644 ports/zookeeper/portfile.cmake create mode 100644 ports/zookeeper/win32.patch diff --git a/ports/zookeeper/CONTROL b/ports/zookeeper/CONTROL new file mode 100644 index 0000000000..d10b1683a5 --- /dev/null +++ b/ports/zookeeper/CONTROL @@ -0,0 +1,7 @@ +Source: zookeeper +Version: 3.5.5 +Description: ZooKeeper C bindings +Default-Features: sync + +Feature: sync +Description: ZooKeeper with the sync API \ No newline at end of file diff --git a/ports/zookeeper/cmake.patch b/ports/zookeeper/cmake.patch new file mode 100644 index 0000000000..4dd8ef93b1 --- /dev/null +++ b/ports/zookeeper/cmake.patch @@ -0,0 +1,50 @@ +diff --git a/zookeeper-client/zookeeper-client-c/CMakeLists.txt b/zookeeper-client/zookeeper-client-c/CMakeLists.txt +index 24a5a1b..1b0ce4a 100644 +--- a/zookeeper-client/zookeeper-client-c/CMakeLists.txt ++++ b/zookeeper-client/zookeeper-client-c/CMakeLists.txt +@@ -153,7 +153,7 @@ configure_file(cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h) + # hashtable library + set(hashtable_sources src/hashtable/hashtable_itr.c src/hashtable/hashtable.c) + add_library(hashtable STATIC ${hashtable_sources}) +-target_include_directories(hashtable PUBLIC include) ++target_include_directories(hashtable PUBLIC $ $) + target_link_libraries(hashtable PUBLIC $<$,$>:m>) + + # zookeeper library +@@ -176,7 +176,10 @@ if(WIN32) + endif() + + add_library(zookeeper STATIC ${zookeeper_sources}) +-target_include_directories(zookeeper PUBLIC include ${CMAKE_CURRENT_BINARY_DIR}/include generated) ++target_include_directories(zookeeper PUBLIC ++ $ ++ $) ++ + target_link_libraries(zookeeper PUBLIC + hashtable + $<$:rt> # clock_gettime +@@ -247,3 +250,23 @@ if(WANT_CPPUNIT) + "ZKROOT=${CMAKE_CURRENT_SOURCE_DIR}/../.." + "CLASSPATH=$CLASSPATH:$CLOVER_HOME/lib/clover*.jar") + endif() ++ ++ ++target_compile_definitions(zookeeper PRIVATE _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE) ++target_compile_definitions(cli PRIVATE _CRT_SECURE_NO_WARNINGS) ++ ++file(GLOB ZOOKEEPER_HEADERS include/*.h) ++ ++install(FILES ${ZOOKEEPER_HEADERS} generated/zookeeper.jute.h DESTINATION include/zookeeper) ++ ++install(TARGETS zookeeper hashtable ++ EXPORT zookeeperConfig ++ RUNTIME DESTINATION bin ++ ARCHIVE DESTINATION lib ++ LIBRARY DESTINATION lib ++) ++install(EXPORT zookeeperConfig ++ FILE zookeeperConfig.cmake ++ NAMESPACE zookeeper:: ++ DESTINATION "${CMAKE_INSTALL_PREFIX}/share/zookeeper" ++) +\ No newline at end of file diff --git a/ports/zookeeper/portfile.cmake b/ports/zookeeper/portfile.cmake new file mode 100644 index 0000000000..2e315a61fd --- /dev/null +++ b/ports/zookeeper/portfile.cmake @@ -0,0 +1,43 @@ +include(vcpkg_common_functions) + +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_download_distfile(ARCHIVE + URLS "https://archive.apache.org/dist/zookeeper/zookeeper-3.5.5/apache-zookeeper-3.5.5.tar.gz" + FILENAME "zookeeper-3.5.5.tar.gz" + SHA512 4e22df899a83ca3cc15f6d94daadb1a8631fb4108e67b4f56d1f4fcf95f10f89c8ff1fb8a7c84799a3856d8803a8db1e1f2f3fe1b7dc0d6cedf485ef90fd212d +) + +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + PATCHES + cmake.patch + win32.patch +) + +set(SOURCE_PATH ${SOURCE_PATH}/zookeeper-client/zookeeper-client-c) + +set(WANT_SYNCAPI OFF) +if("sync" IN_LIST FEATURES) + set(WANT_SYNCAPI ON) +endif() + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + DISABLE_PARALLEL_CONFIGURE + PREFER_NINJA + OPTIONS + -DWANT_CPPUNIT=OFF + -DWANT_SYNCAPI=${WANT_SYNCAPI} +) + +vcpkg_install_cmake() + +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/zookeeper RENAME copyright) + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) + +vcpkg_fixup_cmake_targets() + +vcpkg_copy_pdbs() diff --git a/ports/zookeeper/win32.patch b/ports/zookeeper/win32.patch new file mode 100644 index 0000000000..b55f067358 --- /dev/null +++ b/ports/zookeeper/win32.patch @@ -0,0 +1,29 @@ +diff --git a/zookeeper-client/zookeeper-client-c/src/zk_log.c b/zookeeper-client/zookeeper-client-c/src/zk_log.c +index 436485e..1902b09 100644 +--- a/zookeeper-client/zookeeper-client-c/src/zk_log.c ++++ b/zookeeper-client/zookeeper-client-c/src/zk_log.c +@@ -108,8 +108,11 @@ static const char* time_now(char* now_str){ + gettimeofday(&tv,0); + + now = tv.tv_sec; ++#ifdef WIN32 ++ localtime_s(<, &now); ++#else + localtime_r(&now, <); +- ++#endif + // clone the format used by log4j ISO8601DateFormat + // specifically: "yyyy-MM-dd HH:mm:ss,SSS" + +diff --git a/zookeeper-client/zookeeper-client-c/src/zookeeper.c b/zookeeper-client/zookeeper-client-c/src/zookeeper.c +index 25baa9c..96ed379 100644 +--- a/zookeeper-client/zookeeper-client-c/src/zookeeper.c ++++ b/zookeeper-client/zookeeper-client-c/src/zookeeper.c +@@ -90,6 +90,7 @@ + #define EAI_ADDRFAMILY WSAEINVAL /* is this still needed? */ + #define EHOSTDOWN EPIPE + #define ESTALE ENODEV ++#define strtok_r strtok_s + #endif + + #define IF_DEBUG(x) if(logLevel==ZOO_LOG_LEVEL_DEBUG) {x;}