Improve buildbot script
authorPierre-Yves Rollo <dev@pyrollo.com>
Fri, 21 Jun 2019 00:43:59 +0000 (02:43 +0200)
committerrubenwardy <rw@rubenwardy.com>
Fri, 21 Jun 2019 00:46:00 +0000 (01:46 +0100)
PR created under the employment of EvidenceBKidscode

* Variables to set git repositories urls (allows to build from another repo)
* Variables to set git branch to build from (allows to build from non-master branch)
* Variables to change built name
* Make -j uses the proper number of processors (autodetect)
* Changed toolchain from win32 to adpat it to non-debian distros

.travis.yml
util/buildbot/buildwin32.sh
util/buildbot/buildwin64.sh
util/buildbot/toolchain_i586-mingw32msvc.cmake [new file with mode: 0644]
util/buildbot/toolchain_i646-w64-mingw32.cmake [new file with mode: 0644]
util/buildbot/toolchain_mingw.cmake [deleted file]
util/buildbot/toolchain_mingw64.cmake [deleted file]
util/buildbot/toolchain_x86_64-w64-mingw32.cmake [new file with mode: 0644]
util/travis/before_install.sh

index 23f6d5ebb15c665ce6e174a19aebdf9ac12bc2af..2eb14a96f51d09992d0afc8167e8cfdce86a535e 100644 (file)
@@ -34,22 +34,10 @@ matrix:
     - env: PLATFORM=Win32
       compiler: gcc
       os: linux
-      addons:
-        apt:
-          packages: ['gcc-mingw-w64-i686', 'g++-mingw-w64-i686', 'binutils-mingw-w64-i686']
-          sources: &sources
-            - ubuntu-toolchain-r-test
-            - sourceline: 'deb http://mirrors.kernel.org/ubuntu xenial main universe'
 
     - env: PLATFORM=Win64
       compiler: gcc
       os: linux
-      addons:
-        apt:
-          packages: ['gcc-mingw-w64-x86-64', 'g++-mingw-w64-x86-64', 'binutils-mingw-w64-x86-64']
-          sources: &sources
-            - ubuntu-toolchain-r-test
-            - sourceline: 'deb http://mirrors.kernel.org/ubuntu xenial main universe'
 
     - env: PLATFORM=Unix
       compiler: clang
index 6646ca1642bba943292864759d73769337cc61c5..9af4eb02e362092f82c952b834871e1cf5b86de0 100755 (executable)
@@ -1,6 +1,13 @@
 #!/bin/bash
 set -e
 
