2014-05-26 19:06:57 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-10-21 17:08:16 +02:00
|
|
|
if [[ $TRAVIS != "true" ]]
|
|
|
|
then
|
|
|
|
echo This script is only meant to be run on Travis-CI.
|
|
|
|
echo Please use CMake to build the project.
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-05-26 19:06:57 +02:00
|
|
|
SDL2_PV=2.0.3
|
2015-08-05 22:17:31 +02:00
|
|
|
SDL2_TTF_PV=2.0.12
|
2014-05-26 19:06:57 +02:00
|
|
|
|
|
|
|
cachedir=.cache
|
2015-12-20 05:46:52 +01:00
|
|
|
if [[ $(uname -s) == "Darwin" ]]; then
|
|
|
|
liburl=https://openrct2.website/files/orctlibs-osx.zip
|
|
|
|
else
|
|
|
|
liburl=https://openrct2.website/files/orctlibs.zip
|
|
|
|
fi
|
2015-11-30 08:31:31 +01:00
|
|
|
mkdir -p "$cachedir"
|
2014-05-26 19:06:57 +02:00
|
|
|
|
2016-12-15 17:55:17 +01:00
|
|
|
# Sets default target to "ubuntu_amd64", if none specified
|
|
|
|
TARGET=${TARGET-ubuntu_amd64}
|
2015-09-27 10:43:52 +02:00
|
|
|
# keep in sync with version in build.sh
|
|
|
|
libversion=3
|
|
|
|
libVFile="./libversion"
|
|
|
|
|
2015-11-30 08:31:31 +01:00
|
|
|
function has_cmd {
|
|
|
|
command -v "$1" >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
function calculate_sha256 {
|
|
|
|
if has_cmd "shasum"; then
|
|
|
|
command shasum -a 256 "$1" | cut -f1 -d" "
|
|
|
|
elif has_cmd "sha256sum"; then
|
|
|
|
command sha256sum "$1" | cut -f1 -d" "
|
|
|
|
else
|
|
|
|
echo "Please install either sha256sum or shasum to continue"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-10-07 23:23:03 +02:00
|
|
|
function download {
|
2015-11-30 08:31:31 +01:00
|
|
|
if has_cmd "curl"; then
|
2015-10-17 05:45:40 +02:00
|
|
|
curl -L -o "$2" "$1"
|
2015-11-30 08:31:31 +01:00
|
|
|
elif has_cmd "wget"; then
|
2015-10-17 05:45:40 +02:00
|
|
|
wget -O "$2" "$1"
|
2015-10-07 23:23:03 +02:00
|
|
|
else
|
|
|
|
echo "Please install either wget or curl to continue"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-09-27 10:43:52 +02:00
|
|
|
function download_sdl {
|
|
|
|
if [[ ! -f $cachedir/SDL2-devel-${SDL2_PV}-mingw.tar.gz ]]; then
|
2015-10-07 23:23:03 +02:00
|
|
|
download http://libsdl.org/release/SDL2-devel-${SDL2_PV}-mingw.tar.gz $cachedir/SDL2-devel-${SDL2_PV}-mingw.tar.gz;
|
2015-09-27 10:43:52 +02:00
|
|
|
fi
|
|
|
|
if [[ ! -f $cachedir/SDL2_ttf-devel-${SDL2_TTF_PV}-mingw.tar.gz ]]; then
|
2015-10-07 23:23:03 +02:00
|
|
|
download https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-${SDL2_TTF_PV}-mingw.tar.gz $cachedir/SDL2_ttf-devel-${SDL2_TTF_PV}-mingw.tar.gz;
|
2015-09-27 10:43:52 +02:00
|
|
|
fi
|
|
|
|
if [[ ! -d $cachedir/SDL2-${SDL2_PV} ]]; then
|
|
|
|
pushd $cachedir
|
|
|
|
tar -xzf SDL2-devel-${SDL2_PV}-mingw.tar.gz
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
if [[ ! -d $cachedir/SDL2_ttf-${SDL2_TTF_PV} ]]; then
|
|
|
|
pushd $cachedir
|
|
|
|
tar -xzf SDL2_ttf-devel-${SDL2_TTF_PV}-mingw.tar.gz
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
# Apply platform patch
|
|
|
|
mingw_patch=libsdl2-mingw-2.0.3-fix-platform-detection-for-mingw.patch
|
|
|
|
if [[ ! -f $cachedir/$mingw_patch ]]; then
|
2015-10-07 23:23:03 +02:00
|
|
|
download "https://github.com/anyc/anyc-overlay/raw/master/media-libs/libsdl2-mingw/files/$mingw_patch" $cachedir/$mingw_patch;
|
2015-09-27 10:43:52 +02:00
|
|
|
|
|
|
|
# XXX not sure how to make this idempotent.
|
|
|
|
pushd $cachedir/SDL2-${SDL2_PV}/i686-w64-mingw32/include/SDL2/
|
|
|
|
echo "Applying patch."
|
|
|
|
patch -p2 < ../../../../$mingw_patch
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function download_libs {
|
|
|
|
if [[ ! -f $cachedir/orctlibs.zip ]]; then
|
2015-10-07 23:23:03 +02:00
|
|
|
download $liburl $cachedir/orctlibs.zip;
|
2015-09-27 10:43:52 +02:00
|
|
|
fi
|
|
|
|
if [[ ! -d $cachedir/orctlibs ]]; then
|
|
|
|
mkdir -p $cachedir/orctlibs
|
|
|
|
pushd $cachedir/orctlibs
|
|
|
|
unzip -uaq ../orctlibs.zip
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_cross_tools {
|
|
|
|
if [[ ! -d /usr/local/cross-tools ]]; then
|
|
|
|
sudo mkdir -p /usr/local/cross-tools
|
|
|
|
fi
|
|
|
|
if [[ ! -d /usr/local/cross-tools/i686-w64-mingw32 ]]; then
|
|
|
|
sudo cp -r $cachedir/SDL2-${SDL2_PV}/i686-w64-mingw32 /usr/local/cross-tools/
|
|
|
|
sudo cp -r $cachedir/SDL2_ttf-${SDL2_TTF_PV}/i686-w64-mingw32 /usr/local/cross-tools/
|
|
|
|
fi
|
|
|
|
if [[ ! -d /usr/local/cross-tools/orctlibs ]]; then
|
|
|
|
sudo mkdir -p /usr/local/cross-tools/orctlibs
|
|
|
|
sudo cp -rf $cachedir/orctlibs/glob/* /usr/local/cross-tools/orctlibs/.
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_pkg_config {
|
|
|
|
if [[ ! -f $cachedir/i686-w64-mingw32-pkg-config ]]; then
|
|
|
|
# If this fails to work because of newlines, be sure you are running this
|
|
|
|
# script with Bash, and not sh. We should really move this to a separate
|
|
|
|
# file.
|
|
|
|
echo -e "#!/bin/sh\nexport PKG_CONFIG_PATH=/usr/local/cross-tools/i686-w64-mingw32/lib/pkgconfig:/usr/local/cross-tools/orctlibs/lib/pkgconfig\npkg-config \$@" > $cachedir/i686-w64-mingw32-pkg-config;
|
|
|
|
fi
|
|
|
|
|
|
|
|
chmod +x $cachedir/i686-w64-mingw32-pkg-config
|
|
|
|
sudo cp $cachedir/i686-w64-mingw32-pkg-config /usr/local/bin/
|
|
|
|
|
|
|
|
ls -al /usr/local/bin | grep pkg-config
|
|
|
|
cat /usr/local/bin/i686-w64-mingw32-pkg-config
|
|
|
|
}
|
|
|
|
|
2016-06-13 19:49:06 +02:00
|
|
|
function mac_os_install_mingw_32 {
|
2015-11-30 08:31:31 +01:00
|
|
|
local mingw_name="mingw-w32-bin_i686-darwin"
|
|
|
|
local mingw_tar="${mingw_name}_20130531.tar.bz2"
|
|
|
|
local mingw_path="/usr/local/$mingw_name"
|
|
|
|
|
|
|
|
if [[ ! -f "$cachedir/$mingw_tar" ]]; then
|
|
|
|
download "https://downloads.sourceforge.net/project/mingw-w64/Toolchains targetting Win32/Automated Builds/$mingw_tar" "$cachedir/$mingw_tar"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d "$mingw_path" ]]; then
|
|
|
|
echo "Extracting contents of $mingw_tar to $mingw_path"
|
|
|
|
echo "Don't forget to add $mingw_path/bin to your PATH variable!"
|
|
|
|
|
|
|
|
mkdir "$mingw_path"
|
|
|
|
tar -xyf "$cachedir/$mingw_tar" -C "$mingw_path"
|
|
|
|
|
|
|
|
pushd "$mingw_path"
|
|
|
|
find . -type d -exec chmod 755 {} \;
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "HOST = $(uname)"
|
|
|
|
echo "TARGET = $TARGET"
|
|
|
|
|
|
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
|
|
if ! has_cmd "brew"; then
|
|
|
|
echo "Homebrew is not installed, or brew is not in your \$PATH"
|
|
|
|
echo "install instructions: http://brew.sh/"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
brew install cmake
|
|
|
|
|
|
|
|
if [[ $TARGET == "windows" ]]; then
|
|
|
|
brew install wine
|
2016-06-13 19:49:06 +02:00
|
|
|
mac_os_install_mingw_32
|
2015-11-30 08:31:31 +01:00
|
|
|
else
|
|
|
|
brew install jansson sdl2 sdl2_ttf speex --universal
|
|
|
|
fi
|
2015-11-04 10:55:59 +01:00
|
|
|
elif [[ $(uname) == "Linux" ]]; then
|
2015-09-03 13:38:21 +02:00
|
|
|
if [[ -z "$TRAVIS" ]]; then
|
|
|
|
sudo apt-get install -y binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 cmake
|
|
|
|
if [[ -z "$DISABLE_G2_BUILD" ]]; then
|
|
|
|
sudo apt-get install -y wine
|
|
|
|
fi
|
|
|
|
else
|
2015-09-27 10:43:52 +02:00
|
|
|
# prevent build.sh from re-doing all the steps again
|
2015-09-24 22:47:14 +02:00
|
|
|
case "$TARGET" in
|
2016-12-15 17:55:17 +01:00
|
|
|
"ubuntu_i686")
|
|
|
|
docker pull openrct2/openrct2:ubuntu_i686
|
2015-09-24 22:47:14 +02:00
|
|
|
;;
|
2016-12-15 17:55:17 +01:00
|
|
|
"ubuntu_amd64")
|
|
|
|
docker pull openrct2/openrct2:ubuntu_amd64
|
2016-04-26 22:42:39 +02:00
|
|
|
;;
|
2015-09-24 22:47:14 +02:00
|
|
|
"windows")
|
2016-12-15 17:55:17 +01:00
|
|
|
docker pull openrct2/openrct2:mingw
|
2015-09-24 22:47:14 +02:00
|
|
|
;;
|
2015-09-27 10:43:52 +02:00
|
|
|
"docker32")
|
2015-10-03 22:50:50 +02:00
|
|
|
docker pull openrct2/openrct2:32bit-only
|
2015-09-27 10:43:52 +02:00
|
|
|
;;
|
2016-10-15 22:24:24 +02:00
|
|
|
"docker64")
|
|
|
|
docker pull openrct2/openrct2:64bit-only
|
|
|
|
;;
|
2015-09-24 22:47:14 +02:00
|
|
|
*)
|
|
|
|
echo "unkown target $TARGET"
|
|
|
|
exit 1
|
|
|
|
esac
|
2015-09-03 13:38:21 +02:00
|
|
|
fi
|
2014-05-26 19:06:57 +02:00
|
|
|
fi
|
|
|
|
|
2016-01-09 20:39:13 +01:00
|
|
|
if [[ $TARGET == "windows" || $(uname -s) == "Darwin" ]]; then
|
|
|
|
download_libs
|
|
|
|
calculate_sha256 "$cachedir/orctlibs.zip" > "$libVFile"
|
|
|
|
echo "Downloaded library with sha256sum: $(cat "$libVFile")"
|
|
|
|
# Local libs are required for all targets
|
|
|
|
# $TARGET == "windows" || $(uname -s) == "Darwin"
|
|
|
|
fi
|
2014-05-26 19:06:57 +02:00
|
|
|
|
2015-09-27 10:43:52 +02:00
|
|
|
if [[ $TARGET == "windows" ]]; then
|
|
|
|
download_sdl
|
|
|
|
install_cross_tools
|
|
|
|
install_pkg_config
|
2015-09-24 22:47:14 +02:00
|
|
|
# $TARGET == "windows"
|
|
|
|
fi
|