[ci skip] Prepare travis and docker for pulling images: just need to build images...

This commit is contained in:
ThePhD 2018-01-07 10:28:05 -05:00
parent 1b94182c8d
commit 44e87cedda
7 changed files with 161 additions and 166 deletions

View File

@ -24,7 +24,7 @@ sudo: required
language: cpp
git:
depth: 5
depth: 2
services:
- docker
@ -33,8 +33,8 @@ before_install:
- sudo apt install -y git
script:
- sudo docker image build --tag sol2:ci --build-arg "CI=${CI}" --build-arg "LUA_VERSION=${LUA_VERSION}" --build-arg "GCC_VERSION=${GCC_VERSION}" --build-arg "LLVM_VERSION=${LLVM_VERSION}" .
- sudo docker run --name "sol2.test" --tty --env "CI=${CI}" --env "LUA_VERSION=${LUA_VERSION}" --env "GCC_VERSION=${GCC_VERSION}" --env "LLVM_VERSION=${LLVM_VERSION}" sol2:ci
- sudo docker image pull ThePhD/sol2:gcc-${GCC_VERSION}_llvm-${LLVM_VERSION}
- sudo docker run --rm --name "sol2.test" --tty --env "CI=${CI}" --env "LUA_VERSION=${LUA_VERSION}" --env "GCC_VERSION=${GCC_VERSION}" --env "LLVM_VERSION=${LLVM_VERSION}" sol2:gcc-${GCC_VERSION}_llvm-${LLVM_VERSION}
- sudo docker rm $(sudo docker ps -a -q)
- sudo docker rmi $(sudo docker image ls -q)
@ -43,45 +43,62 @@ env:
- LUA_VERSION=5.3.4
GCC_VERSION=4.9
CI=true
- LUA_VERSION=5.3.4
GCC_VERSION=5
CI=true
- LUA_VERSION=5.3.4
GCC_VERSION=6
CI=true
- LUA_VERSION=5.3.4
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
ALLOW_FAILURE=true
- LUA_VERSION=5.3.4
LLVM_VERSION=3.7.1
CI=true
ALLOW_FAILURE=true
- LUA_VERSION=5.3.4
LLVM_VERSION=3.8.1
CI=true
ALLOW_FAILURE=true
- LUA_VERSION=5.3.4
LLVM_VERSION=3.9.0
CI=true
ALLOW_FAILURE=true
- LUA_VERSION=5.3.4
LLVM_VERSION=4.0.1
CI=true
ALLOW_FAILURE=true
- LUA_VERSION=5.3.4
LLVM_VERSION=5.0.1
CI=true
ALLOW_FAILURE=true
# Lua Versions 5.2.4, 5.1.5, and maybe LuaJIT (as well as x86)
- LUA_VERSION=5.2.4
GCC_VERSION=7
CI=true
- LUA_VERSION=5.1.5
GCC_VERSION=7
CI=true
matrix:
fast_finish: true
allow_failures:
- env: ALLOW_FAILURE=true
notifications:
webhooks:

View File

@ -22,31 +22,44 @@
# Start from the ubuntu:xenial image
FROM ubuntu:xenial
# We want our working directory to be the toplevel
WORKDIR /
# Everything from our current directory (repo toplevel in travis-ci)
# should be copied into our container at the top-level sol2 directory
ADD . sol2
ARG CI=true
ARG LUA_VERSION=5.3.4
ARG GCC_VERSION
ARG LLVM_VERSION
#VOLUME /sol2
# Potential environment variables
ENV LUA_VERSION=${LUA_VERSION} GCC_VERSION=${GCC_VERSION} LLVM_VERSION=${LLVM_VERSION} CI=${CI}
# owner
LABEL maintainer="phdofthehouse@gmail.com"
# We want our working directory to be the home directory
WORKDIR /root
# RUN is how you write to the image you've pulled down
# RUN actions are "committed" to the image, and everything will
# start from the base after all run commands are executed
RUN apt-get update
RUN apt-get -y install sudo zsh
RUN apt-get -y dist-upgrade
RUN mkdir -p /build-sol2/Debug /build-sol2/Release
RUN chmod +x /sol2/scripts/preparation.linux.sh /sol2/scripts/run.linux.sh
RUN ["/usr/bin/env", "zsh", "-e", "/sol2/scripts/preparation.linux.sh"]
RUN apt-get update && apt-get install -y \
zsh
# Scripts should be added directly to the docker image to get us started
# We can mount the whole sol2 directory later as a volume
ADD scripts/ /root/sol2-scripts
RUN mkdir -p /root/build-sol2/Debug /root/build-sol2/Release
RUN chmod +x /root/sol2-scripts/preparation.linux.sh /root/sol2-scripts/run.linux.sh
VOLUME /root/sol2
#ADD . /root/sol2
# # Above this is more or less static parts: the rest is non-static
# # This is ordered like this so making multiple of these
# # containers is more or less identical up to this point
# Command line arguments, with default values
ARG CI=true
ARG GCC_VERSION=7
ARG LLVM_VERSION
# Potential environment variables
ENV GCC_VERSION=${GCC_VERSION} LLVM_VERSION=${LLVM_VERSION} CI=${CI} SOL2_DIR=/root/sol2
RUN ["/usr/bin/env", "zsh", "-e", "/root/sol2-scripts/preparation.linux.sh"]
# CMD/ENTRYPOINT is different from RUN
# these are done on a per-instantiation and essentially describe
# the DEFAULT behavior of this container when its started, not what state it
# gets "saved" in...
# it only runs the last CMD/ENTRYPOINT as the default behavior:
# multiple CMDs will not be respected
ENTRYPOINT ["/usr/bin/env", "zsh", "-x", "-e", "/sol2/scripts/run.linux.sh"]
ENTRYPOINT ["/usr/bin/env", "zsh", "-x", "-e", "/root/sol2-scripts/run.linux.sh"]

