Travis build with MinGW

This commit is contained in:
Jean Pierre Cimalando 2020-02-02 14:43:39 +01:00
parent c06b0e37c7
commit d3b0cef35f
8 changed files with 72 additions and 9 deletions

View file

@ -5,6 +5,11 @@ env:
jobs:
include:
- os: linux
env:
- CROSS_COMPILE=mingw32
- CONTAINER=cross
- os: linux
arch: amd64
dist: bionic

View file

@ -1,9 +1,10 @@
#!/bin/bash
set -ex
. .travis/environment.sh
cd build
make install
buildenv make install
tar -zcvf "${INSTALL_DIR}.tar.gz" ${INSTALL_DIR}
mv "${INSTALL_DIR}.tar.gz" ${TRAVIS_BUILD_DIR}
cd ..

View file

@ -1,18 +1,31 @@
#!/bin/bash
set -ex
. .travis/environment.sh
cmake_dir="cmake-3.13.0-${TRAVIS_OS_NAME}-${TRAVIS_CPU_ARCH}"
cmake_arc="${cmake_dir}.tar.gz"
cmake_url="https://github.com/sfztools/cmake/releases/download/${TRAVIS_OS_NAME}/${cmake_arc}"
if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
if [[ ${CROSS_COMPILE} == "mingw32" ]]; then
buildenv bash -c "echo Hello from container" # ensure to start the container
docker cp "$container":/etc/pacman.conf pacman.conf
cat >>pacman.conf <<EOF
[multilib]
Include = /etc/pacman.d/mirrorlist
[mingw-w64]
SigLevel = Optional TrustAll
Server = https://github.com/jpcima/arch-mingw-w64/releases/download/repo.\$arch/
EOF
docker cp pacman.conf "$container":/etc/pacman.conf
rm -f pacman.conf
elif [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
wget -q ${cmake_url}
tar xzf ${cmake_arc}
cd ${TRAVIS_BUILD_DIR}/${cmake_dir}
sudo cp bin/* /usr/local/bin/
sudo cp -r share/* /usr/local/share/
export PATH="/usr/local/bin:$PATH" # FIXME
elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then
sudo ln -s /usr/local /opt/local
brew update

View file

@ -1,6 +1,7 @@
#!/bin/bash
set -ex
. .travis/environment.sh
# Travis Webhook
wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh

31
.travis/environment.sh Normal file
View file

@ -0,0 +1,31 @@
# ---------------------------------------------------------------------------- #
# Global environment included from all scripts #
# ---------------------------------------------------------------------------- #
# add /usr/local/bin to path, for custom cmake installs
if [[ ${TRAVIS_OS_NAME} == "linux" || ${TRAVIS_OS_NAME} == "osx" ]]; then
export PATH="/usr/local/bin:$PATH"
fi
# buildenv runs a command in host machine or container, depending on build
if [[ ${CROSS_COMPILE} == "mingw32" ]]; then
buildenv() {
setup_container archlinux
docker exec -w "$(pwd)" -i -t "$container" "$@"
}
else
buildenv() {
"$@"
}
fi
# create a container based on given image if not existing
# the container id is persisted in a file across different scripts
setup_container() {
if [ -f ${TRAVIS_BUILD_DIR}/docker-container-id ]; then
container=$(cat ${TRAVIS_BUILD_DIR}/docker-container-id)
else
container=$(docker run -d -i -t -v /home:/home "$1" /bin/bash)
echo "$container" > ${TRAVIS_BUILD_DIR}/docker-container-id
fi
}

View file

@ -1,8 +1,13 @@
#!/bin/bash
set -ex
. .travis/environment.sh
if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
if [[ ${CROSS_COMPILE} == "mingw32" ]]; then
buildenv pacman -Sqy --noconfirm
buildenv pacman -Sq --noconfirm base-devel wget mingw-w64-cmake mingw-w64-gcc mingw-w64-pkg-config mingw-w64-libsndfile
buildenv i686-w64-mingw32-gcc -v && buildenv i686-w64-mingw32-g++ -v && buildenv i686-w64-mingw32-cmake --version
elif [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
sudo apt-get install libasound2-dev libjack-jackd2-dev libsndfile1-dev lv2-dev
gcc -v && g++ -v && cmake --version && /usr/local/bin/cmake --version && $SHELL --version
fi

View file

@ -1,16 +1,22 @@
#!/bin/bash
set -ex
. .travis/environment.sh
mkdir -p build/${INSTALL_DIR} && cd build
/usr/local/bin/cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/${INSTALL_DIR} ..
if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
if [[ ${CROSS_COMPILE} == "mingw32" ]]; then
make -j$(nproc)
buildenv i686-w64-mingw32-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/${INSTALL_DIR} -DSFIZZ_JACK=OFF ..
buildenv make -j
elif [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
buildenv cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/${INSTALL_DIR} ..
buildenv make -j$(nproc)
elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then
make -j$(sysctl -n hw.ncpu)
buildenv cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/${INSTALL_DIR} ..
buildenv make -j$(sysctl -n hw.ncpu)
# Xcode not currently supported, see https://gitlab.kitware.com/cmake/cmake/issues/18088
# xcodebuild -project sfizz.xcodeproj -alltargets -configuration Debug build

View file

@ -1,9 +1,10 @@
#!/bin/bash
set -x # No fail, we need to go back to the original branch at the end
. .travis/environment.sh
# Build documentation only from Linux x86_64 builds
if [[ ${TRAVIS_CPU_ARCH} != "amd64" || ${TRAVIS_OS_NAME} != "linux" ]]; then
if [[ ${TRAVIS_CPU_ARCH} != "amd64" || ${TRAVIS_OS_NAME} != "linux" || "${CROSS_COMPILE}" != "" ]]; then
exit 0
fi