From cb4ff53a18620b23610873914e1a02f92cd5223b Mon Sep 17 00:00:00 2001 From: "philip.liard@gmail.com" Date: Wed, 17 Aug 2011 10:14:24 +0000 Subject: [PATCH] CPP: Fix bug in installation step and add test to the continuous integration script. git-svn-id: http://libphonenumber.googlecode.com/svn/trunk@335 ee073f10-1060-11df-b6a4-87a95322a99c --- cpp/CMakeLists.txt | 4 +++- tools/script/continuous-integration.sh | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 4aecdc3..4cda515 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -313,10 +313,12 @@ install (FILES install (FILES "src/base/basictypes.h" - "src/base/memory/singleton.h" "src/base/scoped_ptr.h" DESTINATION include/base/ ) +install (FILES src/base/memory/singleton.h + DESTINATION include/base/memory) + install (FILES src/base/synchronization/lock.h DESTINATION include/base/synchronization) diff --git a/tools/script/continuous-integration.sh b/tools/script/continuous-integration.sh index 81efebb..212b4b3 100755 --- a/tools/script/continuous-integration.sh +++ b/tools/script/continuous-integration.sh @@ -23,12 +23,39 @@ (find resources/geocoding -type f | xargs file | egrep -v 'UTF-8|ASCII') && exit 1 # Test the C++ version with the provided CMake parameter. +CXX=g++ +INSTALL_PREFIX=/tmp/libphonenumber + test_cpp_version() { + CC_TEST_FILE=`mktemp`.cc + CC_TEST_BINARY=`mktemp` CMAKE_FLAGS="$1" + # Write the program that tests the installation of the library to a temporary + # source file. + > $CC_TEST_FILE echo ' + #include + #include + using i18n::phonenumbers::PhoneNumberUtil; + int main() { + PhoneNumberUtil* const phone_util = PhoneNumberUtil::GetInstance(); + return phone_util == NULL; + }' + # Run the build and tests. ( - rm -rf cpp/build && mkdir cpp/build && cd cpp/build && \ - cmake "${CMAKE_FLAGS}" .. && make && ./libphonenumber_test - ) || exit $? + rm -rf cpp/build /tmp/libphonenumber && + mkdir cpp/build /tmp/libphonenumber && cd cpp/build && + cmake "${CMAKE_FLAGS}" -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX .. && + make && ./libphonenumber_test && make install && + $CXX -o $CC_TEST_BINARY $CC_TEST_FILE -I${INSTALL_PREFIX}/include \ + -lboost_thread -L${INSTALL_PREFIX}/lib -lphonenumber && + $CC_TEST_BINARY + ) + STATUS=$? + # Remove the temporary files. + rm -f $CC_TEST_FILE + rm -f $CC_TEST_BINARY + + [ $STATUS -ne 0 ] && exit $STATUS } test_cpp_version '' test_cpp_version '-DUSE_RE2=ON' -- 2.7.4