From 6f003b62681f32e6f17fb18382f33c73da7113d3 Mon Sep 17 00:00:00 2001 From: Christopher Tubbs Date: Mon, 31 Mar 2025 19:02:31 -0400 Subject: [PATCH 1/3] Remove maven-antrun-plugin Replace maven-antrun-plugin with better alternatives: * Use build-helper-maven-plugin for keeping versions up-to-date in cclient code * Use build-helper-maven-plugin for retrieving hostname * Use Maven native `env.*` properties instead of antrun * Simplify maven-release-plugin to remove extra commit (versions should already be up-to-date from previous SNAPSHOT builds during development) * Use exec-maven-plugin for calling make * Use maven-resources-plugin for creating empty working directory * Use maven-resources-plugin for injecting the version into the cclient files (without the `-SNAPSHOT` suffix) * [BUGFIX] Fixes the incorrect pattern matching of version in `zookeeper_version.h` Additionally, perform some minor cleanup of modified files: * Fix xml indentations in modified pom.xml files * Use `${project.build.directory}` property instead of target when possible * [BUGFIX] Fix some paths that used semi-colons as the path separator and use the OS-dependent path separator This fixes a few bugs (see above notes). --- pom.xml | 228 ++++++-------- .../zookeeper-client-c/configure.ac | 2 +- zookeeper-client/zookeeper-client-c/pom.xml | 119 +++---- .../src/main/c-filtered/CMakeLists.txt | 293 ++++++++++++++++++ .../src/main/c-filtered/configure.ac | 275 ++++++++++++++++ .../c-filtered/include/zookeeper_version.h | 31 ++ zookeeper-server/pom.xml | 14 +- 7 files changed, 753 insertions(+), 209 deletions(-) create mode 100644 zookeeper-client/zookeeper-client-c/src/main/c-filtered/CMakeLists.txt create mode 100644 zookeeper-client/zookeeper-client-c/src/main/c-filtered/configure.ac create mode 100644 zookeeper-client/zookeeper-client-c/src/main/c-filtered/include/zookeeper_version.h diff --git a/pom.xml b/pom.xml index fde5aa9e098..7db61dc3acd 100644 --- a/pom.xml +++ b/pom.xml @@ -46,8 +46,8 @@ http://zookeeper.apache.org 2008 + an ASF parent pom older than v15. Also uses the url from v18. + --> Apache License, Version 2.0 @@ -248,10 +248,10 @@ -8 - eolivelli - Enrico Olivelli - eolivelli@apache.org - +1 + eolivelli + Enrico Olivelli + eolivelli@apache.org + +1 nkalmar @@ -304,44 +304,44 @@ - apache-release - - - - org.apache.maven.plugins - maven-assembly-plugin - - - org.apache.apache.resources - apache-source-release-assembly-descriptor - 1.0.6 - - - - - source-release-assembly-tar-gz - initialize - - single - - - true - - - ${sourceReleaseAssemblyDescriptor} - - apache-zookeeper-${project.version} - false - - tar.gz - - posix - - - - - - + apache-release + + + + org.apache.maven.plugins + maven-assembly-plugin + + + org.apache.apache.resources + apache-source-release-assembly-descriptor + 1.0.6 + + + + + source-release-assembly-tar-gz + initialize + + single + + + true + + + ${sourceReleaseAssemblyDescriptor} + + apache-zookeeper-${project.version} + false + + tar.gz + + posix + + + + + + m2e @@ -376,19 +376,6 @@ - - - org.apache.maven.plugins - maven-antrun-plugin - [0,) - - run - - - - - - com.ruleoftech @@ -481,8 +468,8 @@ org/apache/zookeeper/version/**/* - **/ReadOnlyModeTest.java - **/KeeperStateTest.java + **/ReadOnlyModeTest.java + **/KeeperStateTest.java @@ -527,7 +514,7 @@ reuseReports clover ${project.build.directory}/clover/clover.xml - target/surefire-reports + ${project.build.directory}/surefire-reports clover ${clover-maven-plugin.version} @@ -736,10 +723,10 @@ metrics-core ${dropwizard.version} - - org.slf4j - slf4j-api - + + org.slf4j + slf4j-api + @@ -784,17 +771,17 @@ org.apache.maven.plugins maven-compiler-plugin - true - - -Werror - -Xlint:deprecation - -Xlint:unchecked - -Xlint:-options - -Xdoclint:-missing - - -Xpkginfo:always - - + true + + -Werror + -Xlint:deprecation + -Xlint:unchecked + -Xlint:-options + -Xdoclint:-missing + + -Xpkginfo:always + + org.apache.maven.plugins @@ -825,10 +812,6 @@ maven-assembly-plugin 3.6.0 - - org.apache.maven.plugins - maven-release-plugin - org.apache.maven.plugins maven-scm-plugin @@ -838,14 +821,10 @@ org.apache.maven.plugins maven-surefire-plugin - false - ${redirectTestOutputToFile} + false + ${redirectTestOutputToFile} - - org.apache.maven.plugins - maven-antrun-plugin - org.apache.maven.plugins maven-dependency-plugin @@ -866,7 +845,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.0.0 + 3.6.0 net.nicoulaj.maven.plugins @@ -918,8 +897,8 @@ maven-remote-resources-plugin - process-resource-bundles - none + process-resource-bundles + none @@ -932,7 +911,7 @@ org.cyclonedx cyclonedx-maven-plugin 2.7.9 - + @@ -951,21 +930,23 @@ - org.apache.maven.plugins - maven-antrun-plugin + org.codehaus.mojo + build-helper-maven-plugin + + parse-version + + parse-version + + set-hostname-property validate - run + hostname - true - - - - + host.name @@ -1103,48 +1084,17 @@ - org.apache.maven.plugins - maven-release-plugin - false - - - clean verify -DskipTests antrun:run@replace-cclient-files-during-release scm:add@add-cclient-files-during-release scm:checkin@commit-cclient-files-during-release - clean verify -DskipTests antrun:run@replace-cclient-files-during-release scm:add@add-cclient-files-during-release scm:checkin@commit-cclient-files-during-release - false - true - true - release-@{project.version} - - - - org.apache.maven.plugins - maven-scm-plugin - false - - - add-cclient-files-during-release - none - - add - - - false - zookeeper-client/zookeeper-client-c/CMakeLists.txt,zookeeper-client/zookeeper-client-c/configure.ac,zookeeper-client/zookeeper-client-c/include/zookeeper_version.h - - - - commit-cclient-files-during-release - none - - - checkin - - - false - Prepared ${project.version} - - - + org.apache.maven.plugins + maven-release-plugin + false + + clean verify -DskipTests + clean verify -DskipTests + false + true + true + release-@{project.version} + org.apache.maven.plugins diff --git a/zookeeper-client/zookeeper-client-c/configure.ac b/zookeeper-client/zookeeper-client-c/configure.ac index 0de8427e5bb..832cd816b48 100644 --- a/zookeeper-client/zookeeper-client-c/configure.ac +++ b/zookeeper-client/zookeeper-client-c/configure.ac @@ -66,7 +66,7 @@ else fi AM_CONDITIONAL([WANT_OPENSSL],[test "x$with_openssl" != xno]) -if test "$CALLER" = "ANT" ; then +if test "$CALLER" = "EXECMAVENPLUGIN" ; then CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS -DZKSERVER_CMD=\"\\\"${base_dir}/zookeeper-client/zookeeper-client-c/tests/zkServer.sh\\\"\"" else CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS -DZKSERVER_CMD=\"\\\"./tests/zkServer.sh\\\"\"" diff --git a/zookeeper-client/zookeeper-client-c/pom.xml b/zookeeper-client/zookeeper-client-c/pom.xml index 4550be26501..667ecdba55f 100644 --- a/zookeeper-client/zookeeper-client-c/pom.xml +++ b/zookeeper-client/zookeeper-client-c/pom.xml @@ -37,7 +37,7 @@ - + org.codehaus.mojo exec-maven-plugin @@ -69,7 +69,7 @@ ${project.basedir}/configure ${project.basedir}/../.. - ANT + EXECMAVENPLUGIN --with-openssl=${c-client-openssl} @@ -79,64 +79,63 @@ + + build-c-client + compile + + exec + + + ${project.build.directory}/c + make + + clean + install + + + ${env.LD_LIBRARY_PATH}${path.separator}/usr/lib + ${env.PATH}${path.separator}${basedir} + EXECMAVENPLUGIN + ${basedir}/../../zookeeper-server/target + ${basedir}/../.. + + + org.apache.maven.plugins - maven-antrun-plugin + maven-resources-plugin - generate-sources + mkdir-target-c generate-sources - - - - - - run + copy-resources - - - build-c-client - compile - - - - - - - - - - + ${project.build.directory}/c + - - run - - replace-cclient-files-during-release - none + prepare-filtered-c-source - run + copy-resources + generate-sources - - - - -SNAPSHOT - - - - -SNAPSHOT - - - - -SNAPSHOT - - + ./ + false + + @ + + + + src/main/c-filtered + true + + @@ -162,29 +161,31 @@ - org.apache.maven.plugins - maven-antrun-plugin + org.codehaus.mojo + exec-maven-plugin test-cppunit test + + exec + + ${project.build.directory}/c + make + + check + ${skipTests} - - - - - - - - - - + + ${env.LD_LIBRARY_PATH}${path.separator}/usr/lib + ${env.PATH}${path.separator}${basedir} + EXECMAVENPLUGIN + ${basedir}/../../zookeeper-server/target + ${basedir}/../.. + - - run - diff --git a/zookeeper-client/zookeeper-client-c/src/main/c-filtered/CMakeLists.txt b/zookeeper-client/zookeeper-client-c/src/main/c-filtered/CMakeLists.txt new file mode 100644 index 00000000000..1d1aa79b297 --- /dev/null +++ b/zookeeper-client/zookeeper-client-c/src/main/c-filtered/CMakeLists.txt @@ -0,0 +1,293 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.5) + +project(zookeeper VERSION @parsedVersion.majorVersion@.@parsedVersion.minorVersion@.@parsedVersion.incrementalVersion@) +set(email user@zookeeper.apache.org) +set(description "zookeeper C client") + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../tools/cmake/Modules") + +# general options +if(UNIX) + add_compile_options(-Wall -fPIC) +elseif(WIN32) + add_compile_options(/W3) +endif() +add_definitions(-DUSE_STATIC_LIB) + +# TODO: Enable /WX and /W4 on Windows. Currently there are ~1000 warnings. +# TODO: Add Solaris support. +# TODO: Add a shared library option. +# TODO: Specify symbols to export. +# TODO: Generate doxygen documentation. + +# Sync API option +option(WANT_SYNCAPI "Enables Sync API support" ON) +if(WANT_SYNCAPI) + add_definitions(-DTHREADED) +endif() + +# CppUnit option +if(WIN32 OR APPLE) + # The tests do not yet compile on Windows or macOS, + # so we set this to off by default. + # + # Note that CMake does not have expressions except in conditionals, + # so we're left with this if/else/endif pattern. + set(DEFAULT_WANT_CPPUNIT OFF) +else() + set(DEFAULT_WANT_CPPUNIT ON) +endif() +option(WANT_CPPUNIT "Enables CppUnit and tests" ${DEFAULT_WANT_CPPUNIT}) + +# SOCK_CLOEXEC +option(WANT_SOCK_CLOEXEC "Enables SOCK_CLOEXEC on sockets" OFF) +include(CheckSymbolExists) +check_symbol_exists(SOCK_CLOEXEC sys/socket.h HAVE_SOCK_CLOEXEC) +if(WANT_SOCK_CLOEXEC AND HAVE_SOCK_CLOEXEC) + set(SOCK_CLOEXEC_ENABLED 1) +endif() + +# Cyrus SASL 2.x +option(WITH_CYRUS_SASL "turn ON/OFF Cyrus SASL 2.x support, or define SASL library location (default: ON)" ON) +message("-- using WITH_CYRUS_SASL=${WITH_CYRUS_SASL}") +if(NOT WITH_CYRUS_SASL STREQUAL "OFF") + if(NOT WITH_CYRUS_SASL STREQUAL "ON") + set(CYRUS_SASL_ROOT_DIR "${WITH_CYRUS_SASL}") + endif() + find_package(CyrusSASL) + if(CYRUS_SASL_FOUND) + message("-- Cyrus SASL 2.x found! will build with SASL support.") + else() + message("-- WARNING: unable to find Cyrus SASL 2.x! will build without SASL support.") + endif() +endif() + +# The function `to_have(in out)` converts a header name like `arpa/inet.h` +# into an Autotools style preprocessor definition `HAVE_ARPA_INET_H`. +# This is then set or unset in `configure_file()` step. +# +# Note that CMake functions do not have return values; instead an "out" +# variable must be passed, and explicitly set with parent scope. +function(to_have in out) + string(TOUPPER ${in} str) + string(REGEX REPLACE "/|\\." "_" str ${str}) + set(${out} "HAVE_${str}" PARENT_SCOPE) +endfunction() + +# include file checks +foreach(f generated/zookeeper.jute.h generated/zookeeper.jute.c) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${f}") + to_have(${f} name) + set(${name} 1) + else() + message(FATAL_ERROR + "jute files are missing!\n" + "Please run 'ant compile_jute' while in the ZooKeeper top level directory.") + endif() +endforeach() + +# header checks +include(CheckIncludeFile) +set(check_headers + arpa/inet.h + dlfcn.h + fcntl.h + inttypes.h + memory.h + netdb.h + netinet/in.h + stdint.h + stdlib.h + string.h + strings.h + sys/socket.h + sys/stat.h + sys/time.h + sys/types.h + unistd.h + sys/utsname.h) + +foreach(f ${check_headers}) + to_have(${f} name) + check_include_file(${f} ${name}) +endforeach() + +# function checks +include(CheckFunctionExists) +set(check_functions + getcwd + gethostbyname + gethostname + getlogin + getpwuid_r + gettimeofday + getuid + memmove + memset + poll + socket + strchr + strdup + strerror + strtol) + +foreach(fn ${check_functions}) + to_have(${fn} name) + check_function_exists(${fn} ${name}) +endforeach() + +# library checks +set(check_libraries rt m pthread) +foreach(lib ${check_libraries}) + to_have("lib${lib}" name) + find_library(${name} ${lib}) +endforeach() + +# IPv6 check +include(CheckStructHasMember) +check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h" ZOO_IPV6_ENABLED) + +# configure +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_link_libraries(hashtable PUBLIC $<$,$>:m>) + +# zookeeper library +set(zookeeper_sources + src/zookeeper.c + src/recordio.c + generated/zookeeper.jute.c + src/zk_log.c + src/zk_hashtable.c + src/addrvec.c) + +if(WANT_SYNCAPI) + list(APPEND zookeeper_sources src/mt_adaptor.c) +else() + list(APPEND zookeeper_sources src/st_adaptor.c) +endif() + +if(CYRUS_SASL_FOUND) + list(APPEND zookeeper_sources src/zk_sasl.c) +endif() + +if(WIN32) + list(APPEND zookeeper_sources src/winport.c) +endif() + +add_library(zookeeper STATIC ${zookeeper_sources}) +target_include_directories(zookeeper PUBLIC include ${CMAKE_CURRENT_BINARY_DIR}/include generated) +target_link_libraries(zookeeper PUBLIC + hashtable + $<$:rt> # clock_gettime + $<$:ws2_32>) # Winsock 2.0 + +option(WITH_OPENSSL "turn ON/OFF SSL support, or define openssl library location (default: ON)" ON) +message("-- using WITH_OPENSSL=${WITH_OPENSSL}") +if(NOT WITH_OPENSSL STREQUAL "OFF") + if(NOT WITH_OPENSSL STREQUAL "ON") + set(OPENSSL_ROOT_DIR,${WITH_OPENSSL}) + endif() + find_package(OpenSSL) + if(OPENSSL_FOUND) + target_compile_definitions(zookeeper PUBLIC HAVE_OPENSSL_H) + target_link_libraries(zookeeper PUBLIC OpenSSL::SSL OpenSSL::Crypto) + message("-- OpenSSL libraries found! will build with SSL support.") + else() + message("-- WARNING: unable to find OpenSSL libraries! will build without SSL support.") + endif() +endif() + +if(WANT_SYNCAPI AND NOT WIN32) + find_package(Threads REQUIRED) + target_link_libraries(zookeeper PUBLIC Threads::Threads) +endif() + +if(CYRUS_SASL_FOUND) + target_compile_definitions(zookeeper PUBLIC HAVE_CYRUS_SASL_H) + target_link_libraries(zookeeper PUBLIC CyrusSASL) +endif() + +# cli executable +add_executable(cli src/cli.c) +target_link_libraries(cli zookeeper) + +# load_gen executable +if(WANT_SYNCAPI AND NOT WIN32) + add_executable(load_gen src/load_gen.c) + target_link_libraries(load_gen zookeeper) +endif() + +# tests +set(test_sources + tests/TestDriver.cc + tests/LibCMocks.cc + tests/LibCSymTable.cc + tests/MocksBase.cc + tests/ZKMocks.cc + tests/Util.cc + tests/ThreadingUtil.cc + tests/TestZookeeperInit.cc + tests/TestZookeeperClose.cc + tests/TestSASLAuth.cc + tests/TestReconfig.cc + tests/TestReconfigServer.cc + tests/TestClientRetry.cc + tests/TestOperations.cc + tests/TestMulti.cc + tests/TestWatchers.cc + tests/TestClient.cc + tests/ZooKeeperQuorumServer.cc + tests/TestReadOnlyClient.cc + tests/TestLogClientEnv.cc) + +if(WANT_SYNCAPI) + list(APPEND test_sources tests/PthreadMocks.cc) +endif() + +if(WANT_CPPUNIT) + set (CMAKE_CXX_STANDARD 11) + add_executable(zktest ${test_sources}) + target_include_directories(zktest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + + target_compile_definitions(zktest + PRIVATE -DZKSERVER_CMD="${CMAKE_CURRENT_SOURCE_DIR}/tests/zkServer.sh") + # TODO: Use `find_library()` for `cppunit`. + target_link_libraries(zktest zookeeper cppunit dl) + + # This reads the link flags from the file `tests/wrappers.opt` into + # the variable `symbol_wrappers` for use in `target_link_libraries`. + # It is a holdover from the original build system. + file(STRINGS tests/wrappers.opt symbol_wrappers) + if(WANT_SYNCAPI) + file(STRINGS tests/wrappers-mt.opt symbol_wrappers_mt) + endif() + + target_link_libraries(zktest ${symbol_wrappers} ${symbol_wrappers_mt}) + + enable_testing() + add_test(NAME zktest_runner COMMAND zktest) + set_property(TEST zktest_runner PROPERTY ENVIRONMENT + "ZKROOT=${CMAKE_CURRENT_SOURCE_DIR}/../.." + "CLASSPATH=$CLASSPATH:$CLOVER_HOME/lib/clover*.jar") +endif() diff --git a/zookeeper-client/zookeeper-client-c/src/main/c-filtered/configure.ac b/zookeeper-client/zookeeper-client-c/src/main/c-filtered/configure.ac new file mode 100644 index 00000000000..e1e7a8b071e --- /dev/null +++ b/zookeeper-client/zookeeper-client-c/src/main/c-filtered/configure.ac @@ -0,0 +1,275 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.59) + +AC_INIT([zookeeper C client],@parsedVersion.majorVersion@.@parsedVersion.minorVersion@.@parsedVersion.incrementalVersion@,[user@zookeeper.apache.org],[zookeeper]) +AC_CONFIG_SRCDIR([src/zookeeper.c]) + +# Save initial CFLAGS and CXXFLAGS values before AC_PROG_CC and AC_PROG_CXX +init_cflags="$CFLAGS" +init_cxxflags="$CXXFLAGS" + +# initialize Doxygen support +DX_HTML_FEATURE(ON) +DX_CHM_FEATURE(OFF) +DX_CHI_FEATURE(OFF) +DX_MAN_FEATURE(OFF) +DX_RTF_FEATURE(OFF) +DX_XML_FEATURE(OFF) +DX_PDF_FEATURE(OFF) +DX_PS_FEATURE(OFF) +DX_INIT_DOXYGEN([zookeeper],[c-doc.Doxyfile],[docs]) + +# initialize automake +AM_INIT_AUTOMAKE([-Wall foreign]) + +AC_CONFIG_HEADER([config.h]) + +# Checks for programs. +AC_ARG_WITH(cppunit, + [ --without-cppunit do not use CPPUNIT]) + +if test "$with_cppunit" = "no" ; then + CPPUNIT_PATH="No_CPPUNIT" + CPPUNIT_INCLUDE= + CPPUNIT_LIBS= +else + CHECK_CPPUNIT(1.10.2) +fi + +dnl OpenSSL +AC_ARG_WITH(openssl, + [AC_HELP_STRING([--with-openssl[=DIR]], [build with openssl (autodetect openssl library by default) )])], + [], [with_openssl=yes]) +AC_MSG_NOTICE([configuring SSL using --with-openssl=$with_openssl]) +saved_CPPFLAGS="$CPPFLAGS" +saved_LDFLAGS="$LDFLAGS" +if test "x$with_openssl" != "xno" && test "x$with_openssl" != "xyes" ; then + CPPFLAGS="$CPPFLAGS -I$with_openssl/include" + LDFLAGS="$LDFLAGS -L$with_openssl/lib" +fi +have_openssl=no +AC_CHECK_HEADER(openssl/ssl.h, [ AC_CHECK_LIB(ssl, SSL_CTX_new, [have_openssl=yes]) ]) +if test "x$with_openssl" != "xno" && test "x$with_openssl" != "xyes" && test "x$have_openssl" != "xyes"; then + CPPFLAGS="$saved_CPPFLAGS" + LDFLAGS="$saved_LDFLAGS" +fi +if test "x$with_openssl" != xno && test "x$have_openssl" = xno; then + AC_MSG_WARN([cannot build SSL support -- openssl not found]) + with_openssl=no +fi +if test "x$with_openssl" != xno; then + AC_MSG_NOTICE([building with SSL support]) +else + AC_MSG_NOTICE([building without SSL support]) +fi +AM_CONDITIONAL([WANT_OPENSSL],[test "x$with_openssl" != xno]) + +if test "$CALLER" = "EXECMAVENPLUGIN" ; then +CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS -DZKSERVER_CMD=\"\\\"${base_dir}/zookeeper-client/zookeeper-client-c/tests/zkServer.sh\\\"\"" +else +CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS -DZKSERVER_CMD=\"\\\"./tests/zkServer.sh\\\"\"" +AC_CHECK_FILES([$srcdir/generated/zookeeper.jute.c $srcdir/generated/zookeeper.jute.h],[], + [AC_MSG_ERROR([jute files are missing! Please run "ant compile_jute" while in the zookeeper top level directory.]) +]) +fi +AC_SUBST(CPPUNIT_CFLAGS) + +AC_PROG_CC +AM_PROG_CC_C_O +AC_PROG_CXX +AC_PROG_INSTALL +AC_PROG_LN_S + +# AC_DISABLE_SHARED +AC_PROG_LIBTOOL + +#enable -D_GNU_SOURCE since the return code value of getaddrinfo +#ifdefed with __USE_GNU +#features.h header undef's __USE_GNU and defines it only if _GNU_SOURCE is defined +#hence this define for gcc +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug],[enable debug build [default=no]])], + [],[enable_debug=no]) + +if test "x$enable_debug" = xyes; then + if test "x$init_cflags" = x; then + CFLAGS="" + fi + CFLAGS="$CFLAGS -g -O0 -D_GNU_SOURCE" +else + if test "x$init_cflags" = x; then + CFLAGS="-g -O2 -D_GNU_SOURCE" + fi +fi + +if test "x$enable_debug" = xyes; then + if test "x$init_cxxflags" = x; then + CXXFLAGS="" + fi + CXXFLAGS="$CXXFLAGS -g -O0" +else + if test "x$init_cxxflags" = x; then + CXXFLAGS="-g -O2" + fi +fi + +# Check whether to enable gcov (coverage test) +AC_ARG_ENABLE(gcov, [AS_HELP_STRING([--enable-gcov],[enable coverage test])]) +AC_MSG_CHECKING([whether to enable gcov]) +AS_IF([test "x${enable_gcov}" = "xyes"],AC_MSG_RESULT([yes]),AC_MSG_RESULT([no])) +AM_CONDITIONAL([ENABLEGCOV],[test "x${enable_gcov}" = "xyes"]) + + +CXXFLAGS="$CXXFLAGS -std=c++11" + +AC_ARG_WITH([syncapi], + [AS_HELP_STRING([--with-syncapi],[build with support for SyncAPI [default=yes]])], + [],[with_syncapi=yes]) + +# Checks for libraries. +AC_CHECK_LIB([pthread], [pthread_mutex_lock],[have_pthread=yes],[have_pthread=no]) + +if test "x$with_syncapi" != xno && test "x$have_pthread" = xno; then + AC_MSG_WARN([cannot build SyncAPI -- pthread not found]) + with_syncapi=no +fi +if test "x$with_syncapi" != xno; then + AC_MSG_NOTICE([building with SyncAPI support]) +else + AC_MSG_NOTICE([building without SyncAPI support]) +fi + +AM_CONDITIONAL([WANT_SYNCAPI],[test "x$with_syncapi" != xno]) + +dnl Cyrus SASL 2.x +AC_ARG_WITH(sasl, + [AC_HELP_STRING([--with-sasl[=DIR]], [build with SASL support via Cyrus SASL 2.x (default=auto)])], + [], [with_sasl=yes]) +if test "x$with_sasl" != "xno"; then + saved_CPPFLAGS="$CPPFLAGS" + saved_LDFLAGS="$LDFLAGS" + if test "x$with_sasl" != "xyes" ; then + CPPFLAGS="$CPPFLAGS -I$with_sasl/include" + LDFLAGS="$LDFLAGS -L$with_sasl/lib" + fi + have_sasl=no + AC_CHECK_HEADER(sasl/sasl.h, [ + AC_CHECK_LIB(sasl2, sasl_client_init, [have_sasl=yes])]) + if test "x$have_sasl" != "xyes"; then + CPPFLAGS="$saved_CPPFLAGS" + LDFLAGS="$saved_LDFLAGS" + fi +fi +if test "x$with_sasl" != xno && test "x$have_sasl" = xno; then + AC_MSG_WARN([cannot build SASL support -- sasl2 not found]) + with_sasl=no +fi +if test "x$with_sasl" != xno; then + AC_MSG_NOTICE([building with SASL support]) +else + AC_MSG_NOTICE([building without SASL support]) +fi +AM_CONDITIONAL([WANT_SASL],[test "x$with_sasl" != xno]) + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h sys/utsname.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_C_INLINE +AC_HEADER_TIME +AC_CHECK_TYPE([nfds_t], + [AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[poll() second argument type])], + [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[poll() second argument type])], + [#include ]) + +AC_MSG_CHECKING([whether to enable ipv6]) + +AC_TRY_RUN([ /* is AF_INET6 available? */ +#include +#include +main() +{ + if (socket(AF_INET6, SOCK_STREAM, 0) < 0) + exit(1); + else + exit(0); +} +], AC_MSG_RESULT(yes) + ipv6=yes, + AC_MSG_RESULT(no) + ipv6=no, + AC_MSG_RESULT(no) + ipv6=no) + +if test x"$ipv6" = xyes; then + USEIPV6="-DZOO_IPV6_ENABLED" + AC_SUBST(USEIPV6) +fi + +# use SOCK_CLOEXEC if available and wanted +AC_ARG_WITH([sock_cloexec], +[AS_HELP_STRING([--with-sock-cloexec],[build with SOCK_CLOEXEC flag set on the connections])], +[],[with_sock_cloexec=no]) + +AC_MSG_CHECKING([whether SOCK_CLOEXEC is available]) + +AC_TRY_RUN([ /* is SOCK_CLOEXEC available ? */ +#include +#include +#include +main() +{ +#ifdef SOCK_CLOEXEC + exit(0); +#else + exit(1); +#endif +} +], AC_MSG_RESULT(yes) + has_sock_cloexec=yes, + AC_MSG_RESULT(no) + has_sock_cloexec=no, + AC_MSG_RESULT(no) + has_sock_cloexec=no) + +if test "x$with_sock_cloexec" != xno && test "x$has_sock_cloexec" = xno; then + AC_MSG_WARN([cannot use SOCK_CLOEXEC -- SOCK_CLOEXEC undefined on this platform]) + with_sock_cloexec=no +fi + +if test "x$with_sock_cloexec" != xno; then +AC_MSG_NOTICE([building with SOCK_CLOEXEC]) +else +AC_MSG_NOTICE([building without SOCK_CLOEXEC]) +fi + +AS_IF([test x"$with_sock_cloexec" != xno], [AC_DEFINE([SOCK_CLOEXEC_ENABLED], [1], [Define to 1, if SOCK_CLOEXEC is defined and wanted])]) +AM_CONDITIONAL([SOCK_CLOEXEC_ENABLED],[test "x$with_sock_cloexec" != xno]) + +# Determine which libraries we need to use clock_gettime +saved_LIBS="$LIBS" +LIBS="" +AC_CHECK_LIB(rt, clock_gettime) +CLOCK_GETTIME_LIBS=$LIBS +AC_SUBST(CLOCK_GETTIME_LIBS) +LIBS="$saved_LIBS" + +# Checks for library functions. +AC_CHECK_FUNCS([getcwd gethostbyname gethostname getlogin getpwuid_r gettimeofday getuid memmove memset poll socket strchr strdup strerror strtol]) + +AC_CONFIG_FILES([Makefile]) +AC_CANONICAL_HOST +AM_CONDITIONAL([SOLARIS],[ + case "$host_os" in + *solaris*) + true + ;; + *) + false + ;; + esac ]) +AC_OUTPUT diff --git a/zookeeper-client/zookeeper-client-c/src/main/c-filtered/include/zookeeper_version.h b/zookeeper-client/zookeeper-client-c/src/main/c-filtered/include/zookeeper_version.h new file mode 100644 index 00000000000..88d26f75801 --- /dev/null +++ b/zookeeper-client/zookeeper-client-c/src/main/c-filtered/include/zookeeper_version.h @@ -0,0 +1,31 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ZOOKEEPER_VERSION_H_ +#define ZOOKEEPER_VERSION_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZOO_VERSION "@parsedVersion.majorVersion@.@parsedVersion.minorVersion@.@parsedVersion.incrementalVersion@" + +#ifdef __cplusplus +} +#endif + +#endif /* ZOOKEEPER_VERSION_H_ */ diff --git a/zookeeper-server/pom.xml b/zookeeper-server/pom.xml index 495e4847919..e103daa8e42 100644 --- a/zookeeper-server/pom.xml +++ b/zookeeper-server/pom.xml @@ -121,9 +121,9 @@ provided - io.dropwizard.metrics - metrics-core - provided + io.dropwizard.metrics + metrics-core + provided org.apache.kerby @@ -211,12 +211,6 @@ UTC - - parse-version - - parse-version - - generate-sources @@ -346,7 +340,7 @@ - + From b52ad0a152c2b7c4086b82ac4bdbb62f345fb7a0 Mon Sep 17 00:00:00 2001 From: Christopher Tubbs Date: Thu, 8 May 2025 15:57:22 -0400 Subject: [PATCH 2/3] Remove and untrack generated files * Remove generated files * Add generated files to .gitignore * Add a comment to the generated files so developers know which files to edit --- .../zookeeper-client-c/.gitignore | 4 + .../zookeeper-client-c/CMakeLists.txt | 293 ------------------ .../zookeeper-client-c/configure.ac | 275 ---------------- .../include/zookeeper_version.h | 31 -- zookeeper-client/zookeeper-client-c/pom.xml | 1 + .../src/main/c-filtered/CMakeLists.txt | 2 + .../src/main/c-filtered/configure.ac | 2 + .../c-filtered/include/zookeeper_version.h | 3 + 8 files changed, 12 insertions(+), 599 deletions(-) create mode 100644 zookeeper-client/zookeeper-client-c/.gitignore delete mode 100644 zookeeper-client/zookeeper-client-c/CMakeLists.txt delete mode 100644 zookeeper-client/zookeeper-client-c/configure.ac delete mode 100644 zookeeper-client/zookeeper-client-c/include/zookeeper_version.h diff --git a/zookeeper-client/zookeeper-client-c/.gitignore b/zookeeper-client/zookeeper-client-c/.gitignore new file mode 100644 index 00000000000..ef201f916e1 --- /dev/null +++ b/zookeeper-client/zookeeper-client-c/.gitignore @@ -0,0 +1,4 @@ +# Ignore generated files from the Maven build to patch the ZooKeeper version +/CMakeLists.txt +/configure.ac +/include/zookeeper_version.h diff --git a/zookeeper-client/zookeeper-client-c/CMakeLists.txt b/zookeeper-client/zookeeper-client-c/CMakeLists.txt deleted file mode 100644 index da1351e20f5..00000000000 --- a/zookeeper-client/zookeeper-client-c/CMakeLists.txt +++ /dev/null @@ -1,293 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cmake_minimum_required(VERSION 3.5) - -project(zookeeper VERSION 3.10.0) -set(email user@zookeeper.apache.org) -set(description "zookeeper C client") - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../tools/cmake/Modules") - -# general options -if(UNIX) - add_compile_options(-Wall -fPIC) -elseif(WIN32) - add_compile_options(/W3) -endif() -add_definitions(-DUSE_STATIC_LIB) - -# TODO: Enable /WX and /W4 on Windows. Currently there are ~1000 warnings. -# TODO: Add Solaris support. -# TODO: Add a shared library option. -# TODO: Specify symbols to export. -# TODO: Generate doxygen documentation. - -# Sync API option -option(WANT_SYNCAPI "Enables Sync API support" ON) -if(WANT_SYNCAPI) - add_definitions(-DTHREADED) -endif() - -# CppUnit option -if(WIN32 OR APPLE) - # The tests do not yet compile on Windows or macOS, - # so we set this to off by default. - # - # Note that CMake does not have expressions except in conditionals, - # so we're left with this if/else/endif pattern. - set(DEFAULT_WANT_CPPUNIT OFF) -else() - set(DEFAULT_WANT_CPPUNIT ON) -endif() -option(WANT_CPPUNIT "Enables CppUnit and tests" ${DEFAULT_WANT_CPPUNIT}) - -# SOCK_CLOEXEC -option(WANT_SOCK_CLOEXEC "Enables SOCK_CLOEXEC on sockets" OFF) -include(CheckSymbolExists) -check_symbol_exists(SOCK_CLOEXEC sys/socket.h HAVE_SOCK_CLOEXEC) -if(WANT_SOCK_CLOEXEC AND HAVE_SOCK_CLOEXEC) - set(SOCK_CLOEXEC_ENABLED 1) -endif() - -# Cyrus SASL 2.x -option(WITH_CYRUS_SASL "turn ON/OFF Cyrus SASL 2.x support, or define SASL library location (default: ON)" ON) -message("-- using WITH_CYRUS_SASL=${WITH_CYRUS_SASL}") -if(NOT WITH_CYRUS_SASL STREQUAL "OFF") - if(NOT WITH_CYRUS_SASL STREQUAL "ON") - set(CYRUS_SASL_ROOT_DIR "${WITH_CYRUS_SASL}") - endif() - find_package(CyrusSASL) - if(CYRUS_SASL_FOUND) - message("-- Cyrus SASL 2.x found! will build with SASL support.") - else() - message("-- WARNING: unable to find Cyrus SASL 2.x! will build without SASL support.") - endif() -endif() - -# The function `to_have(in out)` converts a header name like `arpa/inet.h` -# into an Autotools style preprocessor definition `HAVE_ARPA_INET_H`. -# This is then set or unset in `configure_file()` step. -# -# Note that CMake functions do not have return values; instead an "out" -# variable must be passed, and explicitly set with parent scope. -function(to_have in out) - string(TOUPPER ${in} str) - string(REGEX REPLACE "/|\\." "_" str ${str}) - set(${out} "HAVE_${str}" PARENT_SCOPE) -endfunction() - -# include file checks -foreach(f generated/zookeeper.jute.h generated/zookeeper.jute.c) - if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${f}") - to_have(${f} name) - set(${name} 1) - else() - message(FATAL_ERROR - "jute files are missing!\n" - "Please run 'ant compile_jute' while in the ZooKeeper top level directory.") - endif() -endforeach() - -# header checks -include(CheckIncludeFile) -set(check_headers - arpa/inet.h - dlfcn.h - fcntl.h - inttypes.h - memory.h - netdb.h - netinet/in.h - stdint.h - stdlib.h - string.h - strings.h - sys/socket.h - sys/stat.h - sys/time.h - sys/types.h - unistd.h - sys/utsname.h) - -foreach(f ${check_headers}) - to_have(${f} name) - check_include_file(${f} ${name}) -endforeach() - -# function checks -include(CheckFunctionExists) -set(check_functions - getcwd - gethostbyname - gethostname - getlogin - getpwuid_r - gettimeofday - getuid - memmove - memset - poll - socket - strchr - strdup - strerror - strtol) - -foreach(fn ${check_functions}) - to_have(${fn} name) - check_function_exists(${fn} ${name}) -endforeach() - -# library checks -set(check_libraries rt m pthread) -foreach(lib ${check_libraries}) - to_have("lib${lib}" name) - find_library(${name} ${lib}) -endforeach() - -# IPv6 check -include(CheckStructHasMember) -check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h" ZOO_IPV6_ENABLED) - -# configure -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_link_libraries(hashtable PUBLIC $<$,$>:m>) - -# zookeeper library -set(zookeeper_sources - src/zookeeper.c - src/recordio.c - generated/zookeeper.jute.c - src/zk_log.c - src/zk_hashtable.c - src/addrvec.c) - -if(WANT_SYNCAPI) - list(APPEND zookeeper_sources src/mt_adaptor.c) -else() - list(APPEND zookeeper_sources src/st_adaptor.c) -endif() - -if(CYRUS_SASL_FOUND) - list(APPEND zookeeper_sources src/zk_sasl.c) -endif() - -if(WIN32) - list(APPEND zookeeper_sources src/winport.c) -endif() - -add_library(zookeeper STATIC ${zookeeper_sources}) -target_include_directories(zookeeper PUBLIC include ${CMAKE_CURRENT_BINARY_DIR}/include generated) -target_link_libraries(zookeeper PUBLIC - hashtable - $<$:rt> # clock_gettime - $<$:ws2_32>) # Winsock 2.0 - -option(WITH_OPENSSL "turn ON/OFF SSL support, or define openssl library location (default: ON)" ON) -message("-- using WITH_OPENSSL=${WITH_OPENSSL}") -if(NOT WITH_OPENSSL STREQUAL "OFF") - if(NOT WITH_OPENSSL STREQUAL "ON") - set(OPENSSL_ROOT_DIR,${WITH_OPENSSL}) - endif() - find_package(OpenSSL) - if(OPENSSL_FOUND) - target_compile_definitions(zookeeper PUBLIC HAVE_OPENSSL_H) - target_link_libraries(zookeeper PUBLIC OpenSSL::SSL OpenSSL::Crypto) - message("-- OpenSSL libraries found! will build with SSL support.") - else() - message("-- WARNING: unable to find OpenSSL libraries! will build without SSL support.") - endif() -endif() - -if(WANT_SYNCAPI AND NOT WIN32) - find_package(Threads REQUIRED) - target_link_libraries(zookeeper PUBLIC Threads::Threads) -endif() - -if(CYRUS_SASL_FOUND) - target_compile_definitions(zookeeper PUBLIC HAVE_CYRUS_SASL_H) - target_link_libraries(zookeeper PUBLIC CyrusSASL) -endif() - -# cli executable -add_executable(cli src/cli.c) -target_link_libraries(cli zookeeper) - -# load_gen executable -if(WANT_SYNCAPI AND NOT WIN32) - add_executable(load_gen src/load_gen.c) - target_link_libraries(load_gen zookeeper) -endif() - -# tests -set(test_sources - tests/TestDriver.cc - tests/LibCMocks.cc - tests/LibCSymTable.cc - tests/MocksBase.cc - tests/ZKMocks.cc - tests/Util.cc - tests/ThreadingUtil.cc - tests/TestZookeeperInit.cc - tests/TestZookeeperClose.cc - tests/TestSASLAuth.cc - tests/TestReconfig.cc - tests/TestReconfigServer.cc - tests/TestClientRetry.cc - tests/TestOperations.cc - tests/TestMulti.cc - tests/TestWatchers.cc - tests/TestClient.cc - tests/ZooKeeperQuorumServer.cc - tests/TestReadOnlyClient.cc - tests/TestLogClientEnv.cc) - -if(WANT_SYNCAPI) - list(APPEND test_sources tests/PthreadMocks.cc) -endif() - -if(WANT_CPPUNIT) - set (CMAKE_CXX_STANDARD 11) - add_executable(zktest ${test_sources}) - target_include_directories(zktest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) - - target_compile_definitions(zktest - PRIVATE -DZKSERVER_CMD="${CMAKE_CURRENT_SOURCE_DIR}/tests/zkServer.sh") - # TODO: Use `find_library()` for `cppunit`. - target_link_libraries(zktest zookeeper cppunit dl) - - # This reads the link flags from the file `tests/wrappers.opt` into - # the variable `symbol_wrappers` for use in `target_link_libraries`. - # It is a holdover from the original build system. - file(STRINGS tests/wrappers.opt symbol_wrappers) - if(WANT_SYNCAPI) - file(STRINGS tests/wrappers-mt.opt symbol_wrappers_mt) - endif() - - target_link_libraries(zktest ${symbol_wrappers} ${symbol_wrappers_mt}) - - enable_testing() - add_test(NAME zktest_runner COMMAND zktest) - set_property(TEST zktest_runner PROPERTY ENVIRONMENT - "ZKROOT=${CMAKE_CURRENT_SOURCE_DIR}/../.." - "CLASSPATH=$CLASSPATH:$CLOVER_HOME/lib/clover*.jar") -endif() diff --git a/zookeeper-client/zookeeper-client-c/configure.ac b/zookeeper-client/zookeeper-client-c/configure.ac deleted file mode 100644 index 832cd816b48..00000000000 --- a/zookeeper-client/zookeeper-client-c/configure.ac +++ /dev/null @@ -1,275 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.59) - -AC_INIT([zookeeper C client],3.10.0,[user@zookeeper.apache.org],[zookeeper]) -AC_CONFIG_SRCDIR([src/zookeeper.c]) - -# Save initial CFLAGS and CXXFLAGS values before AC_PROG_CC and AC_PROG_CXX -init_cflags="$CFLAGS" -init_cxxflags="$CXXFLAGS" - -# initialize Doxygen support -DX_HTML_FEATURE(ON) -DX_CHM_FEATURE(OFF) -DX_CHI_FEATURE(OFF) -DX_MAN_FEATURE(OFF) -DX_RTF_FEATURE(OFF) -DX_XML_FEATURE(OFF) -DX_PDF_FEATURE(OFF) -DX_PS_FEATURE(OFF) -DX_INIT_DOXYGEN([zookeeper],[c-doc.Doxyfile],[docs]) - -# initialize automake -AM_INIT_AUTOMAKE([-Wall foreign]) - -AC_CONFIG_HEADER([config.h]) - -# Checks for programs. -AC_ARG_WITH(cppunit, - [ --without-cppunit do not use CPPUNIT]) - -if test "$with_cppunit" = "no" ; then - CPPUNIT_PATH="No_CPPUNIT" - CPPUNIT_INCLUDE= - CPPUNIT_LIBS= -else - CHECK_CPPUNIT(1.10.2) -fi - -dnl OpenSSL -AC_ARG_WITH(openssl, - [AC_HELP_STRING([--with-openssl[=DIR]], [build with openssl (autodetect openssl library by default) )])], - [], [with_openssl=yes]) -AC_MSG_NOTICE([configuring SSL using --with-openssl=$with_openssl]) -saved_CPPFLAGS="$CPPFLAGS" -saved_LDFLAGS="$LDFLAGS" -if test "x$with_openssl" != "xno" && test "x$with_openssl" != "xyes" ; then - CPPFLAGS="$CPPFLAGS -I$with_openssl/include" - LDFLAGS="$LDFLAGS -L$with_openssl/lib" -fi -have_openssl=no -AC_CHECK_HEADER(openssl/ssl.h, [ AC_CHECK_LIB(ssl, SSL_CTX_new, [have_openssl=yes]) ]) -if test "x$with_openssl" != "xno" && test "x$with_openssl" != "xyes" && test "x$have_openssl" != "xyes"; then - CPPFLAGS="$saved_CPPFLAGS" - LDFLAGS="$saved_LDFLAGS" -fi -if test "x$with_openssl" != xno && test "x$have_openssl" = xno; then - AC_MSG_WARN([cannot build SSL support -- openssl not found]) - with_openssl=no -fi -if test "x$with_openssl" != xno; then - AC_MSG_NOTICE([building with SSL support]) -else - AC_MSG_NOTICE([building without SSL support]) -fi -AM_CONDITIONAL([WANT_OPENSSL],[test "x$with_openssl" != xno]) - -if test "$CALLER" = "EXECMAVENPLUGIN" ; then -CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS -DZKSERVER_CMD=\"\\\"${base_dir}/zookeeper-client/zookeeper-client-c/tests/zkServer.sh\\\"\"" -else -CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS -DZKSERVER_CMD=\"\\\"./tests/zkServer.sh\\\"\"" -AC_CHECK_FILES([$srcdir/generated/zookeeper.jute.c $srcdir/generated/zookeeper.jute.h],[], - [AC_MSG_ERROR([jute files are missing! Please run "ant compile_jute" while in the zookeeper top level directory.]) -]) -fi -AC_SUBST(CPPUNIT_CFLAGS) - -AC_PROG_CC -AM_PROG_CC_C_O -AC_PROG_CXX -AC_PROG_INSTALL -AC_PROG_LN_S - -# AC_DISABLE_SHARED -AC_PROG_LIBTOOL - -#enable -D_GNU_SOURCE since the return code value of getaddrinfo -#ifdefed with __USE_GNU -#features.h header undef's __USE_GNU and defines it only if _GNU_SOURCE is defined -#hence this define for gcc -AC_ARG_ENABLE([debug], - [AS_HELP_STRING([--enable-debug],[enable debug build [default=no]])], - [],[enable_debug=no]) - -if test "x$enable_debug" = xyes; then - if test "x$init_cflags" = x; then - CFLAGS="" - fi - CFLAGS="$CFLAGS -g -O0 -D_GNU_SOURCE" -else - if test "x$init_cflags" = x; then - CFLAGS="-g -O2 -D_GNU_SOURCE" - fi -fi - -if test "x$enable_debug" = xyes; then - if test "x$init_cxxflags" = x; then - CXXFLAGS="" - fi - CXXFLAGS="$CXXFLAGS -g -O0" -else - if test "x$init_cxxflags" = x; then - CXXFLAGS="-g -O2" - fi -fi - -# Check whether to enable gcov (coverage test) -AC_ARG_ENABLE(gcov, [AS_HELP_STRING([--enable-gcov],[enable coverage test])]) -AC_MSG_CHECKING([whether to enable gcov]) -AS_IF([test "x${enable_gcov}" = "xyes"],AC_MSG_RESULT([yes]),AC_MSG_RESULT([no])) -AM_CONDITIONAL([ENABLEGCOV],[test "x${enable_gcov}" = "xyes"]) - - -CXXFLAGS="$CXXFLAGS -std=c++11" - -AC_ARG_WITH([syncapi], - [AS_HELP_STRING([--with-syncapi],[build with support for SyncAPI [default=yes]])], - [],[with_syncapi=yes]) - -# Checks for libraries. -AC_CHECK_LIB([pthread], [pthread_mutex_lock],[have_pthread=yes],[have_pthread=no]) - -if test "x$with_syncapi" != xno && test "x$have_pthread" = xno; then - AC_MSG_WARN([cannot build SyncAPI -- pthread not found]) - with_syncapi=no -fi -if test "x$with_syncapi" != xno; then - AC_MSG_NOTICE([building with SyncAPI support]) -else - AC_MSG_NOTICE([building without SyncAPI support]) -fi - -AM_CONDITIONAL([WANT_SYNCAPI],[test "x$with_syncapi" != xno]) - -dnl Cyrus SASL 2.x -AC_ARG_WITH(sasl, - [AC_HELP_STRING([--with-sasl[=DIR]], [build with SASL support via Cyrus SASL 2.x (default=auto)])], - [], [with_sasl=yes]) -if test "x$with_sasl" != "xno"; then - saved_CPPFLAGS="$CPPFLAGS" - saved_LDFLAGS="$LDFLAGS" - if test "x$with_sasl" != "xyes" ; then - CPPFLAGS="$CPPFLAGS -I$with_sasl/include" - LDFLAGS="$LDFLAGS -L$with_sasl/lib" - fi - have_sasl=no - AC_CHECK_HEADER(sasl/sasl.h, [ - AC_CHECK_LIB(sasl2, sasl_client_init, [have_sasl=yes])]) - if test "x$have_sasl" != "xyes"; then - CPPFLAGS="$saved_CPPFLAGS" - LDFLAGS="$saved_LDFLAGS" - fi -fi -if test "x$with_sasl" != xno && test "x$have_sasl" = xno; then - AC_MSG_WARN([cannot build SASL support -- sasl2 not found]) - with_sasl=no -fi -if test "x$with_sasl" != xno; then - AC_MSG_NOTICE([building with SASL support]) -else - AC_MSG_NOTICE([building without SASL support]) -fi -AM_CONDITIONAL([WANT_SASL],[test "x$with_sasl" != xno]) - -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h sys/utsname.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_C_INLINE -AC_HEADER_TIME -AC_CHECK_TYPE([nfds_t], - [AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[poll() second argument type])], - [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[poll() second argument type])], - [#include ]) - -AC_MSG_CHECKING([whether to enable ipv6]) - -AC_TRY_RUN([ /* is AF_INET6 available? */ -#include -#include -main() -{ - if (socket(AF_INET6, SOCK_STREAM, 0) < 0) - exit(1); - else - exit(0); -} -], AC_MSG_RESULT(yes) - ipv6=yes, - AC_MSG_RESULT(no) - ipv6=no, - AC_MSG_RESULT(no) - ipv6=no) - -if test x"$ipv6" = xyes; then - USEIPV6="-DZOO_IPV6_ENABLED" - AC_SUBST(USEIPV6) -fi - -# use SOCK_CLOEXEC if available and wanted -AC_ARG_WITH([sock_cloexec], -[AS_HELP_STRING([--with-sock-cloexec],[build with SOCK_CLOEXEC flag set on the connections])], -[],[with_sock_cloexec=no]) - -AC_MSG_CHECKING([whether SOCK_CLOEXEC is available]) - -AC_TRY_RUN([ /* is SOCK_CLOEXEC available ? */ -#include -#include -#include -main() -{ -#ifdef SOCK_CLOEXEC - exit(0); -#else - exit(1); -#endif -} -], AC_MSG_RESULT(yes) - has_sock_cloexec=yes, - AC_MSG_RESULT(no) - has_sock_cloexec=no, - AC_MSG_RESULT(no) - has_sock_cloexec=no) - -if test "x$with_sock_cloexec" != xno && test "x$has_sock_cloexec" = xno; then - AC_MSG_WARN([cannot use SOCK_CLOEXEC -- SOCK_CLOEXEC undefined on this platform]) - with_sock_cloexec=no -fi - -if test "x$with_sock_cloexec" != xno; then -AC_MSG_NOTICE([building with SOCK_CLOEXEC]) -else -AC_MSG_NOTICE([building without SOCK_CLOEXEC]) -fi - -AS_IF([test x"$with_sock_cloexec" != xno], [AC_DEFINE([SOCK_CLOEXEC_ENABLED], [1], [Define to 1, if SOCK_CLOEXEC is defined and wanted])]) -AM_CONDITIONAL([SOCK_CLOEXEC_ENABLED],[test "x$with_sock_cloexec" != xno]) - -# Determine which libraries we need to use clock_gettime -saved_LIBS="$LIBS" -LIBS="" -AC_CHECK_LIB(rt, clock_gettime) -CLOCK_GETTIME_LIBS=$LIBS -AC_SUBST(CLOCK_GETTIME_LIBS) -LIBS="$saved_LIBS" - -# Checks for library functions. -AC_CHECK_FUNCS([getcwd gethostbyname gethostname getlogin getpwuid_r gettimeofday getuid memmove memset poll socket strchr strdup strerror strtol]) - -AC_CONFIG_FILES([Makefile]) -AC_CANONICAL_HOST -AM_CONDITIONAL([SOLARIS],[ - case "$host_os" in - *solaris*) - true - ;; - *) - false - ;; - esac ]) -AC_OUTPUT diff --git a/zookeeper-client/zookeeper-client-c/include/zookeeper_version.h b/zookeeper-client/zookeeper-client-c/include/zookeeper_version.h deleted file mode 100644 index 639eaf5fe28..00000000000 --- a/zookeeper-client/zookeeper-client-c/include/zookeeper_version.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef ZOOKEEPER_VERSION_H_ -#define ZOOKEEPER_VERSION_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZOO_VERSION "3.10.0" - -#ifdef __cplusplus -} -#endif - -#endif /* ZOOKEEPER_VERSION_H_ */ diff --git a/zookeeper-client/zookeeper-client-c/pom.xml b/zookeeper-client/zookeeper-client-c/pom.xml index 667ecdba55f..57cb412181f 100644 --- a/zookeeper-client/zookeeper-client-c/pom.xml +++ b/zookeeper-client/zookeeper-client-c/pom.xml @@ -32,6 +32,7 @@ ZooKeeper c client + This file is GENERATED. Developers should edit the template in src/main/c-filtered/ diff --git a/zookeeper-client/zookeeper-client-c/src/main/c-filtered/CMakeLists.txt b/zookeeper-client/zookeeper-client-c/src/main/c-filtered/CMakeLists.txt index 1d1aa79b297..caa628e355b 100644 --- a/zookeeper-client/zookeeper-client-c/src/main/c-filtered/CMakeLists.txt +++ b/zookeeper-client/zookeeper-client-c/src/main/c-filtered/CMakeLists.txt @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# @filteredBuildComment@ + cmake_minimum_required(VERSION 3.5) project(zookeeper VERSION @parsedVersion.majorVersion@.@parsedVersion.minorVersion@.@parsedVersion.incrementalVersion@) diff --git a/zookeeper-client/zookeeper-client-c/src/main/c-filtered/configure.ac b/zookeeper-client/zookeeper-client-c/src/main/c-filtered/configure.ac index e1e7a8b071e..5967aa9a650 100644 --- a/zookeeper-client/zookeeper-client-c/src/main/c-filtered/configure.ac +++ b/zookeeper-client/zookeeper-client-c/src/main/c-filtered/configure.ac @@ -1,6 +1,8 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. +# @filteredBuildComment@ + AC_PREREQ(2.59) AC_INIT([zookeeper C client],@parsedVersion.majorVersion@.@parsedVersion.minorVersion@.@parsedVersion.incrementalVersion@,[user@zookeeper.apache.org],[zookeeper]) diff --git a/zookeeper-client/zookeeper-client-c/src/main/c-filtered/include/zookeeper_version.h b/zookeeper-client/zookeeper-client-c/src/main/c-filtered/include/zookeeper_version.h index 88d26f75801..d0c2ed4793e 100644 --- a/zookeeper-client/zookeeper-client-c/src/main/c-filtered/include/zookeeper_version.h +++ b/zookeeper-client/zookeeper-client-c/src/main/c-filtered/include/zookeeper_version.h @@ -15,6 +15,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/* @filteredBuildComment@ */ + #ifndef ZOOKEEPER_VERSION_H_ #define ZOOKEEPER_VERSION_H_ From 2931f537c97cf6397f9e72f04edd5dda4b56da97 Mon Sep 17 00:00:00 2001 From: Christopher Tubbs Date: Thu, 8 May 2025 16:39:52 -0400 Subject: [PATCH 3/3] Fix unrelated issue with JMockIt --- zookeeper-server/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zookeeper-server/pom.xml b/zookeeper-server/pom.xml index e103daa8e42..331097ab99f 100644 --- a/zookeeper-server/pom.xml +++ b/zookeeper-server/pom.xml @@ -275,7 +275,7 @@ ${surefire-forkcount} false - -Xmx512m -Dtest.junit.threads=${surefire-forkcount} -Dzookeeper.junit.threadid=${surefire.forkNumber} -javaagent:${org.jmockit:jmockit:jar} + -Xmx512m -Dtest.junit.threads=${surefire-forkcount} -Dzookeeper.junit.threadid=${surefire.forkNumber} -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar ${project.basedir} ${project.build.directory}/surefire