From 6aa7c9926a9286f358c24064ab0028d77dad4147 Mon Sep 17 00:00:00 2001 From: Matteo Merli Date: Mon, 6 Feb 2017 13:51:23 -0800 Subject: [PATCH] Read pulsar version from inside cmake file --- .travis.yml | 4 ++-- pulsar-client-cpp/lib/CMakeLists.txt | 10 +++++++--- pulsar-client-cpp/{build.sh => travis-build.sh} | 3 +-- 3 files changed, 10 insertions(+), 7 deletions(-) rename pulsar-client-cpp/{build.sh => travis-build.sh} (91%) diff --git a/.travis.yml b/.travis.yml index f3ab0a4b89da6..90ad90ca16234 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,10 +14,10 @@ before_deploy: - echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --import-ownertrust --batch || true install: - - sudo bash -x $TRAVIS_BUILD_DIR/pulsar-client-cpp/build.sh $HOME/pulsar-dep $TRAVIS_BUILD_DIR dep + - sudo bash -x $TRAVIS_BUILD_DIR/pulsar-client-cpp/travis-build.sh $HOME/pulsar-dep $TRAVIS_BUILD_DIR dep after_success: - - sudo bash -x $TRAVIS_BUILD_DIR/pulsar-client-cpp/build.sh $HOME/pulsar-dep $TRAVIS_BUILD_DIR compile + - sudo bash -x $TRAVIS_BUILD_DIR/pulsar-client-cpp/travis-build.sh $HOME/pulsar-dep $TRAVIS_BUILD_DIR compile deploy: - diff --git a/pulsar-client-cpp/lib/CMakeLists.txt b/pulsar-client-cpp/lib/CMakeLists.txt index 335cef6796c47..6569945415b1c 100644 --- a/pulsar-client-cpp/lib/CMakeLists.txt +++ b/pulsar-client-cpp/lib/CMakeLists.txt @@ -16,13 +16,17 @@ file(GLOB PULSAR_SOURCES *.cc lz4/*.c checksum/*.cc) -set (CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -msse4.2 -mpclmul -D_PULSAR_VERSION_=\\\"$ENV{PULSAR_VERSION}\\\" ") +execute_process(COMMAND bash -c "cat ../pom.xml | grep -Po '()[^<]+' | sed 's/.*>//' | head -1" + OUTPUT_VARIABLE PULSAR_VERSION) +MESSAGE( STATUS "PULSAR VERSION: " ${PULSAR_VERSION} ) + +set (CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -msse4.2 -mpclmul -D_PULSAR_VERSION_=\\\"${PULSAR_VERSION}\\\" ") add_library(pulsarStatic STATIC ${PULSAR_SOURCES}) add_library(pulsarShared SHARED ${PULSAR_SOURCES}) -set_target_properties(pulsarStatic PROPERTIES OUTPUT_NAME pulsar VERSION $ENV{PULSAR_VERSION}) -set_target_properties(pulsarShared PROPERTIES OUTPUT_NAME pulsar VERSION $ENV{PULSAR_VERSION}) +set_target_properties(pulsarStatic PROPERTIES OUTPUT_NAME pulsar VERSION ${PULSAR_VERSION}) +set_target_properties(pulsarShared PROPERTIES OUTPUT_NAME pulsar VERSION ${PULSAR_VERSION}) target_link_libraries(pulsarStatic ${COMMON_LIBS}) target_link_libraries(pulsarShared ${COMMON_LIBS}) diff --git a/pulsar-client-cpp/build.sh b/pulsar-client-cpp/travis-build.sh similarity index 91% rename from pulsar-client-cpp/build.sh rename to pulsar-client-cpp/travis-build.sh index 4fe30baaa8062..f760afbc80780 100755 --- a/pulsar-client-cpp/build.sh +++ b/pulsar-client-cpp/travis-build.sh @@ -62,8 +62,7 @@ fi if [ "$3" = "all" -o "$3" = "compile" ]; then # Compile and run unit tests - PULSAR_VERSION=`cat $2/pom.xml | grep -Po '()[^<]+' | sed 's/.*>//' | head -1`; - exec_cmd "pushd $2/pulsar-client-cpp && PULSAR_VERSION=$PULSAR_VERSION cmake . && make && popd"; + exec_cmd "pushd $2/pulsar-client-cpp && cmake . && make && popd"; PULSAR_STANDALONE_CONF=$2/pulsar-client-cpp/tests/standalone.conf $2/bin/pulsar standalone & pid=$!; exec_cmd "sleep 10 && pushd $2/pulsar-client-cpp/tests && ./main && popd";