diff --git a/.travis.yml b/.travis.yml index 2c4c0195..3166f1ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,24 +53,24 @@ env: GCC_VERSION=7 CI=true # LLVM 3.6.x -> 5.0.x - - LUA_VERSION=5.3.4 - LLVM_VERSION=3.6.2 - CI=true - - LUA_VERSION=5.3.4 - LLVM_VERSION=3.7.1 - CI=true - - LUA_VERSION=5.3.4 - LLVM_VERSION=3.8.1 - CI=true - - LUA_VERSION=5.3.4 - LLVM_VERSION=3.9.0 - CI=true - - LUA_VERSION=5.3.4 - LLVM_VERSION=4.0.1 - CI=true - - LUA_VERSION=5.3.4 - LLVM_VERSION=5.0.1 - CI=true + #- LUA_VERSION=5.3.4 + # LLVM_VERSION=3.6.2 + # CI=true + #- LUA_VERSION=5.3.4 + # LLVM_VERSION=3.7.1 + # CI=true + #- LUA_VERSION=5.3.4 + # LLVM_VERSION=3.8.1 + # CI=true + #- LUA_VERSION=5.3.4 + # LLVM_VERSION=3.9.0 + # CI=true + #- LUA_VERSION=5.3.4 + # LLVM_VERSION=4.0.1 + # CI=true + #- LUA_VERSION=5.3.4 + # LLVM_VERSION=5.0.1 + # CI=true # Lua Versions 5.2.4, 5.1.5, and maybe LuaJIT (as well as x86) - LUA_VERSION=5.2.4 GCC_VERSION=7 diff --git a/CMakeLists.txt b/CMakeLists.txt index e71c1f02..e71baea1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,13 @@ else() add_compile_options(-Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) endif() +if (CI) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + include_directories("$ENV{CLANG_PREFIX}/include/c++/v1") + #add_compile_options(-lc++) + endif() +endif() + # # # General project output locations if (CMAKE_SIZEOF_VOID_P EQUAL 4) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/x86/lib") diff --git a/scripts/preparation.linux.llvm.sh b/scripts/preparation.linux.llvm.sh index 3b7924e5..54134635 100644 --- a/scripts/preparation.linux.llvm.sh +++ b/scripts/preparation.linux.llvm.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env zsh # # # # sol2 # The MIT License (MIT) @@ -22,9 +22,8 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -export LLVM_ARCHIVE_PATH=~/clang+llvm.tar.xz -export CLANG_PREFIX=$HOME/clang-$LLVM_VERSION -export PATH=$LLVM_ARCHIVE_PATH:$PATH +top_level_dir="$(pwd)" +export LLVM_ARCHIVE_PATH=${top_level_dir}/clang+llvm.tar.xz +export CLANG_PREFIX=${top_level_dir}/clang-$LLVM_VERSION +export PATH=$CLANG_PREFIX/bin:$PATH export LD_LIBRARY_PATH=$CLANG_PREFIX/lib:$LD_LIBRARY_PATH -export CPPFLAGS="-I $CLANG_PREFIX/include/c++/v1" -export CXXFLAGS=-lc++ diff --git a/scripts/preparation.linux.sh b/scripts/preparation.linux.sh index ce3bfb8c..323b463d 100644 --- a/scripts/preparation.linux.sh +++ b/scripts/preparation.linux.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env zsh # # # # sol2 # The MIT License (MIT) @@ -22,6 +22,36 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within +get_script_dir () { + if [ -n "`$SHELL -c 'echo $ZSH_VERSION'`" ] + then + SOURCE="${(%):-%x}" + elif [ -n "`$SHELL -c 'echo $BASH_VERSION'`" ] + then + SOURCE="${BASH_SOURCE[0]}" + else + SOURCE="${0}" + fi + # While $SOURCE is a symlink, resolve it + while [ -h "$SOURCE" ]; do + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$( readlink "$SOURCE" )" + # If $SOURCE was a relative symlink (so no "/" as prefix, need to resolve it relative to the symlink base directory + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" + done + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + echo "$DIR" +} + +scripts_dir="$(get_script_dir)" +sol2_dir="${scripts_dir}/.." + +mkdir -p build-sol2 +cd build-sol2 + +top_level_dir="$(pwd)" + # # Initial and necessary installations sudo apt-get -y install ninja-build libreadline6 libreadline6-dev python3 wget curl libcurl3 cmake git @@ -32,12 +62,26 @@ sudo apt-get -y install ninja-build libreadline6 libreadline6-dev python3 wget c if [ "$LLVM_VERSION" ] then # get and use LLVM - source /sol2/scripts/preparation.linux.llvm.sh + source ${scripts_dir}/preparation.linux.llvm.sh export CC=clang export CXX=clang++ - wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-16.04.tar.xz -O $LLVM_ARCHIVE_PATH + version_nums=(${=LLVM_VERSION//./ }) + major=$version_nums[1] + minor=$version_nums[2] + revision=$version_nums[3] + #sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + #sudo apt-get -y update + sudo apt-get -y install xz-utils + if [ $major -lt 4 ] && [ $minor -lt 8 ]; + then + sudo apt-get -y install libstdc++6 + wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-14.04.tar.xz -O $LLVM_ARCHIVE_PATH + else + sudo apt-get -y install clang clang++ + wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-16.04.tar.xz -O $LLVM_ARCHIVE_PATH + fi mkdir -p $CLANG_PREFIX - tar xf $LLVM_ARCHIVE_PATH -C $CLANG_PREFIX --strip-components 1 + tar xf "$LLVM_ARCHIVE_PATH" -C "$CLANG_PREFIX" --strip-components 1 elif [ "$GCC_VERSION" ] then # get and use GCC version that we desire @@ -55,3 +99,5 @@ else export CC=cc export CXX=c++ fi + +cd .. diff --git a/scripts/preparation.osx.sh b/scripts/preparation.osx.sh index ca3e5519..a8391f5a 100644 --- a/scripts/preparation.osx.sh +++ b/scripts/preparation.osx.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env zsh # # # # sol2 # The MIT License (MIT) diff --git a/scripts/run.linux.sh b/scripts/run.linux.sh index 08830230..817460c3 100644 --- a/scripts/run.linux.sh +++ b/scripts/run.linux.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env zsh # # # # sol2 # The MIT License (MIT) @@ -22,11 +22,41 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# Things we need +# https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within +get_script_dir () { + if [ -n "`$SHELL -c 'echo $ZSH_VERSION'`" ] + then + SOURCE="${(%):-%x}" + elif [ -n "`$SHELL -c 'echo $BASH_VERSION'`" ] + then + SOURCE="${BASH_SOURCE[0]}" + else + SOURCE="${0}" + fi + # While $SOURCE is a symlink, resolve it + while [ -h "$SOURCE" ]; do + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$( readlink "$SOURCE" )" + # If $SOURCE was a relative symlink (so no "/" as prefix, need to resolve it relative to the symlink base directory + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" + done + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + echo "$DIR" +} + +scripts_dir="$(get_script_dir)" +sol2_dir="${scripts_dir}/.." + +mkdir -p build-sol2 +cd build-sol2 + # This script runs the actual project +mkdir -p Debug Release if [ "$LLVM_VERSION" ] then - source /sol2/scripts/preparation.linux.llvm.sh + source ${scripts_dir}/preparation.linux.llvm.sh export CC=clang export CXX=clang++ elif [ "$GCC_VERSION" ] @@ -49,14 +79,14 @@ echo build_type_cxx: "${build_type_cxx}" top_level=${PWD} -cd /build-sol2/Debug -cmake ../../sol2 -G Ninja -DCMAKE_BUILD_TYPE=Debug ${build_type_cc} ${build_type_cxx} -DLUA_VERSION="${LUA_VERSION}" -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DTESTS_SINGLE=ON -DCI=ON +cd Debug +cmake ${sol2_dir} -G Ninja -DCMAKE_BUILD_TYPE=Debug ${build_type_cc} ${build_type_cxx} -DLUA_VERSION="${LUA_VERSION}" -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DTESTS_SINGLE=ON -DCI=ON cmake --build . --config Debug ctest -C Debug cd ${top_level} -cd /build-sol2/Release -cmake ../../sol2 -G Ninja -DCMAKE_BUILD_TYPE=Release ${build_type_cc} ${build_type_cxx} -DLUA_VERSION="${LUA_VERSION}" -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DTESTS_SINGLE=ON -DCI=ON +cd Release +cmake ${sol2_dir} -G Ninja -DCMAKE_BUILD_TYPE=Release ${build_type_cc} ${build_type_cxx} -DLUA_VERSION="${LUA_VERSION}" -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DTESTS_SINGLE=ON -DCI=ON cmake --build . --config Release ctest -C Release cd ${top_level}