From 863939c2c51b6f5a14f264cf71b7809f58b34c8a Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Thu, 21 Jul 2016 22:51:13 +0100 Subject: [PATCH] Updates for LOOT's Travis CI integration * Build and use Boost 1.61.0 * Cache Node, Bower and Boost dependencies * Always link to static Boost libraries * Remove Travis's Boost ABI incompatibility hack --- .travis.yml | 26 +++++++++++++++----------- CMakeLists.txt | 9 +-------- docs/BUILD.LINUX.md | 8 -------- scripts/travis/install_boost.sh | 25 +++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 scripts/travis/install_boost.sh diff --git a/.travis.yml b/.travis.yml index 771ee1dd..17f45d04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,16 +8,10 @@ compiler: gcc addons: apt: sources: - - boost-latest - - ubuntu-toolchain-r-test - - kubuntu-backports + - ubuntu-toolchain-r-test # ppa:ubuntu-toolchain-r/test + - kubuntu-backports # ppa:kubuntu-ppa/backports packages: - - libboost-log1.55-dev - - libboost-date-time1.55-dev - - libboost-thread1.55-dev - - libboost-filesystem1.55-dev - - libboost-locale1.55-dev - - libboost-iostreams1.55-dev + - libbz2-dev - libssl-dev - gcc-5 - g++-5 @@ -25,6 +19,13 @@ addons: - cmake-data sauce_connect: true +cache: + directories: + - $TRAVIS_BUILD_DIR/node_modules + - $TRAVIS_BUILD_DIR/bower_components + - $HOME/boost_1_61_0/boost + - $HOME/boost_1_61_0/stage/lib + install: # Use GCC 5. - if [ "$CXX" = "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi @@ -38,15 +39,18 @@ install: - export PATH="./node_modules/.bin:$PATH" # Install runtime dependencies using Bower - bower install + - chmod +x scripts/travis/install_boost.sh + - scripts/travis/install_boost.sh before_script: # Move into the cloned LOOT repo build path. - mkdir build && cd build - # Travis machines are 64 bit, and the dependencies use dynamic linking. - - cmake .. -DPROJECT_STATIC_RUNTIME=OFF -DBUILD_SHARED_LIBS=OFF + # Link dynamically to the C++ standard library runtime. + - cmake .. -DPROJECT_STATIC_RUNTIME=OFF -DBOOST_ROOT=~/boost_1_61_0 script: - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm test; fi + - export CXXFLAGS="-fPIC" CFLAGS="-fPIC" - make tests && ./tests - make api-tests && ./api-tests diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eef875e..3df2be4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ configure_file("${CMAKE_SOURCE_DIR}/src/backend/app/loot_version.cpp.in" "${CMAK # External Projects ############################## -set (Boost_USE_STATIC_LIBS ${PROJECT_STATIC_RUNTIME}) +set (Boost_USE_STATIC_LIBS ON) set (Boost_USE_MULTITHREADED ON) set (Boost_USE_STATIC_RUNTIME ${PROJECT_STATIC_RUNTIME}) @@ -317,13 +317,6 @@ include_directories ("${CMAKE_SOURCE_DIR}/src" # System-Specific Settings ############################## -# If building on Travis, define BOOST_NO_CXX11_SCOPED_ENUMS to avoid -# boost::filesystem::copy_file() linking errors due to mismatched C++ runtimes -# between Boost and LOOT. -IF ($ENV{TRAVIS}) - add_definitions (-DBOOST_NO_CXX11_SCOPED_ENUMS) -ENDIF () - # Settings when compiling for Windows. IF (CMAKE_SYSTEM_NAME MATCHES "Windows") add_definitions (-DUNICODE -D_UNICODE -DLIBLO_STATIC) diff --git a/docs/BUILD.LINUX.md b/docs/BUILD.LINUX.md index fb749ba3..26d599d2 100644 --- a/docs/BUILD.LINUX.md +++ b/docs/BUILD.LINUX.md @@ -32,14 +32,6 @@ sudo apt-get update sudo apt-get install nodejs libx11-dev libgtk2.0-dev libnss3-dev libgconf2-dev libxss-dev libasound2-dev libxtst-dev ``` -## Pre-built Boost Packages Workaround - -The pre-built Boost packages for Boost 1.55 and below in Ubuntu were built without C++11 support, which causes an error when linking with a C++11-built LOOT binary. While it's better to use a build of Boost with C++11 support when building LOOT, the error can be worked around by running the following before running CMake: - -``` -export TRAVIS=1 -``` - ## Runtime Differences Not all LOOT's features have been implemented for Linux builds. Issues labelled diff --git a/scripts/travis/install_boost.sh b/scripts/travis/install_boost.sh new file mode 100644 index 00000000..27f8c59d --- /dev/null +++ b/scripts/travis/install_boost.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +BOOST_BASENAME=boost_1_61_0 +BOOST_LIBRARIES=(libboost_atomic.a libboost_chrono.a libboost_date_time.a libboost_filesystem.a libboost_iostreams.a libboost_locale.a libboost_log.a libboost_log_setup.a libboost_regex.a libboost_system.a libboost_thread.a) + +function isLibraryMissing { + for LIBRARY in $BOOST_LIBRARIES; do + if [[ ! -e ~/$BOOST_BASENAME/stage/lib/$LIBRARY ]]; then + return 0 + fi + done + + return 1 +} + +if isLibraryMissing; then + cd ~ + + wget http://downloads.sourceforge.net/project/boost/boost/1.61.0/${BOOST_BASENAME}.tar.bz2 + tar xf ${BOOST_BASENAME}.tar.bz2 + + cd $BOOST_BASENAME + ./bootstrap.sh + ./b2 toolset=gcc-5 link=static variant=release address-model=64 cxxflags="-std=c++14 -fPIC" boost.locale.icu=off --with-log --with-date_time --with-thread --with-filesystem --with-locale --with-regex --with-system --with-iostreams +fi