master the use of docker. maybe

This commit is contained in:
ThePhD 2017-12-31 21:15:43 -05:00
parent 41c297b9ab
commit 962ff6cf61
9 changed files with 267 additions and 140 deletions

91
.dockerignore Normal file
View File

@ -0,0 +1,91 @@
# Python (Bytecode)
*.pyc
# ninja files
*.ninja
# Visual Studio
*.props
*.user
.vs/
Debug/
Release/
x64/
x86/
*.pyproj
*.vcxproj
*.vcxproj.filters
*.tlog
*.lastbuildstate
*.idb
*.sln
*.gitattributes
# VSCode
.vscode/
# CMake
build/
build-sol2/
CMakeCache.txt
CMakeFiles/
# Compiler outputs
obj/*
bin/*
main.exe
main.o
lua53.dll
lua-5.3.4.dll
main.ilk
main.pdb
# Dropbox interference
.dropbox*
# QtCreator
*.creator.user.*
*.config
*.creator
*.files
*.includes
# Scratchpad Files
m.lua
catch_mock.hpp
main_aux.cpp
main.hpp
main2.cpp
main.cpp
# Local Lua Testbeds
lua-5.3.4-cxx/
lua-5.3.4/
lua-5.3.2/
lua-5.3.1/
lua-5.3.0/
lua-5.2.4/
lua-5.2.2/
lua-5.2.3/
lua-5.1.5/
LuaJIT-2.1.0/
luajit-2.0.5/
luajit-2.0.3/
include/
liblua.a
lib/liblua5.2.a
# Docs Artefacts
docs/build/
# Sublime Text
*.sublime-workspace
*.sublime-project
# Windows Crap
desktop.ini
*.db
# Miscellaneous
external/

54
.gitignore vendored
View File

@ -11,6 +11,8 @@
Debug/
Release/
x64/
x86/
*.pyproj
*.vcxproj
*.vcxproj.filters
*.tlog
@ -24,12 +26,19 @@ x64/
# CMake
build/
build-sol2/
CMakeCache.txt
CMakeFiles/
# Compiler outputs
obj/*
bin/*
main.exe
main.o
lua53.dll
lua-5.3.4.dll
main.ilk
main.pdb
# Dropbox interference
.dropbox*
@ -42,10 +51,17 @@ bin/*
*.includes
# Scratchpad Files
m.lua
main.lua
catch_mock.hpp
main_aux.cpp
main.hpp
main2.cpp
main.cpp
# Local Lua Testbeds
lua-5.3.4-cxx/
lua-5.3.4/
lua-5.3.2/
lua-5.3.1/
lua-5.3.0/
@ -53,40 +69,24 @@ lua-5.2.4/
lua-5.2.2/
lua-5.2.3/
lua-5.1.5/
LuaJIT-2.1.0/
luajit-2.0.5/
luajit-2.0.3/
include/
liblua.a
lib/liblua5.2.a
# Docs Artefacts
docs/build/
# Sublime Text
*.sublime-workspace
*.sublime-project
# Windows Crap
desktop.ini
*.sublime-workspace
docs/build/
*.sublime-project
m.lua
single/sol.hpp
*.db
lua53.dll
main.exe
main.o
lua-5.3.4/
main.lua
LuaJIT-2.1.0/
lua-5.3.4-cxx/
lua-5.3.4.vcxproj-cxx.filters
sol.pyproj
lua-5.3.4.dll
main.ilk
main.pdb
lua-5.3.4-cxx/
lua-5.3.4/
temp.bad_runtime.lua
temp.bad_syntax.lua
temp.good.lua
catch_mock.hpp
main_aux.cpp
main.hpp
tmp_thingy_user.lua
tmp_thingy.lua
# Miscellaneous
external/

View File

@ -23,48 +23,61 @@
sudo: required
language: cpp
git:
depth: 5
services:
- docker
before_install:
- sudo apt install -y git zsh
- sudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
- sudo chmod +x /usr/local/bin/docker-compose
- sudo usermod -aG docker ${USER}
- sudo docker-compose --version
- sudo apt install -y git
script:
- sudo docker-compose build
- sudo docker-compose run -e "LUA_VERSION=$LUA_VERSION" -e "LLVM_VERSION=$LLVM_VERSION" -e "GCC_VERSION=$GCC_VERSION" test
- 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 rm $(sudo docker ps -a -q)
- sudo docker rmi $(sudo docker image ls -q)
env:
# GCC 4.9.x, 5.x, 6.x, 7.x
- 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 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

View File

@ -199,19 +199,23 @@ if (TESTS OR TESTS_SINGLE OR EXAMPLES OR TESTS_EXAMPLES)
endif()
find_package(Threads)
# Find way to get Lua: build if requested, or attempt to build if no matching version is found
string(TOLOWER ${LUA_VERSION} NORMALIZED_LUA_VERSION)
if (BUILD_LUA OR BUILD_LUAJIT)
include(LuaBuild)
elseif (NORMALIZED_LUA_VERSION MATCHES "5.1")
find_package(Lua 5.1 EXACT REQUIRED)
elseif(NORMALIZED_LUA_VERSION MATCHES "5.2")
find_package(Lua 5.2 EXACT REQUIRED)
elseif(NORMALIZED_LUA_VERSION MATCHES "5.3")
find_package(Lua 5.3 EXACT REQUIRED)
elseif(NORMALIZED_LUA_VERSION MATCHES "luajit")
find_package(LuaJIT REQUIRED)
elseif (NOT LUA_VERSION)
# can't do anything
else()
include(LuaBuild)
string(TOLOWER ${LUA_VERSION} NORMALIZED_LUA_VERSION)
if (NORMALIZED_LUA_VERSION MATCHES "5.1")
find_package(Lua 5.1 EXACT REQUIRED)
elseif(NORMALIZED_LUA_VERSION MATCHES "5.2")
find_package(Lua 5.2 EXACT REQUIRED)
elseif(NORMALIZED_LUA_VERSION MATCHES "5.3")
find_package(Lua 5.3 EXACT REQUIRED)
elseif(NORMALIZED_LUA_VERSION MATCHES "luajit")
find_package(LuaJIT REQUIRED)
else()
include(LuaBuild)
endif()
endif()
if (NOT LUA_FOUND)

View File

@ -22,25 +22,31 @@
# Start from the ubuntu:xenial image
FROM ubuntu:xenial
# Everything from our current directory (repo toplevel in travis-ci)
# should be copied into our container at the top-level sol2 directory
ADD . /sol2
#VOLUME /sol2
# 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}
# 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 update
RUN apt -y install sudo zsh
RUN apt -y dist-upgrade
RUN mkdir -p build-sol2/Debug build-sol2/Release
RUN chmod +x /sol2/scripts/preparation.linux.sh
RUN ["/usr/bin/env", "zsh", "-c", "-x", "./sol2/scripts/preparation.linux.sh"]
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"]
# 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
CMD ["/usr/bin/env", "zsh", "-c", "-x", "chmod +x /sol2/scripts/run.linux.sh && ./sol2/scripts/run.linux.sh"]
ENTRYPOINT ["/usr/bin/env", "zsh", "-x", "-e", "/sol2/scripts/run.linux.sh"]

View File

@ -304,6 +304,9 @@ target_compile_definitions(${liblua}
if (MSVC)
target_compile_options(${liblua}
PRIVATE /W1)
else()
target_compile_options(${liblua}
PRIVATE -w -Wno-implicit-fallthrough)
endif()
if (WIN32)
#target_compile_definitions(${liblua}

View File

@ -1,33 +1,30 @@
# # # # 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.
version: "3"
services:
test:
build: .
volumes:
- .:/sol2
environment:
- LUA_VERSION
- GCC_VERSION
- LLVM_VERSION
#!/usr/bin/env bash
# # # # 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.
export LLVM_ARCHIVE_PATH=~/clang+llvm.tar.xz
export CLANG_PREFIX=$HOME/clang-$LLVM_VERSION
export PATH=$LLVM_ARCHIVE_PATH:$PATH
export LD_LIBRARY_PATH=$CLANG_PREFIX/lib:$LD_LIBRARY_PATH
export CPPFLAGS="-I $CLANG_PREFIX/include/c++/v1"
export CXXFLAGS=-lc++

View File

@ -23,29 +23,7 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# # Initial and necessary installations
sudo apt -y install build-essential zsh ninja-build libreadline6 libreadline6-dev python3 zsh wget curl libcurl3 openssl libexpat1 libexpat1-dev cmake git
# # CMake Installation (from script)
# This is only necessary if we need cmake of a better version than what's available on the system
#CMAKE_VERSION_MAJOR_MINOR=3.10
#CMAKE_VERSION_BUILD=1
#CMAKE_VERSION=$CMAKE_VERSION_MAJOR_MINOR.$CMAKE_VERSION_BUILD
#wget https://cmake.org/files/v$CMAKE_VERSION_MAJOR_MINOR/cmake-$CMAKE_VERSION-Linux-x86_64.sh
#sudo bash cmake-$CMAKE_VERSION-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir --skip-license
# # CMake Installation (from source)
#mkdir -p cmake-tmp
#cd cmake-tmp
#wget https://cmake.org/files/v$CMAKE_VERSION_MAJOR_MINOR/cmake-$CMAKE_VERSION.tar.gz
#tar -xzvf cmake-$CMAKE_VERSION.tar.gz
#cd cmake-$CMAKE_VERSION/
#./bootstrap --system-libs
#make
#sudo make install
# cd ..
# refresh the shell, then print the CMake version to make
# sure we've got what we need (need to be 3.6 or better: Ubuntu 16.04 rolls 3.5.1 or somethnig)
#exec bash
sudo apt-get -y install ninja-build libreadline6 libreadline6-dev python3 wget curl libcurl3 cmake git
# # LLVM and GCC updates
# Grab LLVM or GCC
@ -54,31 +32,26 @@ sudo apt -y install build-essential zsh ninja-build libreadline6 libreadline6-de
if [ "$LLVM_VERSION" ]
then
# get and use LLVM
echo "========== detected LLVM_VERSION, attempting to install llvm version $LLVM_VERSION =========="
wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-16.04.tar.xz -O $LLVM_ARCHIVE_PATH
mkdir ~/clang-$LLVM_VERSION
tar xf $LLVM_ARCHIVE_PATH -C $HOME/clang-$LLVM_VERSION --strip-components 1
export PATH=~/clang+llvm/bin:$PATH
source /sol2/scripts/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
mkdir -p $CLANG_PREFIX
tar xf $LLVM_ARCHIVE_PATH -C $CLANG_PREFIX --strip-components 1
elif [ "$GCC_VERSION" ]
then
# get and use GCC version that we desire
echo "========== detected GCC_VERSION, attempting to install gcc version $GCC_VERSION =========="
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt update
sudo apt dist-upgrade
sudo apt install gcc-$GCC_VERSION g++-$GCC_VERSION
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
export CC=gcc
export CXX=g++
export CC=gcc-$GCC_VERSION
export CXX=g++-$GCC_VERSION
else
export CC=gcc
export CXX=g++
sudo apt-get -y install build-essential
export CC=cc
export CXX=c++
fi
# show the tool and compiler versions we're using
cmake --version
$CC --version
$CXX --version

View File

@ -1,22 +1,62 @@
#!/usr/bin/env bash
# # # # 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.
# This script runs the actual project
if [ "$LLVM_VERSION" ]
then
build_type=-DCMAKE_CXX_COMPILER\=clang++ -DCMAKE_C_COMPILER\=clang;
source /sol2/scripts/preparation.linux.llvm.sh
export CC=clang
export CXX=clang++
elif [ "$GCC_VERSION" ]
then
build_type=-DCMAKE_CXX_COMPILER\=g++ -DCMAKE_C_COMPILER\=gcc;
export CC=gcc-$GCC_VERSION
export CXX=g++-$GCC_VERSION
else
build_type=-DCMAKE_CXX_COMPILER\=g++ -DCMAKE_C_COMPILER\=gcc;
export CC=cc
export CXX=c++
fi
export build_type_cxx=-DCMAKE_CXX_COMPILER\=${CXX}
export build_type_cc=-DCMAKE_C_COMPILER\=${CC}
cd build-sol2
cd Debug
cmake ../../sol2 -G Ninja -DCMAKE_BUILD_TYPE=Debug $build_type -DLUA_VERSION="${LUA_VERSION}" -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DTESTS_SINGLE=ON
# show the tool and compiler versions we're using
cmake --version
$CC --version
$CXX --version
echo build_type_cc : "${build_type_cc}"
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
cmake --build . --config Debug
ctest -C Debug
cd ..
cd ${top_level}
cd Release
cmake ../../sol2 -G Ninja -DCMAKE_BUILD_TYPE=Release $build_type -DLUA_VERSION="${LUA_VERSION}" -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DTESTS_SINGLE=ON
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
cmake --build . --config Release
ctest -C Release
cd ..
cd ${top_level}