mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-02-01 11:15:13 +01:00
Move scripts to new location
This commit is contained in:
107
scripts/linux/build.sh
Executable file
107
scripts/linux/build.sh
Executable file
@@ -0,0 +1,107 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
cachedir=.cache
|
||||
mkdir -p $cachedir
|
||||
|
||||
# Sets default target to "linux", if none specified
|
||||
TARGET=${TARGET-linux}
|
||||
|
||||
if [[ ! -d build ]]; then
|
||||
mkdir -p build
|
||||
fi
|
||||
|
||||
# keep in sync with version in install.sh
|
||||
if [[ $(uname -s) == "Darwin" ]]; then
|
||||
# keep in sync with version in Xcode project
|
||||
sha256sum=2cec3958352477fbb876a5b6398722077084b5ff7e95a7d3cd67492abf5012fc
|
||||
else
|
||||
sha256sum=69ff98c9544838fb16384bc78af9dc1c452b9d01d919e43f5fec686d02c9bdd8
|
||||
fi
|
||||
libVFile="./libversion"
|
||||
libdir="./lib"
|
||||
currentversion=0
|
||||
needsdownload="true"
|
||||
|
||||
if [ -f $libVFile ]; then
|
||||
while read line; do
|
||||
currentversion=$line
|
||||
continue
|
||||
done < $libVFile
|
||||
fi
|
||||
|
||||
if [ "z$currentversion" == "z$sha256sum" ]; then
|
||||
needsdownload="false"
|
||||
fi
|
||||
|
||||
if [ ! -d $libdir ]; then
|
||||
needsdownload="true"
|
||||
fi
|
||||
|
||||
if [[ "$needsdownload" = "true" ]]; then
|
||||
echo "Found library had sha256sum $currentversion, expected $sha256sum"
|
||||
echo "New libraries need to be downloaded. Clearing cache and calling ./install.sh"
|
||||
rm -rf ./lib
|
||||
if [[ -f $cachedir/orctlibs.zip ]]; then
|
||||
rm -rf $cachedir/orctlibs.zip
|
||||
fi
|
||||
if [[ -d /usr/local/cross-tools/orctlibs ]]; then
|
||||
sudo rm -rf /usr/local/cross-tools/orctlibs
|
||||
fi
|
||||
if [[ -d $cachedir/orctlibs ]]; then
|
||||
rm -rf $cachedir/orctlibs
|
||||
fi
|
||||
scripts/linux/install.sh
|
||||
fi
|
||||
|
||||
pushd build
|
||||
echo OPENRCT2_CMAKE_OPTS = $OPENRCT2_CMAKE_OPTS
|
||||
if [[ $TARGET == "docker32" ]]
|
||||
then
|
||||
PARENT=$(readlink -f ../)
|
||||
chmod a+rwx $(pwd)
|
||||
chmod g+s $(pwd)
|
||||
docker run -u travis -v $PARENT:/work/openrct2 -w /work/openrct2/build -i -t openrct2/openrct2:32bit-only bash -c "cmake ../ $OPENRCT2_CMAKE_OPTS && make"
|
||||
else
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug $OPENRCT2_CMAKE_OPTS ..
|
||||
make
|
||||
fi
|
||||
popd
|
||||
|
||||
if [[ $TARGET == "windows" ]]; then
|
||||
if [[ ! -h openrct2.dll ]]; then
|
||||
ln -s build/openrct2.dll openrct2.dll
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -h build/data ]]; then
|
||||
ln -s ../data build/data
|
||||
fi
|
||||
|
||||
if [[ $TARGET == "linux" ]] || [[ $TARGET == "docker32" ]]; then
|
||||
if [[ ! -h openrct2 ]]; then
|
||||
ln -s build/openrct2 openrct2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "$DISABLE_G2_BUILD" ]]; then
|
||||
echo Building: g2.dat
|
||||
pushd build
|
||||
make g2
|
||||
popd
|
||||
fi
|
||||
|
||||
if [[ $TARGET == "windows" ]]; then
|
||||
if [[ -t 1 ]]; then
|
||||
echo -e "\nDone! Run OpenRCT2 by typing:\n\n\033[95mwine openrct2.exe\n\033[0m"
|
||||
else
|
||||
echo -e "\nDone! Run OpenRCT2 by typing:\n\nwine openrct2.exe\n"
|
||||
fi
|
||||
else
|
||||
if [[ -t 1 ]]; then
|
||||
echo -e "\nDone! Run OpenRCT2 by typing:\n\n\033[95m./openrct2\n\033[0m"
|
||||
else
|
||||
echo -e "\nDone! Run OpenRCT2 by typing:\n\n./openrct2\n"
|
||||
fi
|
||||
fi
|
||||
9
scripts/linux/clean.sh
Executable file
9
scripts/linux/clean.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ev
|
||||
|
||||
sudo rm -rf /usr/local/cross-tools/i686-w64-mingw32
|
||||
sudo rm -rf /usr/local/cross-tools/orcalibs
|
||||
sudo rm -rf /usr/local/cross-tools/orctlibs
|
||||
rm -rf .cache
|
||||
rm -rf build
|
||||
206
scripts/linux/install.sh
Executable file
206
scripts/linux/install.sh
Executable file
@@ -0,0 +1,206 @@
|
||||
#!/bin/bash
|
||||
|
||||
SDL2_PV=2.0.3
|
||||
SDL2_TTF_PV=2.0.12
|
||||
|
||||
cachedir=.cache
|
||||
if [[ $(uname -s) == "Darwin" ]]; then
|
||||
liburl=https://openrct2.website/files/orctlibs-osx.zip
|
||||
else
|
||||
liburl=https://openrct2.website/files/orctlibs.zip
|
||||
fi
|
||||
mkdir -p "$cachedir"
|
||||
|
||||
# Sets default target to "linux", if none specified
|
||||
TARGET=${TARGET-linux}
|
||||
# keep in sync with version in build.sh
|
||||
libversion=3
|
||||
libVFile="./libversion"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
function download {
|
||||
if has_cmd "curl"; then
|
||||
curl -L -o "$2" "$1"
|
||||
elif has_cmd "wget"; then
|
||||
wget -O "$2" "$1"
|
||||
else
|
||||
echo "Please install either wget or curl to continue"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function download_sdl {
|
||||
if [[ ! -f $cachedir/SDL2-devel-${SDL2_PV}-mingw.tar.gz ]]; then
|
||||
download http://libsdl.org/release/SDL2-devel-${SDL2_PV}-mingw.tar.gz $cachedir/SDL2-devel-${SDL2_PV}-mingw.tar.gz;
|
||||
fi
|
||||
if [[ ! -f $cachedir/SDL2_ttf-devel-${SDL2_TTF_PV}-mingw.tar.gz ]]; then
|
||||
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;
|
||||
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
|
||||
download "https://github.com/anyc/anyc-overlay/raw/master/media-libs/libsdl2-mingw/files/$mingw_patch" $cachedir/$mingw_patch;
|
||||
|
||||
# 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
|
||||
download $liburl $cachedir/orctlibs.zip;
|
||||
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
|
||||
}
|
||||
|
||||
function install_local_libs {
|
||||
mkdir -p lib
|
||||
cp -rf $cachedir/orctlibs/local/* ./lib/.
|
||||
}
|
||||
|
||||
function os_x_install_mingw_32 {
|
||||
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
|
||||
os_x_install_mingw_32
|
||||
else
|
||||
brew install jansson sdl2 sdl2_ttf speex --universal
|
||||
fi
|
||||
elif [[ $(uname) == "Linux" ]]; then
|
||||
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
|
||||
# prevent build.sh from re-doing all the steps again
|
||||
case "$TARGET" in
|
||||
"linux")
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get install --no-install-recommends -y --force-yes cmake libsdl2-dev:i386 libsdl2-ttf-dev:i386 gcc-4.8 pkg-config:i386 g++-4.8-multilib gcc-4.8-multilib libjansson-dev:i386 libspeex-dev:i386 libspeexdsp-dev:i386 libcurl4-openssl-dev:i386 libcrypto++-dev:i386 clang
|
||||
download https://launchpad.net/ubuntu/+archive/primary/+files/libjansson4_2.7-1ubuntu1_i386.deb libjansson4_2.7-1ubuntu1_i386.deb
|
||||
download https://launchpad.net/ubuntu/+archive/primary/+files/libjansson-dev_2.7-1ubuntu1_i386.deb libjansson-dev_2.7-1ubuntu1_i386.deb
|
||||
sudo dpkg -i libjansson4_2.7-1ubuntu1_i386.deb
|
||||
sudo dpkg -i libjansson-dev_2.7-1ubuntu1_i386.deb
|
||||
sudo apt-get install -f
|
||||
;;
|
||||
"windows")
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 cmake
|
||||
;;
|
||||
"docker32")
|
||||
docker pull openrct2/openrct2:32bit-only
|
||||
;;
|
||||
*)
|
||||
echo "unkown target $TARGET"
|
||||
exit 1
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
download_libs
|
||||
calculate_sha256 "$cachedir/orctlibs.zip" > "$libVFile"
|
||||
echo "Downloaded library with sha256sum: $(cat "$libVFile")"
|
||||
# Local libs are required for all targets
|
||||
install_local_libs
|
||||
|
||||
if [[ $TARGET == "windows" ]]; then
|
||||
download_sdl
|
||||
install_cross_tools
|
||||
install_pkg_config
|
||||
# $TARGET == "windows"
|
||||
fi
|
||||
Reference in New Issue
Block a user