Philippe Liard | bee8be5 | 2011-07-06 12:15:51 +0000 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
Philippe Liard | b59d908 | 2011-08-18 11:41:24 +0000 | [diff] [blame] | 3 | # Copyright (C) 2011 The Libphonenumber Authors |
Philippe Liard | bee8be5 | 2011-07-06 12:15:51 +0000 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Author: Philippe Liard |
| 18 | |
| 19 | # Countinuous integration script that tests the different versions and |
| 20 | # configurations of libphonenumber. |
| 21 | |
Philippe Liard | b8acd0d | 2011-08-16 13:13:07 +0000 | [diff] [blame] | 22 | # Check geocoding resource files encoding. |
| 23 | (find resources/geocoding -type f | xargs file | egrep -v 'UTF-8|ASCII') && exit 1 |
| 24 | |
Philippe Liard | bee8be5 | 2011-07-06 12:15:51 +0000 | [diff] [blame] | 25 | # Test the C++ version with the provided CMake parameter. |
Philippe Liard | 33a02e4 | 2011-08-17 10:14:24 +0000 | [diff] [blame] | 26 | CXX=g++ |
| 27 | INSTALL_PREFIX=/tmp/libphonenumber |
| 28 | |
Philippe Liard | bee8be5 | 2011-07-06 12:15:51 +0000 | [diff] [blame] | 29 | test_cpp_version() { |
Philippe Liard | 33a02e4 | 2011-08-17 10:14:24 +0000 | [diff] [blame] | 30 | CC_TEST_FILE=`mktemp`.cc |
| 31 | CC_TEST_BINARY=`mktemp` |
Philippe Liard | bee8be5 | 2011-07-06 12:15:51 +0000 | [diff] [blame] | 32 | CMAKE_FLAGS="$1" |
Philippe Liard | 62c4580 | 2012-05-09 11:09:53 +0000 | [diff] [blame] | 33 | LD_FLAGS="-L${INSTALL_PREFIX}/lib -lphonenumber -lboost_thread $2" |
Philippe Liard | 7b30af6 | 2011-09-21 17:43:54 +0000 | [diff] [blame] | 34 | |
Philippe Liard | 33a02e4 | 2011-08-17 10:14:24 +0000 | [diff] [blame] | 35 | # Write the program that tests the installation of the library to a temporary |
| 36 | # source file. |
| 37 | > $CC_TEST_FILE echo ' |
Philippe Liard | 7b30af6 | 2011-09-21 17:43:54 +0000 | [diff] [blame] | 38 | #include <cassert> |
| 39 | |
Philippe Liard | 4bffe68 | 2011-09-14 10:42:59 +0000 | [diff] [blame] | 40 | #include <base/memory/scoped_ptr.h> |
Philippe Liard | 7b30af6 | 2011-09-21 17:43:54 +0000 | [diff] [blame] | 41 | |
| 42 | // Include all the public headers. |
Philippe Liard | 4bffe68 | 2011-09-14 10:42:59 +0000 | [diff] [blame] | 43 | #include <phonenumbers/asyoutypeformatter.h> |
Philippe Liard | 7b30af6 | 2011-09-21 17:43:54 +0000 | [diff] [blame] | 44 | #include <phonenumbers/phonenumber.pb.h> |
| 45 | #include <phonenumbers/phonenumbermatch.h> |
| 46 | #include <phonenumbers/phonenumbermatcher.h> |
Philippe Liard | 33a02e4 | 2011-08-17 10:14:24 +0000 | [diff] [blame] | 47 | #include <phonenumbers/phonenumberutil.h> |
Philippe Liard | 4bffe68 | 2011-09-14 10:42:59 +0000 | [diff] [blame] | 48 | |
| 49 | using i18n::phonenumbers::AsYouTypeFormatter; |
Philippe Liard | 33a02e4 | 2011-08-17 10:14:24 +0000 | [diff] [blame] | 50 | using i18n::phonenumbers::PhoneNumberUtil; |
Philippe Liard | 4bffe68 | 2011-09-14 10:42:59 +0000 | [diff] [blame] | 51 | |
Philippe Liard | 33a02e4 | 2011-08-17 10:14:24 +0000 | [diff] [blame] | 52 | int main() { |
| 53 | PhoneNumberUtil* const phone_util = PhoneNumberUtil::GetInstance(); |
Philippe Liard | 4bffe68 | 2011-09-14 10:42:59 +0000 | [diff] [blame] | 54 | const scoped_ptr<AsYouTypeFormatter> asytf( |
| 55 | phone_util->GetAsYouTypeFormatter("US")); |
Philippe Liard | 7b30af6 | 2011-09-21 17:43:54 +0000 | [diff] [blame] | 56 | |
| 57 | assert(phone_util != NULL); |
| 58 | assert(asytf != NULL); |
Philippe Liard | 33a02e4 | 2011-08-17 10:14:24 +0000 | [diff] [blame] | 59 | }' |
Philippe Liard | 7b30af6 | 2011-09-21 17:43:54 +0000 | [diff] [blame] | 60 | |
Philippe Liard | 33a02e4 | 2011-08-17 10:14:24 +0000 | [diff] [blame] | 61 | # Run the build and tests. |
Philippe Liard | bee8be5 | 2011-07-06 12:15:51 +0000 | [diff] [blame] | 62 | ( |
Philippe Liard | 62c4580 | 2012-05-09 11:09:53 +0000 | [diff] [blame] | 63 | set +e |
| 64 | rm -rf cpp/build /tmp/libphonenumber |
| 65 | mkdir cpp/build /tmp/libphonenumber |
| 66 | cd cpp/build |
| 67 | cmake "${CMAKE_FLAGS}" -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX .. |
| 68 | make test |
| 69 | make install |
| 70 | $CXX -o $CC_TEST_BINARY $CC_TEST_FILE -I${INSTALL_PREFIX}/include $LD_FLAGS |
| 71 | LD_LIBRARY_PATH="${INSTALL_PREFIX}/lib" $CC_TEST_BINARY |
Philippe Liard | 33a02e4 | 2011-08-17 10:14:24 +0000 | [diff] [blame] | 72 | ) |
| 73 | STATUS=$? |
| 74 | # Remove the temporary files. |
| 75 | rm -f $CC_TEST_FILE |
| 76 | rm -f $CC_TEST_BINARY |
| 77 | |
| 78 | [ $STATUS -ne 0 ] && exit $STATUS |
Philippe Liard | bee8be5 | 2011-07-06 12:15:51 +0000 | [diff] [blame] | 79 | } |
Philippe Liard | 62c4580 | 2012-05-09 11:09:53 +0000 | [diff] [blame] | 80 | |
| 81 | BASE_LIBS='-licuuc -lprotobuf' |
| 82 | |
| 83 | test_cpp_version '' "$BASE_LIBS" |
| 84 | test_cpp_version '-DUSE_ICU_REGEXP=ON' "$BASE_LIBS" |
| 85 | test_cpp_version '-DUSE_LITE_METADATA=ON' '-licuuc -lprotobuf-lite' |
| 86 | test_cpp_version '-DUSE_RE2=ON' "$BASE_LIBS -lre2" |
| 87 | test_cpp_version '-DUSE_STD_MAP=ON' "$BASE_LIBS" |
Philippe Liard | bee8be5 | 2011-07-06 12:15:51 +0000 | [diff] [blame] | 88 | |
| 89 | # Test Java version using Ant. |
Philippe Liard | aa58387 | 2011-11-22 15:43:10 +0000 | [diff] [blame] | 90 | (cd java && ant clean jar && ant junit) || exit $? |
Philippe Liard | bee8be5 | 2011-07-06 12:15:51 +0000 | [diff] [blame] | 91 | |
| 92 | # Test Java version using Maven. |
Philippe Liard | aa58387 | 2011-11-22 15:43:10 +0000 | [diff] [blame] | 93 | (cd java && mvn clean package) || exit $? |
Philippe Liard | bee8be5 | 2011-07-06 12:15:51 +0000 | [diff] [blame] | 94 | |
| 95 | # Test build tools. |
| 96 | (cd tools/java && mvn clean package) || exit $? |