Skip to content

Commit

Permalink
[zookeeper] Add new port (#7000)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
SamuelMarks authored and dan-shaw committed Jul 6, 2019
1 parent 1000d82 commit 8c64785
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ports/zookeeper/CONTROL
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions ports/zookeeper/cmake.patch
Original file line number Diff line number Diff line change
@@ -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 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_link_libraries(hashtable PUBLIC $<$<OR:$<PLATFORM_ID:Linux>,$<PLATFORM_ID:FreeBSD>>: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
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/generated>)
+
target_link_libraries(zookeeper PUBLIC
hashtable
$<$<PLATFORM_ID:Linux>: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
43 changes: 43 additions & 0 deletions ports/zookeeper/portfile.cmake
Original file line number Diff line number Diff line change
@@ -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()
29 changes: 29 additions & 0 deletions ports/zookeeper/win32.patch
Original file line number Diff line number Diff line change
@@ -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(&lt, &now);
+#else
localtime_r(&now, &lt);
-
+#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;}

0 comments on commit 8c64785

Please sign in to comment.