From b0a686aad72855b0aa69e89455bd4aa5cd2beb8d Mon Sep 17 00:00:00 2001 From: davidvujic Date: Tue, 23 Jul 2019 12:11:19 +0200 Subject: [PATCH 1/4] chore: skip build steps and ignore warnings using a custom CMakeLists.txt file --- patches/CMakeLists.txt | 68 ++++++++++++++++++++++++++++++++++++++++++ scripts/prepublish.js | 2 ++ 2 files changed, 70 insertions(+) create mode 100644 patches/CMakeLists.txt diff --git a/patches/CMakeLists.txt b/patches/CMakeLists.txt new file mode 100644 index 00000000..3768d910 --- /dev/null +++ b/patches/CMakeLists.txt @@ -0,0 +1,68 @@ +cmake_minimum_required(VERSION 3.6) + +project(zookeeper VERSION 3.4.13) +set(email user@zookeeper.apache.org) +set(description "zookeeper C client") + +# general options +include_directories(include tests generated ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) +add_compile_options(/W0) +add_definitions(-DUSE_STATIC_LIB) + +# CppUnit option +set(DEFAULT_WANT_CPPUNIT OFF) +option(WANT_CPPUNIT "Enables CppUnit and tests" ${DEFAULT_WANT_CPPUNIT}) + +# 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_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() + +# configure +configure_file(cmake_config.h.in ${CMAKE_SOURCE_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_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) + +list(APPEND zookeeper_sources src/st_adaptor.c) + +list(APPEND zookeeper_sources src/winport.c) + +add_library(zookeeper STATIC ${zookeeper_sources}) +target_link_libraries(zookeeper PUBLIC + hashtable + $<$:rt> # clock_gettime + $<$:ws2_32>) # Winsock 2.0 + +# cli executable +add_executable(cli src/cli.c) +target_link_libraries(cli zookeeper) diff --git a/scripts/prepublish.js b/scripts/prepublish.js index 3143e7af..b88ff3e8 100644 --- a/scripts/prepublish.js +++ b/scripts/prepublish.js @@ -83,6 +83,8 @@ function applyPatches() { shell.sed('-i', '#include "zookeeper.h"', '#include "winport.h"\n#include "zookeeper.h"\n', `${destination}/zk_adaptor.h`); shell.sed('-i', '#include "zk_adaptor.h"', '#include "zk_adaptor.h"\n#include "winport.h"\n', `${destination}/zookeeper.c`); + const cmakeFile = 'CMakeLists.txt'; + shell.cp(`${env.rootFolder}/patches/${cmakeFile}`, `${env.sourceFolder}/src/c/${cmakeFile}`); return; } From 965f7570719783a0944e6082a82c3fa1b86b3ee0 Mon Sep 17 00:00:00 2001 From: davidvujic Date: Tue, 23 Jul 2019 14:43:33 +0200 Subject: [PATCH 2/4] feat: quick install if not explicit verbose --- scripts/prepublish.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/prepublish.js b/scripts/prepublish.js index b88ff3e8..cbf97295 100644 --- a/scripts/prepublish.js +++ b/scripts/prepublish.js @@ -83,8 +83,10 @@ function applyPatches() { shell.sed('-i', '#include "zookeeper.h"', '#include "winport.h"\n#include "zookeeper.h"\n', `${destination}/zk_adaptor.h`); shell.sed('-i', '#include "zk_adaptor.h"', '#include "zk_adaptor.h"\n#include "winport.h"\n', `${destination}/zookeeper.c`); - const cmakeFile = 'CMakeLists.txt'; - shell.cp(`${env.rootFolder}/patches/${cmakeFile}`, `${env.sourceFolder}/src/c/${cmakeFile}`); + if (!process.env.ZK_INSTALL_VERBOSE) { + const cmakeFile = 'CMakeLists.txt'; + shell.cp(`${env.rootFolder}/patches/${cmakeFile}`, `${env.sourceFolder}/src/c/${cmakeFile}`); + } return; } From 4144cdb485edacdbc27df9b25144ca6b078540c4 Mon Sep 17 00:00:00 2001 From: davidvujic Date: Tue, 23 Jul 2019 15:41:51 +0200 Subject: [PATCH 3/4] added docs --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 2107364b..a58004cb 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,16 @@ To run full output during the module build one has to use `ZK_INSTALL_VERBOSE` f `ZK_INSTALL_VERBOSE=1 npm install` +##### For Windows (PowerShell): verbose build ##### +```bash +$env:ZK_INSTALL_VERBOSE=1 +npm install +``` +This PowerShell command will remove the environment variable: +```bash +Remove-Item Env:\ZK_INSTALL_VERBOSE +``` + # Implementation Notes ### NOTE on Module Status (DDOPSON-2011-11-30): From d5446a34c00579a746c9be5c28c2ac25f4afca80 Mon Sep 17 00:00:00 2001 From: davidvujic Date: Wed, 24 Jul 2019 13:01:55 +0200 Subject: [PATCH 4/4] fix: docs about windows installation process --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a58004cb..915d5137 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,7 @@ For more details please refer to ZooKeeper docs. # Windows support Install `CMake` to build a ZooKeeper client on Windows. `Python 2.7.x` is currently required by the tool `node-gyp` to build the ZooKeeper client as a native Node.js Addon. -Also, run `npm install` in a Powershell window as an __Administrator__. For further instructions visit [node-gyp documentation](https://github.com/nodejs/node-gyp/#on-windows). +Also, run `npm install` in a Powershell window. For further instructions visit [node-gyp documentation](https://github.com/nodejs/node-gyp/#on-windows). Windows support has been enabled mainly for supporting development, not for production.