View File

@ -1,29 +0,0 @@
#!/usr/bin/env zsh
# # # # sol2
# The MIT License (MIT)
#
# Copyright (c) 2013-2017 Rapptz, ThePhD, and contributors
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# 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.
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

View File

@ -22,82 +22,92 @@
# 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}/.."
top_level_dir="$(pwd)"
mkdir -p build-sol2
cd build-sol2
top_level_dir="$(pwd)"
build_dir="$(pwd)"
echo "#\!/usr/bin/env zsh\n\n" > "sol2.compiler.vars"
# # Initial and necessary installations
sudo apt-get -y install ninja-build libreadline6 libreadline6-dev python3 wget curl libcurl3 cmake git
apt-get -y install ninja-build libreadline6 libreadline6-dev python3 wget curl libcurl3 cmake git
# # LLVM and GCC updates
# Grab LLVM or GCC
# if we need it
# defining both is probably an expotentially terrible idea
if [ "$LLVM_VERSION" ]
if [ "${LLVM_VERSION}" ]
then
# get and use LLVM
source ${scripts_dir}/preparation.linux.llvm.sh
export CC=clang
export CXX=clang++
version_nums=(${=LLVM_VERSION//./ })
major=$version_nums[1]
minor=$version_nums[2]
revision=$version_nums[3]
download_llvm=true
download_version=16.04
#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 ];
if [ $major -le 3 ]
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
if [ $minor -le 8 ] && [ $minor -ge 5 ];
then
download_llvm=false
download_version=16.04
apt-get -y install clang-3.${minor}
export CC=clang-3.${minor}
export CXX=clang++-3.${minor}
elif [ $minor -le 4 ]
then
download_llvm=true
download_version=14.04
fi
fi
mkdir -p $CLANG_PREFIX
tar xf "$LLVM_ARCHIVE_PATH" -C "$CLANG_PREFIX" --strip-components 1
elif [ "$GCC_VERSION" ]
if [ ${download_llvm} = true ]
then
export LLVM_ARCHIVE_PATH=${build_dir}/clang+llvm.tar.xz
export CLANG_PREFIX=${build_dir}/clang-$LLVM_VERSION
export PATH=$CLANG_PREFIX/bin:$PATH
export LD_LIBRARY_PATH=$CLANG_PREFIX/lib:$LD_LIBRARY_PATH
echo "export LLVM_ARCHIVE_PATH=${build_dir}/clang+llvm.tar.xz\nexport CLANG_PREFIX=${build_dir}/clang-$LLVM_VERSION\nexport PATH=$CLANG_PREFIX/bin:$PATH\nexport LD_LIBRARY_PATH=$CLANG_PREFIX/lib:$LD_LIBRARY_PATH\n" >> "sol2.compiler.vars"
apt-get -y install xz-utils clang
wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-${download_version}.tar.xz -O ${LLVM_ARCHIVE_PATH}
mkdir -p "${CLANG_PREFIX}"
tar xf "${LLVM_ARCHIVE_PATH}" -C "${CLANG_PREFIX}" --strip-components 1
# make sure a clang(++) of major/minor exists
# use || true to ignore potential failures
ln -s "clang-${major}.${minor}" "${CLANG_PREFIX}/bin/clang-${major}.${minor}" || true
ln -s "clang-${major}.${minor}" "${CLANG_PREFIX}/bin/clang++-${major}.${minor}" || true
export CC=clang-${major}.${minor}
export CXX=clang++-${major}.${minor}
fi
elif [ "${GCC_VERSION}" ]
then
# get and use GCC version that we desire
sudo apt-get -y install software-properties-common python-software-properties
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get -y update
sudo apt-get -y dist-upgrade
sudo apt-get -y install gcc-$GCC_VERSION g++-$GCC_VERSION
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 60 --slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION
sudo update-alternatives --config gcc
apt-get -y install software-properties-common python-software-properties
add-apt-repository -y ppa:ubuntu-toolchain-r/test
apt-get -y update
apt-get -y dist-upgrade
apt-get -y install gcc-$GCC_VERSION g++-$GCC_VERSION
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 60 --slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION
update-alternatives --config gcc
export CC=gcc-$GCC_VERSION
export CXX=g++-$GCC_VERSION
else
sudo apt-get -y install build-essential
apt-get -y install build-essential
export CC=cc
export CXX=c++
fi
cd ..
# show the tool and compiler versions we're using
echo "=== Compiler and tool variables ==="
ninja --version
cmake --version
$CC --version
$CXX --version
echo "export CC=$CC\nexport CXX=$CXX\n" >> "sol2.compiler.vars"
cd "${top_level_dir}"

View File

@ -22,71 +22,55 @@
# 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'`" ]
if [ -z "${SOL2_DIR}"]
then
if [ ${CI} = true ]
then
SOURCE="${(%):-%x}"
elif [ -n "`$SHELL -c 'echo $BASH_VERSION'`" ]
then
SOURCE="${BASH_SOURCE[0]}"
export SOL2_DIR=~/sol2
else
SOURCE="${0}"
export SOL2_DIR=../..
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"
}
fi
scripts_dir="$(get_script_dir)"
sol2_dir="${scripts_dir}/.."
if [ -z "${LUA_VERSION}"]
then
export LUA_VERSION=5.3.4
fi
mkdir -p build-sol2
cd build-sol2
build_dir=$(pwd)
if [ -f "sol2.compiler.vars" ]
then
source ./sol2.compiler.vars
fi
# This script runs the actual project
mkdir -p Debug Release
if [ "$LLVM_VERSION" ]
then
source ${scripts_dir}/preparation.linux.llvm.sh
export CC=clang
export CXX=clang++
elif [ "$GCC_VERSION" ]
then
export CC=gcc-$GCC_VERSION
export CXX=g++-$GCC_VERSION
else
export CC=cc
export CXX=c++
fi
export build_type_cxx=-DCMAKE_CXX_COMPILER\=${CXX}
export build_type_cc=-DCMAKE_C_COMPILER\=${CC}
export build_type_cxx=-DCMAKE_CXX_COMPILER\=${CXX}
# show the tool and compiler versions we're using
echo "=== Compiler and tool variables ==="
ninja --version
cmake --version
$CC --version
$CXX --version
${CC} --version
${CXX} --version
echo build_type_cc : "${build_type_cc}"
echo build_type_cxx: "${build_type_cxx}"
top_level=${PWD}
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 ${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}
ctest --build-config Debug --output-on-failure
cd ..
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 ${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}
ctest --build-config Release --output-on-failure
cd ..

View File

@ -85,7 +85,7 @@ namespace sol {
template <typename... Args, typename... Ret>
static std::function<Signature> get_std_func(types<Ret...>, types<Args...>, lua_State* L, int index) {
unsafe_function f(L, index);
auto fx = [ f = std::move(f), L, index ](Args && ... args) -> meta::return_type_t<Ret...> {
auto fx = [ f = std::move(f) ](Args && ... args) -> meta::return_type_t<Ret...> {
return f.call<Ret...>(std::forward<Args>(args)...);
};
return std::move(fx);

View File

@ -440,7 +440,7 @@ TEST_CASE("tables/function variables", "Check if tables and function calls work
int breakit = 50;
lua.get<sol::table>("os").set_function("fun",
[&breakit]() {
INFO("stateful lambda()");
INFO("stateful lambda() with breakit:" << breakit);
return "test";
});
REQUIRE_NOTHROW(run_script(lua));