The-Powder-Toy/.github/build.sh

131 lines
3.7 KiB
Bash
Raw Normal View History

2019-12-17 08:03:41 -06:00
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
if [ -z "${PLATFORM_SHORT-}" ]; then
2021-03-12 14:02:02 -06:00
>&2 echo "PLATFORM_SHORT not set (lin, mac, win)"
exit 1
fi
if [ -z "${MACHINE_SHORT-}" ]; then
>&2 echo "MACHINE_SHORT not set (x86_64, i686)"
exit 1
fi
if [ -z "${TOOLSET_SHORT-}" ]; then
>&2 echo "TOOLSET_SHORT not set (gcc, clang, mingw)"
2019-12-17 08:03:41 -06:00
exit 1
fi
if [ -z "${STATIC_DYNAMIC-}" ]; then
2021-03-12 14:02:02 -06:00
>&2 echo "STATIC_DYNAMIC not set (static, dynamic)"
2019-12-17 08:03:41 -06:00
exit 1
fi
if [ -z "${RELNAME-}" ]; then
>&2 echo "RELNAME not set"
exit 1
fi
if [ -z "${RELTYPE-}" ]; then
>&2 echo "RELTYPE not set"
exit 1
fi
if [ -z "${MOD_ID-}" ]; then
>&2 echo "MOD_ID not set"
exit 1
fi
2019-12-17 08:03:41 -06:00
if [ -z "${build_sh_init-}" ]; then
if [ $TOOLSET_SHORT == "msvc" ]; then
2019-12-17 08:03:41 -06:00
for i in C:/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/**/**/VC/Auxiliary/Build/vcvarsall.bat; do
vcvarsall_path=$i
done
2021-03-12 14:02:02 -06:00
if [ $MACHINE_SHORT == "x86_64" ]; then
x64_x86=x64
else
x64_x86=x86
fi
2019-12-17 08:03:41 -06:00
cat << BUILD_INIT_BAT > .github/build_init.bat
@echo off
2021-03-12 14:02:02 -06:00
call "${vcvarsall_path}" ${x64_x86}
2019-12-17 08:03:41 -06:00
bash -c 'build_sh_init=1 ./.github/build.sh'
BUILD_INIT_BAT
./.github/build_init.bat
else
build_sh_init=1 ./.github/build.sh
fi
exit 0
fi
other_flags=$'\t-Dmod_id='
other_flags+=$MOD_ID
bin_suffix=
2019-12-17 08:03:41 -06:00
static_flag=
if [ $STATIC_DYNAMIC == "static" ]; then
static_flag=-Dstatic=prebuilt
if [ $PLATFORM_SHORT == "win" ]; then
other_flags+=$'\t-Db_vscrt=static_from_buildtype'
2019-12-17 08:03:41 -06:00
fi
fi
if [ $PLATFORM_SHORT == "lin" ]; then
# We use gcc on lin; sadly, gcc + lto + libstdc++ + pthread = undefined reference to
# pthread_create, thanks to weak symbols in libstdc++.so (or something). See
# https://gcc.gnu.org/legacy-ml/gcc-help/2017-03/msg00081.html
other_flags+=$'\t-Db_asneeded=false\t-Dcpp_link_args=-Wl,--no-as-needed'
2021-12-24 10:43:44 -06:00
if [ $STATIC_DYNAMIC == "static" ] && [ $TOOLSET_SHORT == "gcc" ]; then
other_flags+=$'\t-Dbuild_render=true\t-Dbuild_font=true'
fi
2019-12-17 08:03:41 -06:00
fi
2021-12-24 10:43:44 -06:00
if [ $TOOLSET_SHORT == "mingw" ]; then
bin_suffix=$bin_suffix.exe
2019-12-17 08:03:41 -06:00
fi
2021-06-30 15:13:24 -05:00
stable_or_beta="n"
if [ "$RELTYPE" == "beta" ]; then
other_flags+=$'\t-Dbeta=true'
stable_or_beta="y"
fi
if [ "$RELTYPE" == "stable" ]; then
stable_or_beta="y"
fi
if [ "$RELTYPE" == "snapshot" ]; then
other_flags+=$'\t-Dsnapshot=true\t-Dsnapshot_id='
other_flags+=`echo $RELNAME | cut -d '-' -f 2` # $RELNAME is snapshot-X
fi
if [ "$RELTYPE" == "snapshot" ] && [ "$MOD_ID" != "0" ]; then
>&2 echo "mods and snapshots do not mix"
exit 1
fi
2021-06-30 15:13:24 -05:00
if [ "$stable_or_beta" == "y" ] && [ "$MOD_ID" != "0" ]; then
# mods and snapshots both check their snapshot_id against whatever version starcatcher.us/TPT has
other_flags+=$'\t-Dsnapshot_id='
other_flags+=`echo $RELNAME | cut -d '.' -f 3` # $RELNAME is vX.Y.Z
fi
if [ "$RELTYPE" == "snapshot" ] || [ "$MOD_ID" != "0" ]; then
2020-12-15 15:02:56 -06:00
other_flags+=$'\t-Dupdate_server=starcatcher.us/TPT'
fi
if [ "$RELTYPE" != "dev" ]; then
other_flags+=$'\t-Dignore_updates=false'
fi
lto_flag=-Db_lto=true
if [ $TOOLSET_SHORT == "mingw" ]; then
# This simply doesn't work with MinGW. I have no idea why and I also don't care.
lto_flag=
2021-12-24 10:43:44 -06:00
if [ $PLATFORM_SHORT == "lin" ]; then
other_flags+=$'\t--cross-file=.github/mingw-ghactions.ini'
fi
fi
if [ $PLATFORM_SHORT == "mac" ]; then
macosx_version_min=10.9
if [ $MACHINE_SHORT == "arm64" ]; then
macosx_version_min=10.15
other_flags+=$'\t--cross-file=.github/macaa64-ghactions.ini'
fi
export CFLAGS=-mmacosx-version-min=$macosx_version_min
export CXXFLAGS=-mmacosx-version-min=$macosx_version_min
export LDFLAGS=-mmacosx-version-min=$macosx_version_min
fi
meson -Dbuildtype=release -Db_pie=false -Dworkaround_gcc_no_pie=true -Db_staticpic=false $lto_flag $static_flag -Dinstall_check=true $other_flags build
2019-12-17 08:03:41 -06:00
cd build
ninja
2020-12-15 15:02:56 -06:00
if [ $PLATFORM_SHORT == "lin" ] || [ $PLATFORM_SHORT == "mac" ]; then
strip powder$bin_suffix
2020-12-15 15:02:56 -06:00
fi
cp powder$bin_suffix ..