+CORE_GIT=https://github.com/minetest/minetest
+CORE_BRANCH=master
+CORE_NAME=minetest
+GAME_GIT=https://github.com/minetest/minetest_game
+GAME_BRANCH=master
+GAME_NAME=minetest_game
+
 dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 if [ $# -ne 1 ]; then
        echo "Usage: $0 <build directory>"
@@ -12,7 +19,18 @@ builddir="$( cd "$builddir" && pwd )"
 packagedir=$builddir/packages
 libdir=$builddir/libs
 
-toolchain_file=$dir/toolchain_mingw.cmake
+# Test which win32 compiler is present
+which i586-mingw32msvc-windres > /dev/null 2>&1 && toolchain_file=$dir/toolchain_i586-mingw32msvc.cmake
+which i686-w64-mingw32-windres > /dev/null 2>&1 && toolchain_file=$dir/toolchain_i646-w64-mingw32.cmake
+
+if [ -z "$toolchain_file" ]
+then
+       echo "Unable to determine which mingw32 compiler to use"
+       exit 1
+else
+       echo "Using $toolchain_file"
+fi
+
 irrlicht_version=1.8.4
 ogg_version=1.3.2
 vorbis_version=1.3.5
@@ -70,22 +88,22 @@ cd $libdir
 # Get minetest
 cd $builddir
 if [ ! "x$EXISTING_MINETEST_DIR" = "x" ]; then
-       ln -s $EXISTING_MINETEST_DIR minetest
+       ln -s $EXISTING_MINETEST_DIR $CORE_NAME
 else
-       [ -d minetest ] && (cd minetest && git pull) || (git clone https://github.com/minetest/minetest)
+       [ -d $CORE_NAME ] && (cd $CORE_NAME && git pull) || (git clone -b $CORE_BRANCH $CORE_GIT)
 fi
-cd minetest
+cd $CORE_NAME
 git_hash=$(git rev-parse --short HEAD)
 
 # Get minetest_game
 cd games
 if [ "x$NO_MINETEST_GAME" = "x" ]; then
-       [ -d minetest_game ] && (cd minetest_game && git pull) || (git clone https://github.com/minetest/minetest_game)
+       [ -d $GAME_NAME ] && (cd $GAME_NAME && git pull) || (git clone -b $GAME_BRANCH $GAME_GIT)
 fi
 cd ../..
 
 # Build the thing
-cd minetest
+cd $CORE_NAME
 [ -d _build ] && rm -Rf _build/
 mkdir _build
 cd _build
@@ -149,7 +167,7 @@ cmake .. \
        -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
        -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
 
-make -j2
+make -j$(nproc)
 
 [ "x$NO_PACKAGE" = "x" ] && make package
 
index b0b2bed1740acb9354b3c3359d88387ed09d5d26..7e3db4842559d1ea756ff62304a186bc4962034e 100755 (executable)
@@ -1,6 +1,13 @@
 #!/bin/bash
 set -e
 
+CORE_GIT=https://github.com/minetest/minetest
+CORE_BRANCH=master
+CORE_NAME=minetest
+GAME_GIT=https://github.com/minetest/minetest_game
+GAME_BRANCH=master
+GAME_NAME=minetest_game
+
 dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 if [ $# -ne 1 ]; then
        echo "Usage: $0 <build directory>"
@@ -12,7 +19,7 @@ builddir="$( cd "$builddir" && pwd )"
 packagedir=$builddir/packages
 libdir=$builddir/libs
 
-toolchain_file=$dir/toolchain_mingw64.cmake
+toolchain_file=$dir/toolchain_x86_64-w64-mingw32.cmake
 irrlicht_version=1.8.4
 ogg_version=1.3.2
 vorbis_version=1.3.5
@@ -71,22 +78,22 @@ cd $libdir
 # Get minetest
 cd $builddir
 if [ ! "x$EXISTING_MINETEST_DIR" = "x" ]; then
-       ln -s $EXISTING_MINETEST_DIR minetest
+       ln -s $EXISTING_MINETEST_DIR $CORE_NAME
 else
-       [ -d minetest ] && (cd minetest && git pull) || (git clone https://github.com/minetest/minetest)
+       [ -d $CORE_NAME ] && (cd $CORE_NAME && git pull) || (git clone -b $CORE_BRANCH $CORE_GIT)
 fi
-cd minetest
+cd $CORE_NAME
 git_hash=$(git rev-parse --short HEAD)
 
 # Get minetest_game
 cd games
 if [ "x$NO_MINETEST_GAME" = "x" ]; then
-       [ -d minetest_game ] && (cd minetest_game && git pull) || (git clone https://github.com/minetest/minetest_game)
+       [ -d $GAME_NAME ] && (cd $GAME_NAME && git pull) || (git clone -b $GAME_BRANCH $GAME_GIT)
 fi
 cd ../..
 
 # Build the thing
-cd minetest
+cd $CORE_NAME
 [ -d _build ] && rm -Rf _build/
 mkdir _build
 cd _build
@@ -150,7 +157,7 @@ cmake .. \
        -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
        -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
 
-make -j2
+make -j$(nproc)
 
 [ "x$NO_PACKAGE" = "x" ] && make package
 
diff --git a/util/buildbot/toolchain_i586-mingw32msvc.cmake b/util/buildbot/toolchain_i586-mingw32msvc.cmake
new file mode 100644 (file)
index 0000000..0eeefb8
--- /dev/null
@@ -0,0 +1,17 @@
+# name of the target operating system
+SET(CMAKE_SYSTEM_NAME Windows)
+
+# which compilers to use for C and C++
+SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
+SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
+SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
+
+# here is the target environment located
+SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc)
+
+# adjust the default behaviour of the FIND_XXX() commands:
+# search headers and libraries in the target environment, search
+# programs in the host environment
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/util/buildbot/toolchain_i646-w64-mingw32.cmake b/util/buildbot/toolchain_i646-w64-mingw32.cmake
new file mode 100644 (file)
index 0000000..015baa2
--- /dev/null
@@ -0,0 +1,17 @@
+# name of the target operating system
+SET(CMAKE_SYSTEM_NAME Windows)
+
+# which compilers to use for C and C++
+SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
+SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
+SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
+
+# here is the target environment located
+SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
+
+# adjust the default behaviour of the FIND_XXX() commands:
+# search headers and libraries in the target environment, search
+# programs in the host environment
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/util/buildbot/toolchain_mingw.cmake b/util/buildbot/toolchain_mingw.cmake
deleted file mode 100644 (file)
index 0eeefb8..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# name of the target operating system
-SET(CMAKE_SYSTEM_NAME Windows)
-
-# which compilers to use for C and C++
-SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
-SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
-SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
-
-# here is the target environment located
-SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc)
-
-# adjust the default behaviour of the FIND_XXX() commands:
-# search headers and libraries in the target environment, search
-# programs in the host environment
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/util/buildbot/toolchain_mingw64.cmake b/util/buildbot/toolchain_mingw64.cmake
deleted file mode 100644 (file)
index 9a7ed82..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# name of the target operating system
-SET(CMAKE_SYSTEM_NAME Windows)
-
-# which compilers to use for C and C++
-SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
-SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
-SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
-
-# here is the target environment located
-SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
-
-# adjust the default behaviour of the FIND_XXX() commands:
-# search headers and libraries in the target environment, search
-# programs in the host environment
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/util/buildbot/toolchain_x86_64-w64-mingw32.cmake b/util/buildbot/toolchain_x86_64-w64-mingw32.cmake
new file mode 100644 (file)
index 0000000..9a7ed82
--- /dev/null
@@ -0,0 +1,17 @@
+# name of the target operating system
+SET(CMAKE_SYSTEM_NAME Windows)
+
+# which compilers to use for C and C++
+SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
+SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
+SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
+
+# here is the target environment located
+SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
+
+# adjust the default behaviour of the FIND_XXX() commands:
+# search headers and libraries in the target environment, search
+# programs in the host environment
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
index fef054130dd1f49f6c9451444503d37f94b541f7..fe9243583f09c0f91537b846a5f77cc7a6f1123f 100755 (executable)
@@ -20,9 +20,7 @@ elif [[ $PLATFORM == "Win32" ]]; then
        sudo apt-get update
        sudo apt-get install p7zip-full
        wget http://minetest.kitsunemimi.pw/mingw-w64-i686_7.1.1_ubuntu14.04.7z -O mingw.7z
-       sed -e "s|%PREFIX%|i686-w64-mingw32|" \
-               -e "s|%ROOTPATH%|/usr/i686-w64-mingw32|" \
-               < util/travis/toolchain_mingw.cmake.in > util/buildbot/toolchain_mingw.cmake
+       # buildwin32.sh detects the installed toolchain automatically
        sudo 7z x -y -o/usr mingw.7z
 elif [[ $PLATFORM == "Win64" ]]; then
        sudo apt-get update