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
|
2021-04-04 15:09:16 -05:00
|
|
|
if [ -z "${RELNAME-}" ]; then
|
|
|
|
>&2 echo "RELNAME not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-04-16 16:20:38 -05:00
|
|
|
if [ -z "${RELTYPE-}" ]; then
|
|
|
|
>&2 echo "RELTYPE not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-04-04 15:09:16 -05:00
|
|
|
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
|
2021-10-22 09:38:42 -05:00
|
|
|
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
|
|
|
|
|
2021-04-04 15:09:16 -05:00
|
|
|
other_flags=$'\t-Dmod_id='
|
|
|
|
other_flags+=$MOD_ID
|
2021-01-21 12:08:27 -06:00
|
|
|
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
|
2021-01-03 03:13:55 -06:00
|
|
|
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
|
2021-01-21 12:08:27 -06:00
|
|
|
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
|
2021-01-21 12:08:27 -06:00
|
|
|
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
|
2021-04-16 16:20:38 -05:00
|
|
|
if [ "$RELTYPE" == "snapshot" ]; then
|
2021-04-04 15:09:16 -05:00
|
|
|
other_flags+=$'\t-Dsnapshot=true\t-Dsnapshot_id='
|
2021-04-16 16:20:38 -05:00
|
|
|
other_flags+=`echo $RELNAME | cut -d '-' -f 2` # $RELNAME is snapshot-X
|
2021-04-04 15:09:16 -05:00
|
|
|
fi
|
2021-04-16 16:20:38 -05:00
|
|
|
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
|
2021-04-16 16:20:38 -05:00
|
|
|
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
|
2021-04-16 16:20:38 -05:00
|
|
|
if [ "$RELTYPE" != "dev" ]; then
|
|
|
|
other_flags+=$'\t-Dignore_updates=false'
|
|
|
|
fi
|
2021-10-22 09:38:42 -05:00
|
|
|
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
|
2021-10-22 09:38:42 -05:00
|
|
|
fi
|
2022-02-16 06:31:31 -06:00
|
|
|
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
|
2022-04-09 08:01:23 -05:00
|
|
|
if [ "$RELTYPE" == "tptlibsdev" ]; then
|
|
|
|
tptlibsbranch=`echo $RELNAME | cut -d '-' -f 2-` # $RELNAME is tptlibsdev-BRANCH
|
|
|
|
git clone https://github.com/$GITHUB_REPOSITORY_OWNER/tpt-libs --branch $tptlibsbranch
|
|
|
|
cd tpt-libs
|
|
|
|
if [ ! -d patches/$MACHINE_SHORT-$PLATFORM_SHORT-$TOOLSET_SHORT-$STATIC_DYNAMIC ]; then
|
|
|
|
cd ..
|
|
|
|
echo "no prebuilt libraries for this configuration" > powder$bin_suffix
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
VTAG=v00000000000000 ./build.sh
|
|
|
|
cd ../subprojects
|
|
|
|
7z x ../tpt-libs/temp/libraries.zip
|
|
|
|
other_flags+=$'\t-Dtpt_libs_vtag=v00000000000000'
|
|
|
|
cd ..
|
|
|
|
fi
|
2022-02-16 06:31:31 -06:00
|
|
|
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
|
2021-01-21 12:08:27 -06:00
|
|
|
strip powder$bin_suffix
|
2020-12-15 15:02:56 -06:00
|
|
|
fi
|
2021-01-21 12:08:27 -06:00
|
|
|
cp powder$bin_suffix ..
|