2022-08-23 04:14:06 -05:00
|
|
|
#!/usr/bin/env bash
|
2019-12-17 08:03:41 -06:00
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
|
2022-12-17 06:53:37 -06:00
|
|
|
if [[ -z ${BSH_BUILD_PLATFORM-} ]]; then >&2 echo "BSH_BUILD_PLATFORM not set"; exit 1; fi
|
|
|
|
if [[ -z ${BSH_HOST_ARCH-} ]]; then >&2 echo "BSH_HOST_ARCH not set"; exit 1; fi
|
|
|
|
if [[ -z ${BSH_HOST_PLATFORM-} ]]; then >&2 echo "BSH_HOST_PLATFORM not set"; exit 1; fi
|
|
|
|
if [[ -z ${BSH_HOST_LIBC-} ]]; then >&2 echo "BSH_HOST_LIBC not set"; exit 1; fi
|
|
|
|
if [[ -z ${BSH_STATIC_DYNAMIC-} ]]; then >&2 echo "BSH_STATIC_DYNAMIC not set"; exit 1; fi
|
|
|
|
if [[ -z ${BSH_DEBUG_RELEASE-} ]]; then >&2 echo "BSH_DEBUG_RELEASE not set"; exit 1; fi
|
|
|
|
if [[ -z ${RELEASE_NAME-} ]]; then >&2 echo "RELEASE_NAME not set"; exit 1; fi
|
|
|
|
if [[ -z ${RELEASE_TYPE-} ]]; then >&2 echo "RELEASE_TYPE not set"; exit 1; fi
|
|
|
|
if [[ -z ${MOD_ID-} ]]; then >&2 echo "MOD_ID not set"; exit 1; fi
|
|
|
|
if [[ -z ${SEPARATE_DEBUG-} ]]; then >&2 echo "SEPARATE_DEBUG not set"; exit 1; fi
|
|
|
|
if [[ -z ${PACKAGE_MODE-} ]]; then >&2 echo "PACKAGE_MODE not set"; exit 1; fi
|
|
|
|
if [[ -z ${ASSET_PATH-} ]]; then >&2 echo "ASSET_PATH not set"; exit 1; fi
|
|
|
|
if [[ -z ${DEBUG_ASSET_PATH-} ]]; then >&2 echo "DEBUG_ASSET_PATH not set"; exit 1; fi
|
|
|
|
if [[ -z ${APP_NAME-} ]]; then >&2 echo "APP_NAME not set"; exit 1; fi
|
|
|
|
if [[ -z ${APP_COMMENT-} ]]; then >&2 echo "APP_COMMENT not set"; exit 1; fi
|
|
|
|
if [[ -z ${APP_EXE-} ]]; then >&2 echo "APP_EXE not set"; exit 1; fi
|
|
|
|
if [[ -z ${APP_ID-} ]]; then >&2 echo "APP_ID not set"; exit 1; fi
|
|
|
|
if [[ -z ${APP_DATA-} ]]; then >&2 echo "APP_DATA not set"; exit 1; fi
|
|
|
|
if [[ -z ${APP_VENDOR-} ]]; then >&2 echo "APP_VENDOR not set"; exit 1; fi
|
2019-12-17 08:03:41 -06:00
|
|
|
|
2022-08-23 04:14:06 -05:00
|
|
|
case $BSH_HOST_ARCH-$BSH_HOST_PLATFORM-$BSH_HOST_LIBC-$BSH_STATIC_DYNAMIC in
|
|
|
|
x86_64-linux-gnu-static) ;;
|
|
|
|
x86_64-linux-gnu-dynamic) ;;
|
|
|
|
x86_64-windows-mingw-static) ;;
|
|
|
|
x86_64-windows-mingw-dynamic) ;;
|
|
|
|
x86_64-windows-msvc-static) ;;
|
|
|
|
x86_64-windows-msvc-dynamic) ;;
|
|
|
|
x86-windows-msvc-static) ;;
|
|
|
|
x86-windows-msvc-dynamic) ;;
|
|
|
|
x86_64-darwin-macos-static) ;;
|
|
|
|
x86_64-darwin-macos-dynamic) ;;
|
|
|
|
aarch64-darwin-macos-static) ;;
|
|
|
|
aarch64-darwin-macos-dynamic) ;;
|
|
|
|
x86-android-bionic-static) ;;
|
|
|
|
x86_64-android-bionic-static) ;;
|
|
|
|
arm-android-bionic-static) ;;
|
|
|
|
aarch64-android-bionic-static) ;;
|
2023-01-24 11:37:06 -06:00
|
|
|
wasm32-emscripten-emscripten-static) ;;
|
2022-08-23 04:14:06 -05:00
|
|
|
*) >&2 echo "configuration $BSH_HOST_ARCH-$BSH_HOST_PLATFORM-$BSH_HOST_LIBC-$BSH_STATIC_DYNAMIC is not supported" && exit 1;;
|
|
|
|
esac
|
|
|
|
|
2023-01-04 06:48:43 -06:00
|
|
|
if [[ -z ${BSH_NO_PACKAGES-} ]]; then
|
2023-01-24 11:37:06 -06:00
|
|
|
case $BSH_HOST_PLATFORM in
|
|
|
|
windows)
|
|
|
|
if [[ $BSH_BUILD_PLATFORM == linux ]] && [[ $BSH_HOST_LIBC == mingw ]]; then
|
|
|
|
sudo apt update
|
|
|
|
sudo apt install g++-mingw-w64-x86-64
|
|
|
|
fi
|
|
|
|
;;
|
2023-01-04 06:48:43 -06:00
|
|
|
linux)
|
|
|
|
sudo apt update
|
|
|
|
if [[ $BSH_STATIC_DYNAMIC == static ]]; then
|
|
|
|
sudo apt install libc6-dev libc6-dev-i386
|
|
|
|
else
|
|
|
|
sudo apt install libluajit-5.1-dev libcurl4-openssl-dev libfftw3-dev zlib1g-dev libsdl2-dev libbz2-dev libjsoncpp-dev
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
darwin)
|
|
|
|
brew install pkg-config binutils
|
|
|
|
if [[ $BSH_STATIC_DYNAMIC != static ]]; then
|
|
|
|
brew install luajit curl fftw zlib sdl2 bzip2 jsoncpp
|
|
|
|
fi
|
|
|
|
;;
|
2023-01-24 11:37:06 -06:00
|
|
|
emscripten)
|
|
|
|
git clone https://github.com/emscripten-core/emsdk.git --branch 3.1.30
|
|
|
|
cd emsdk
|
|
|
|
./emsdk install latest
|
|
|
|
./emsdk activate latest
|
|
|
|
. ./emsdk_env.sh
|
|
|
|
cd ..
|
|
|
|
;;
|
2023-01-04 06:48:43 -06:00
|
|
|
esac
|
|
|
|
fi
|
2023-01-01 10:33:39 -06:00
|
|
|
|
2022-12-19 15:08:02 -06:00
|
|
|
function inplace_sed() {
|
|
|
|
local subst=$1
|
|
|
|
local path=$2
|
|
|
|
if [[ $BSH_BUILD_PLATFORM == darwin ]]; then
|
|
|
|
sed -i "" -e $subst $path
|
|
|
|
else
|
|
|
|
sed -i $subst $path
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $BSH_HOST_PLATFORM == android ]]; then
|
|
|
|
android_platform=android-30
|
|
|
|
if [[ -z "${JAVA_HOME_8_X64-}" ]]; then
|
|
|
|
>&2 echo "JAVA_HOME_8_X64 not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [[ -z "${ANDROID_SDK_ROOT-}" ]]; then
|
|
|
|
>&2 echo "ANDROID_SDK_ROOT not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [[ -z "${ANDROID_NDK_LATEST_HOME-}" ]]; then
|
|
|
|
>&2 echo "ANDROID_NDK_LATEST_HOME not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $BSH_HOST_PLATFORM-$BSH_HOST_LIBC == windows-msvc ]]; then
|
|
|
|
case $BSH_HOST_ARCH in
|
|
|
|
x86_64) vs_env_arch=x64;;
|
|
|
|
x86) vs_env_arch=x86;;
|
|
|
|
esac
|
2022-10-28 12:20:09 -05:00
|
|
|
VS_ENV_PARAMS=$vs_env_arch$'\t'-vcvars_ver=14.1
|
|
|
|
. ./.github/vs-env.sh
|
2022-08-23 04:14:06 -05:00
|
|
|
elif [[ $BSH_HOST_PLATFORM == darwin ]]; then
|
|
|
|
# may need export SDKROOT=$(xcrun --show-sdk-path --sdk macosx11.1)
|
|
|
|
CC=clang
|
|
|
|
CXX=clang++
|
|
|
|
if [[ $BSH_HOST_ARCH == aarch64 ]]; then
|
2022-12-23 09:09:10 -06:00
|
|
|
macos_min_ver=11.0
|
2022-08-23 04:14:06 -05:00
|
|
|
CC+=" -arch arm64"
|
|
|
|
CXX+=" -arch arm64"
|
2019-12-17 08:03:41 -06:00
|
|
|
else
|
2022-12-23 09:09:10 -06:00
|
|
|
macos_min_ver=10.13
|
2022-08-23 04:14:06 -05:00
|
|
|
CC+=" -arch x86_64"
|
|
|
|
CXX+=" -arch x86_64"
|
2019-12-17 08:03:41 -06:00
|
|
|
fi
|
2022-12-23 09:09:10 -06:00
|
|
|
if [[ $BSH_STATIC_DYNAMIC == static ]]; then
|
|
|
|
export MACOSX_DEPLOYMENT_TARGET=$macos_min_ver
|
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
export CC
|
|
|
|
export CXX
|
|
|
|
elif [[ $BSH_HOST_PLATFORM == android ]]; then
|
|
|
|
case $BSH_HOST_ARCH in
|
|
|
|
x86_64) android_toolchain_prefix=x86_64-linux-android ; android_system_version=21; android_arch_abi=x86_64 ;;
|
2023-10-01 03:53:59 -05:00
|
|
|
x86) android_toolchain_prefix=i686-linux-android ; android_system_version=21; android_arch_abi=x86 ;;
|
2022-08-23 04:14:06 -05:00
|
|
|
aarch64) android_toolchain_prefix=aarch64-linux-android ; android_system_version=21; android_arch_abi=arm64-v8a ;;
|
2023-10-01 03:53:59 -05:00
|
|
|
arm) android_toolchain_prefix=armv7a-linux-androideabi; android_system_version=21; android_arch_abi=armeabi-v7a;;
|
2022-08-23 04:14:06 -05:00
|
|
|
esac
|
|
|
|
android_toolchain_dir=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64
|
|
|
|
CC=$android_toolchain_dir/bin/$android_toolchain_prefix$android_system_version-clang
|
|
|
|
CXX=$android_toolchain_dir/bin/$android_toolchain_prefix$android_system_version-clang++
|
|
|
|
LD=$android_toolchain_dir/bin/$android_toolchain_prefix-ld
|
|
|
|
AR=$android_toolchain_dir/bin/llvm-ar
|
|
|
|
echo $AR
|
|
|
|
CC+=" -fPIC"
|
|
|
|
CXX+=" -fPIC"
|
|
|
|
LD+=" -fPIC"
|
|
|
|
export CC
|
|
|
|
export CXX
|
|
|
|
export LD
|
|
|
|
export AR
|
|
|
|
else
|
|
|
|
export CC=gcc
|
|
|
|
export CXX=g++
|
2019-12-17 08:03:41 -06:00
|
|
|
fi
|
|
|
|
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ -d build ]]; then
|
2022-04-11 14:11:03 -05:00
|
|
|
rm -r build
|
|
|
|
fi
|
|
|
|
|
2022-10-06 00:41:08 -05:00
|
|
|
c_args=
|
|
|
|
c_link_args=
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $BSH_HOST_PLATFORM-$BSH_HOST_LIBC != windows-msvc ]]; then
|
2022-10-06 00:41:08 -05:00
|
|
|
c_args+=\'-ffunction-sections\',
|
|
|
|
c_args+=\'-fdata-sections\',
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $BSH_HOST_PLATFORM == darwin ]]; then
|
2022-10-06 00:41:08 -05:00
|
|
|
c_link_args+=\'-Wl,-dead_strip\',
|
2022-08-23 04:14:06 -05:00
|
|
|
else
|
2022-10-06 00:41:08 -05:00
|
|
|
c_link_args+=\'-Wl,--gc-sections\',
|
2021-01-21 12:08:27 -06:00
|
|
|
fi
|
2019-12-17 08:03:41 -06:00
|
|
|
fi
|
2022-10-11 06:08:42 -05:00
|
|
|
if [[ $BSH_HOST_PLATFORM-$BSH_STATIC_DYNAMIC == darwin-static ]]; then
|
2022-12-23 09:09:10 -06:00
|
|
|
c_args+=\'-mmacosx-version-min=$macos_min_ver\',
|
|
|
|
c_link_args+=\'-mmacosx-version-min=$macos_min_ver\',
|
2022-10-06 00:41:08 -05:00
|
|
|
fi
|
|
|
|
|
2022-11-08 14:00:47 -06:00
|
|
|
meson_configure=meson$'\t'setup
|
2022-10-06 00:41:08 -05:00
|
|
|
if [[ $BSH_DEBUG_RELEASE == release ]]; then
|
|
|
|
meson_configure+=$'\t'-Dbuildtype=debugoptimized
|
|
|
|
fi
|
Sort out version info
The idea is to have the following version information included:
- 1-component save version
- 2-component under the hood but the minor component shouldn't ever change again
- see currentVersionMajor in GameSave.cpp
- 1-component website API version
- again, currently 2-component because that's what the website code expects
- see apiVersion in requestmanager/Common.cpp
- 2-component display version, entirely cosmetic
- exposed as meson options display_version_major and display_version_minor
- see APP_VERSION in Config.template.h
- 1-component business logic version aka build number
- exposed as meson option build_num
- see APP_VERSION in Config.template.h
- variant id aka mod id, tightly coupled with the build number
- exposed as meson option mod_id
- see MOD_ID in Config.template.h
- display and business logic versions repeated for the upstream
- exposed as meson options upstream_version_major, upstream_version_minor, and upstream_build_num
- we'll have to update these alongside display_version_major, display_version_minor, and build_num, but mod owners can just merge our changes
- see UPSTREAM_VERSION in Config.template.h
- update channel, makes sense in the context of the variant (and yes, this would later enable mod snapshots)
- currently not exposed as a meson option but derived from meson options snapshot and mod_id
- see IDENT_RELTYPE in Config.template.h
- vcs tag aka git commit hash
- set by build.sh in ghactions workflows
- see VCS_TAG in VcsTag.tempalte.h
Rather importantly, the save and website API versions are now allowed to change independently of the display version.
These changes also allowed me to remove the ugly sed hacks in build.sh used to provision some manifest files; they are now provisioned by meson.
Also add version info for windows and android.
2023-10-19 03:48:10 -05:00
|
|
|
if [[ $BSH_HOST_PLATFORM == darwin ]]; then
|
|
|
|
meson_configure+=$'\t'-Dmanifest_macos_min_ver=$macos_min_ver
|
|
|
|
else
|
|
|
|
meson_configure+=$'\t'-Dmanifest_date=$(date --iso-8601)
|
|
|
|
fi
|
2022-12-27 11:41:23 -06:00
|
|
|
meson_configure+=$'\t'-Dapp_name=$APP_NAME
|
|
|
|
meson_configure+=$'\t'-Dapp_comment=$APP_COMMENT
|
|
|
|
meson_configure+=$'\t'-Dapp_exe=$APP_EXE
|
|
|
|
meson_configure+=$'\t'-Dapp_id=$APP_ID
|
|
|
|
meson_configure+=$'\t'-Dapp_data=$APP_DATA
|
|
|
|
meson_configure+=$'\t'-Dapp_vendor=$APP_VENDOR
|
2022-10-06 00:41:08 -05:00
|
|
|
meson_configure+=$'\t'-Db_strip=false
|
2022-08-23 04:14:06 -05:00
|
|
|
meson_configure+=$'\t'-Db_staticpic=false
|
|
|
|
meson_configure+=$'\t'-Dmod_id=$MOD_ID
|
2022-12-18 12:08:44 -06:00
|
|
|
case $BSH_HOST_ARCH-$BSH_HOST_PLATFORM-$BSH_HOST_LIBC-$BSH_DEBUG_RELEASE in
|
|
|
|
x86_64-linux-gnu-debug) ;&
|
|
|
|
x86_64-windows-mingw-debug) ;&
|
|
|
|
x86_64-windows-msvc-debug) ;&
|
|
|
|
x86_64-darwin-macos-debug)
|
2022-08-23 04:14:06 -05:00
|
|
|
meson_configure+=$'\t'-Dbuild_render=true
|
|
|
|
meson_configure+=$'\t'-Dbuild_font=true
|
2022-12-18 12:08:44 -06:00
|
|
|
;;
|
|
|
|
esac
|
2023-01-14 12:13:22 -06:00
|
|
|
if [[ $PACKAGE_MODE == nohttp ]]; then
|
|
|
|
meson_configure+=$'\t'-Dhttp=false
|
|
|
|
fi
|
|
|
|
if [[ $PACKAGE_MODE == nolua ]]; then
|
|
|
|
meson_configure+=$'\t'-Dlua=none
|
|
|
|
fi
|
2023-12-03 10:32:33 -06:00
|
|
|
if [[ $PACKAGE_MODE == backendvs ]]; then
|
|
|
|
meson_configure+=$'\t'-Dbackend=vs
|
|
|
|
echo "NOTE: patching CREATEPROCESS_MANIFEST_RESOURCE_ID out of powder-res.template.rc"
|
|
|
|
echo "TODO: remove this patch once https://github.com/mesonbuild/meson/pull/12472 makes it into a release"
|
|
|
|
echo "TODO: also remove the relevant note from the building guide"
|
|
|
|
git apply <<PATCH
|
|
|
|
diff --git a/resources/powder-res.template.rc b/resources/powder-res.template.rc
|
|
|
|
index 1dc26c78..2094049f 100644
|
|
|
|
--- a/resources/powder-res.template.rc
|
|
|
|
+++ b/resources/powder-res.template.rc
|
|
|
|
@@ -7,7 +7,6 @@
|
|
|
|
|
|
|
|
IDI_ICON ICON DISCARDABLE "@ICON_EXE_ICO@"
|
|
|
|
IDI_DOC_ICON ICON DISCARDABLE "@ICON_CPS_ICO@"
|
|
|
|
-CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "@WINUTF8_XML@"
|
|
|
|
|
|
|
|
VS_VERSION_INFO VERSIONINFO
|
|
|
|
FILEVERSION @DISPLAY_VERSION_MAJOR@,@DISPLAY_VERSION_MINOR@,0,@BUILD_NUM@
|
|
|
|
PATCH
|
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $BSH_STATIC_DYNAMIC == static ]]; then
|
|
|
|
meson_configure+=$'\t'-Dstatic=prebuilt
|
|
|
|
if [[ $BSH_HOST_PLATFORM == windows ]]; then
|
2022-10-06 00:41:08 -05:00
|
|
|
if [[ $BSH_HOST_LIBC == msvc ]]; then
|
|
|
|
meson_configure+=$'\t'-Db_vscrt=static_from_buildtype
|
|
|
|
else
|
|
|
|
c_link_args+=\'-static\',
|
|
|
|
c_link_args+=\'-static-libgcc\',
|
|
|
|
c_link_args+=\'-static-libstdc++\',
|
|
|
|
fi
|
|
|
|
elif [[ $BSH_HOST_PLATFORM == linux ]]; then
|
|
|
|
c_link_args+=\'-static-libgcc\',
|
|
|
|
c_link_args+=\'-static-libstdc++\',
|
2022-08-23 04:14:06 -05:00
|
|
|
fi
|
2022-10-11 06:08:42 -05:00
|
|
|
else
|
|
|
|
if [[ $BSH_BUILD_PLATFORM == linux ]]; then
|
|
|
|
meson_configure+=$'\t'-Dworkaround_elusive_bzip2=true
|
|
|
|
fi
|
|
|
|
if [[ $BSH_BUILD_PLATFORM == darwin ]]; then
|
|
|
|
meson_configure+=$'\t'-Dworkaround_elusive_bzip2=true
|
|
|
|
meson_configure+=$'\t'-Dworkaround_elusive_bzip2_lib_dir=/usr/local/opt/bzip2/lib
|
|
|
|
meson_configure+=$'\t'-Dworkaround_elusive_bzip2_include_dir=/usr/local/opt/bzip2/include
|
|
|
|
meson_configure+=$'\t'-Dworkaround_elusive_bzip2_static=true
|
|
|
|
fi
|
2022-04-11 14:11:03 -05:00
|
|
|
fi
|
2022-10-06 00:41:08 -05:00
|
|
|
if [[ $BSH_HOST_PLATFORM == linux ]] && [[ $BSH_HOST_ARCH != aarch64 ]]; then
|
|
|
|
# certain file managers can't run PIEs https://bugzilla.gnome.org/show_bug.cgi?id=737849
|
|
|
|
meson_configure+=$'\t'-Db_pie=false
|
|
|
|
c_link_args+=\'-no-pie\',
|
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
stable_or_beta=no
|
|
|
|
if [[ $RELEASE_TYPE == beta ]]; then
|
|
|
|
meson_configure+=$'\t'-Dbeta=true
|
|
|
|
stable_or_beta=yes
|
2021-06-30 15:13:24 -05:00
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $RELEASE_TYPE == stable ]]; then
|
|
|
|
stable_or_beta=yes
|
2021-06-30 15:13:24 -05:00
|
|
|
fi
|
Sort out version info
The idea is to have the following version information included:
- 1-component save version
- 2-component under the hood but the minor component shouldn't ever change again
- see currentVersionMajor in GameSave.cpp
- 1-component website API version
- again, currently 2-component because that's what the website code expects
- see apiVersion in requestmanager/Common.cpp
- 2-component display version, entirely cosmetic
- exposed as meson options display_version_major and display_version_minor
- see APP_VERSION in Config.template.h
- 1-component business logic version aka build number
- exposed as meson option build_num
- see APP_VERSION in Config.template.h
- variant id aka mod id, tightly coupled with the build number
- exposed as meson option mod_id
- see MOD_ID in Config.template.h
- display and business logic versions repeated for the upstream
- exposed as meson options upstream_version_major, upstream_version_minor, and upstream_build_num
- we'll have to update these alongside display_version_major, display_version_minor, and build_num, but mod owners can just merge our changes
- see UPSTREAM_VERSION in Config.template.h
- update channel, makes sense in the context of the variant (and yes, this would later enable mod snapshots)
- currently not exposed as a meson option but derived from meson options snapshot and mod_id
- see IDENT_RELTYPE in Config.template.h
- vcs tag aka git commit hash
- set by build.sh in ghactions workflows
- see VCS_TAG in VcsTag.tempalte.h
Rather importantly, the save and website API versions are now allowed to change independently of the display version.
These changes also allowed me to remove the ugly sed hacks in build.sh used to provision some manifest files; they are now provisioned by meson.
Also add version info for windows and android.
2023-10-19 03:48:10 -05:00
|
|
|
if [[ $stable_or_beta == yes ]]; then
|
2023-10-23 11:05:17 -05:00
|
|
|
xyz=$(echo $RELEASE_NAME | cut -d 'v' -f 2 | cut -d 'b' -f 1) # $RELEASE_NAME is vX.Y.Z or vX.Y.Zb
|
2023-10-26 13:00:40 -05:00
|
|
|
display_version_major=$(echo $xyz | cut -d '.' -f 1)
|
|
|
|
display_version_minor=$(echo $xyz | cut -d '.' -f 2)
|
|
|
|
build_num=$(echo $xyz | cut -d '.' -f 3)
|
|
|
|
if [[ $MOD_ID != 0 ]]; then
|
|
|
|
meson_configure+=$'\t'-Ddisplay_version_major=$display_version_major
|
|
|
|
meson_configure+=$'\t'-Ddisplay_version_minor=$display_version_minor
|
|
|
|
meson_configure+=$'\t'-Dbuild_num=$build_num
|
|
|
|
fi
|
2022-10-22 14:51:12 -05:00
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $RELEASE_TYPE == snapshot ]]; then
|
2023-10-26 13:00:40 -05:00
|
|
|
build_num=$(echo $RELEASE_NAME | cut -d '-' -f 2) # $RELEASE_NAME is snapshot-X
|
2022-08-23 04:14:06 -05:00
|
|
|
meson_configure+=$'\t'-Dsnapshot=true
|
2023-10-26 13:00:40 -05:00
|
|
|
if [[ $MOD_ID != 0 ]]; then
|
|
|
|
meson_configure+=$'\t'-Dbuild_num=$build_num
|
|
|
|
fi
|
2021-04-04 15:09:16 -05:00
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $RELEASE_TYPE == snapshot ]] && [[ $MOD_ID != 0 ]]; then
|
2021-04-16 16:20:38 -05:00
|
|
|
>&2 echo "mods and snapshots do not mix"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $RELEASE_TYPE == snapshot ]] || [[ $MOD_ID != 0 ]]; then
|
|
|
|
meson_configure+=$'\t'-Dupdate_server=starcatcher.us/TPT
|
2020-12-15 15:02:56 -06:00
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $RELEASE_TYPE != dev ]]; then
|
|
|
|
meson_configure+=$'\t'-Dignore_updates=false
|
2021-04-16 16:20:38 -05:00
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $BSH_HOST_PLATFORM-$BSH_HOST_LIBC == windows-mingw ]]; then
|
2022-10-19 07:32:54 -05:00
|
|
|
if [[ $BSH_BUILD_PLATFORM == linux ]]; then
|
2022-08-23 04:14:06 -05:00
|
|
|
meson_configure+=$'\t'--cross-file=.github/mingw-ghactions.ini
|
2021-12-24 10:43:44 -06:00
|
|
|
fi
|
2022-10-20 23:22:07 -05:00
|
|
|
fi
|
|
|
|
if [[ $BSH_HOST_PLATFORM-$BSH_HOST_LIBC != windows-mingw ]] && [[ $BSH_STATIC_DYNAMIC == static ]]; then
|
2022-08-23 04:14:06 -05:00
|
|
|
# LTO simply doesn't work with MinGW. I have no idea why and I also don't care.
|
2022-10-20 23:22:07 -05:00
|
|
|
# It also has a tendency to not play well with dynamic libraries.
|
2022-08-23 04:14:06 -05:00
|
|
|
meson_configure+=$'\t'-Db_lto=true
|
2021-10-22 09:38:42 -05:00
|
|
|
fi
|
2022-10-11 06:08:42 -05:00
|
|
|
if [[ $BSH_HOST_PLATFORM-$BSH_HOST_ARCH == darwin-aarch64 ]]; then
|
|
|
|
meson_configure+=$'\t'--cross-file=.github/macaa64-ghactions.ini
|
2022-08-23 04:14:06 -05:00
|
|
|
fi
|
2023-01-24 11:37:06 -06:00
|
|
|
if [[ $BSH_HOST_PLATFORM == emscripten ]]; then
|
|
|
|
meson_configure+=$'\t'--cross-file=.github/emscripten-ghactions.ini
|
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $RELEASE_TYPE == tptlibsdev ]] && ([[ $BSH_HOST_PLATFORM == windows ]] || [[ $BSH_STATIC_DYNAMIC == static ]]); then
|
2023-01-01 10:33:39 -06:00
|
|
|
if [[ -z ${TPTLIBSREMOTE-} ]]; then
|
|
|
|
if [[ -z "${GITHUB_REPOSITORY_OWNER-}" ]]; then
|
|
|
|
>&2 echo "GITHUB_REPOSITORY_OWNER not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
tptlibsremote=https://github.com/$GITHUB_REPOSITORY_OWNER/tpt-libs
|
|
|
|
else
|
|
|
|
tptlibsremote=$TPTLIBSREMOTE
|
2022-04-11 14:11:03 -05:00
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ "$BSH_HOST_ARCH-$BSH_HOST_PLATFORM-$BSH_HOST_LIBC-$BSH_STATIC_DYNAMIC $BSH_BUILD_PLATFORM" == "x86_64-windows-mingw-dynamic linux" ]]; then
|
|
|
|
>&2 echo "this configuration is not supported in tptlibsdev mode"
|
|
|
|
touch $ASSET_PATH
|
|
|
|
exit 0
|
2022-04-11 14:11:03 -05:00
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
tptlibsbranch=$(echo $RELEASE_NAME | cut -d '-' -f 2-) # $RELEASE_NAME is tptlibsdev-BRANCH
|
2023-01-01 10:33:39 -06:00
|
|
|
if [[ -d build-tpt-libs ]] && [[ ${TPTLIBSRESET-} == yes ]]; then
|
|
|
|
rm -rf build-tpt-libs
|
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ ! -d build-tpt-libs/tpt-libs ]]; then
|
|
|
|
mkdir -p build-tpt-libs
|
|
|
|
cd build-tpt-libs
|
2023-01-01 10:33:39 -06:00
|
|
|
git clone $tptlibsremote --branch $tptlibsbranch --depth 1
|
2022-04-09 08:01:23 -05:00
|
|
|
cd ..
|
|
|
|
fi
|
2022-04-11 14:11:03 -05:00
|
|
|
tpt_libs_vtag=v00000000000000
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ ! -f build-tpt-libs/tpt-libs/.ok ]]; then
|
|
|
|
cd build-tpt-libs/tpt-libs
|
2022-10-28 12:20:09 -05:00
|
|
|
BSH_VTAG=$tpt_libs_vtag ./.github/build.sh
|
2022-04-11 14:11:03 -05:00
|
|
|
touch .ok
|
2022-08-23 04:14:06 -05:00
|
|
|
cd ../../subprojects
|
|
|
|
for i in tpt-libs-prebuilt-*; do
|
|
|
|
if [[ -d $i ]]; then
|
|
|
|
rm -r $i
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
7z x ../build-tpt-libs/tpt-libs/temp/libraries.zip
|
|
|
|
cd ..
|
2022-07-31 00:54:28 -05:00
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
meson_configure+=$'\t'-Dtpt_libs_vtag=$tpt_libs_vtag
|
|
|
|
fi
|
|
|
|
if [[ $BSH_HOST_PLATFORM == android ]]; then
|
|
|
|
android_platform=android-30
|
|
|
|
meson_configure+=$'\t'--cross-file=android/cross/$BSH_HOST_ARCH.ini
|
2022-07-31 00:54:28 -05:00
|
|
|
cat << ANDROID_INI > .github/android-ghactions.ini
|
|
|
|
[constants]
|
|
|
|
andriod_ndk_toolchain_bin = '$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin'
|
|
|
|
andriod_sdk_build_tools = '$ANDROID_SDK_ROOT/build-tools/32.0.0'
|
|
|
|
|
|
|
|
[properties]
|
2022-08-23 04:14:06 -05:00
|
|
|
# android_ndk_toolchain_prefix comes from the correct cross-file in ./android/cross
|
|
|
|
android_ndk_toolchain_prefix = android_ndk_toolchain_prefix
|
|
|
|
android_platform = '$android_platform'
|
|
|
|
android_platform_jar = '$ANDROID_SDK_ROOT/platforms/' + android_platform + '/android.jar'
|
|
|
|
java_runtime_jar = '$JAVA_HOME_8_X64/jre/lib/rt.jar'
|
2022-07-31 00:54:28 -05:00
|
|
|
|
|
|
|
[binaries]
|
|
|
|
# android_ndk_toolchain_prefix comes from the correct cross-file in ./android/cross
|
|
|
|
c = andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang')
|
|
|
|
cpp = andriod_ndk_toolchain_bin / (android_ndk_toolchain_prefix + 'clang++')
|
|
|
|
strip = andriod_ndk_toolchain_bin / 'llvm-strip'
|
2022-08-23 04:14:06 -05:00
|
|
|
javac = '$JAVA_HOME_8_X64/bin/javac'
|
|
|
|
jar = '$JAVA_HOME_8_X64/bin/jar'
|
2022-07-31 00:54:28 -05:00
|
|
|
d8 = andriod_sdk_build_tools / 'd8'
|
|
|
|
aapt = andriod_sdk_build_tools / 'aapt'
|
|
|
|
aapt2 = andriod_sdk_build_tools / 'aapt2'
|
|
|
|
zipalign = andriod_sdk_build_tools / 'zipalign'
|
|
|
|
apksigner = andriod_sdk_build_tools / 'apksigner'
|
|
|
|
ANDROID_INI
|
2022-08-23 04:14:06 -05:00
|
|
|
meson_configure+=$'\t'--cross-file=.github/android-ghactions.ini
|
2022-04-09 08:01:23 -05:00
|
|
|
fi
|
2022-10-06 00:41:08 -05:00
|
|
|
meson_configure+=$'\t'-Dc_args=[$c_args]
|
|
|
|
meson_configure+=$'\t'-Dcpp_args=[$c_args]
|
|
|
|
meson_configure+=$'\t'-Dc_link_args=[$c_link_args]
|
|
|
|
meson_configure+=$'\t'-Dcpp_link_args=[$c_link_args]
|
2022-08-23 04:14:06 -05:00
|
|
|
$meson_configure build
|
2019-12-17 08:03:41 -06:00
|
|
|
cd build
|
2023-10-26 13:00:40 -05:00
|
|
|
|
|
|
|
function verify_version_component() {
|
|
|
|
local key=$1
|
|
|
|
local expected=$2
|
|
|
|
local actual=$(jq -r '.[] | select(.name == "'$key'") | .value' < meson-info/intro-buildoptions.json)
|
|
|
|
if [[ $actual != $expected ]]; then
|
|
|
|
>&2 echo "meson option $key expected to be $expected, is instead $actual"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
if [[ $stable_or_beta == yes ]] && [[ $MOD_ID == 0 ]]; then
|
|
|
|
verify_version_component display_version_major $display_version_major
|
|
|
|
verify_version_component display_version_minor $display_version_minor
|
|
|
|
verify_version_component build_num $build_num
|
|
|
|
verify_version_component upstream_version_major $display_version_major
|
|
|
|
verify_version_component upstream_version_minor $display_version_minor
|
|
|
|
verify_version_component upstream_build_num $build_num
|
|
|
|
fi
|
|
|
|
if [[ $RELEASE_TYPE == snapshot ]] && [[ $MOD_ID == 0 ]]; then
|
|
|
|
verify_version_component build_num $build_num
|
|
|
|
verify_version_component upstream_build_num $build_num
|
|
|
|
fi
|
|
|
|
|
2022-11-03 01:05:31 -05:00
|
|
|
strip=strip
|
|
|
|
objcopy=objcopy
|
|
|
|
strip_target=$ASSET_PATH
|
|
|
|
if [[ $BSH_HOST_PLATFORM == android ]]; then
|
|
|
|
strip=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-$strip
|
|
|
|
objcopy=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-$objcopy
|
2022-12-17 06:53:37 -06:00
|
|
|
strip_target=lib$APP_EXE.so
|
2022-11-03 01:05:31 -05:00
|
|
|
fi
|
|
|
|
if [[ $PACKAGE_MODE == appimage ]]; then
|
|
|
|
# so far this can only happen with $BSH_HOST_PLATFORM-$BSH_HOST_LIBC == linux-gnu, but this may change later
|
2023-01-25 02:30:43 -06:00
|
|
|
meson configure -Dcan_install=no -Dignore_updates=true -Dbuild_render=false -Dbuild_font=false
|
2022-12-17 06:53:37 -06:00
|
|
|
strip_target=$APP_EXE
|
2022-11-03 01:05:31 -05:00
|
|
|
fi
|
2023-12-03 10:32:33 -06:00
|
|
|
meson_compile=meson$'\t'compile
|
|
|
|
meson_compile+=$'\t'-v
|
|
|
|
if [[ $BSH_BUILD_PLATFORM == windows ]] && [[ $PACKAGE_MODE != backendvs ]]; then
|
2022-09-11 04:55:01 -05:00
|
|
|
set +e
|
2023-12-03 10:32:33 -06:00
|
|
|
meson_compile+=$'\t'--ninja-args='["-d","keeprsp"]'
|
|
|
|
$meson_compile
|
2022-09-11 04:55:01 -05:00
|
|
|
ninja_code=$?
|
|
|
|
set -e
|
2022-12-17 06:53:37 -06:00
|
|
|
cat $APP_EXE.exe.rsp
|
2022-09-11 04:55:01 -05:00
|
|
|
[[ $ninja_code == 0 ]];
|
2023-02-05 06:33:26 -06:00
|
|
|
echo # rsps don't usually have a newline at the end
|
|
|
|
if [[ "$BSH_HOST_PLATFORM-$BSH_STATIC_DYNAMIC $BSH_BUILD_PLATFORM" == "windows-dynamic windows" ]]; then
|
|
|
|
# on windows we provide the dynamic dependencies also; makes sense to check for their presence
|
|
|
|
# msys ldd works fine but only on windows build machines
|
|
|
|
if ldd $APP_EXE | grep "not found"; then
|
|
|
|
exit 1 # ldd | grep will have printed missing deps
|
|
|
|
fi
|
|
|
|
fi
|
2022-09-11 04:55:01 -05:00
|
|
|
else
|
2023-12-03 10:32:33 -06:00
|
|
|
$meson_compile
|
2022-09-11 04:55:01 -05:00
|
|
|
fi
|
2022-10-23 23:41:12 -05:00
|
|
|
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $SEPARATE_DEBUG == yes ]] && [[ $BSH_HOST_PLATFORM-$BSH_HOST_LIBC != windows-msvc ]]; then
|
2022-11-03 01:05:31 -05:00
|
|
|
$objcopy --only-keep-debug $strip_target $DEBUG_ASSET_PATH
|
|
|
|
$strip --strip-debug --strip-unneeded $strip_target
|
|
|
|
$objcopy --add-gnu-debuglink $DEBUG_ASSET_PATH $strip_target
|
|
|
|
chmod -x $DEBUG_ASSET_PATH
|
2022-04-11 14:11:03 -05:00
|
|
|
fi
|
2022-08-23 04:14:06 -05:00
|
|
|
if [[ $BSH_HOST_PLATFORM == android ]]; then
|
2022-04-11 14:11:03 -05:00
|
|
|
$JAVA_HOME_8_X64/bin/keytool -genkeypair -keystore keystore.jks -alias androidkey -validity 10000 -keyalg RSA -keysize 2048 -keypass bagelsbagels -storepass bagelsbagels -dname "CN=nobody"
|
2022-08-23 04:14:06 -05:00
|
|
|
meson configure -Dandroid_keystore=$(realpath keystore.jks)
|
2022-12-17 06:53:37 -06:00
|
|
|
ANDROID_KEYSTORE_PASS=bagelsbagels ninja android/$APP_EXE.apk
|
|
|
|
mv android/$APP_EXE.apk $APP_EXE.apk
|
2020-12-15 15:02:56 -06:00
|
|
|
fi
|
2022-12-19 15:08:02 -06:00
|
|
|
if [[ $PACKAGE_MODE == dmg ]]; then
|
|
|
|
# so far this can only happen with $BSH_HOST_PLATFORM-$BSH_HOST_LIBC == darwin-macos
|
|
|
|
appdir=$APP_NAME.app
|
|
|
|
mkdir $appdir
|
|
|
|
mkdir $appdir/Contents
|
|
|
|
cp resources/Info.plist $appdir/Contents/Info.plist
|
|
|
|
mkdir $appdir/Contents/MacOS
|
|
|
|
cp $APP_EXE $appdir/Contents/MacOS/$APP_EXE
|
|
|
|
mkdir $appdir/Contents/Resources
|
|
|
|
mkdir icon_exe.iconset
|
|
|
|
cp ../resources/generated_icons/icon_exe_16.png icon_exe.iconset/icon_16x16.png
|
|
|
|
cp ../resources/generated_icons/icon_exe_32.png icon_exe.iconset/icon_32x32.png
|
|
|
|
cp ../resources/generated_icons/icon_exe.png icon_exe.iconset/icon_128x128.png
|
|
|
|
iconutil -c icns icon_exe.iconset
|
|
|
|
cp icon_exe.icns $appdir/Contents/Resources/icon_exe.icns
|
|
|
|
mkdir icon_cps.iconset
|
|
|
|
cp ../resources/generated_icons/icon_cps_16.png icon_cps.iconset/icon_16x16.png
|
|
|
|
cp ../resources/generated_icons/icon_cps_32.png icon_cps.iconset/icon_32x32.png
|
|
|
|
cp ../resources/generated_icons/icon_cps.png icon_cps.iconset/icon_128x128.png
|
|
|
|
iconutil -c icns icon_cps.iconset
|
|
|
|
cp icon_cps.icns $appdir/Contents/Resources/icon_cps.icns
|
|
|
|
mkdir dmgroot
|
|
|
|
mv $appdir dmgroot/$appdir
|
|
|
|
cp ../LICENSE dmgroot/LICENSE
|
|
|
|
cp ../README.md dmgroot/README.md
|
2023-01-15 07:22:40 -06:00
|
|
|
hdiutil create -format UDZO -volname $APP_NAME -fs HFS+ -srcfolder dmgroot -o $ASSET_PATH
|
2023-01-24 11:37:06 -06:00
|
|
|
elif [[ $PACKAGE_MODE == emscripten ]]; then
|
2023-08-21 13:32:16 -05:00
|
|
|
tar cvf $ASSET_PATH $APP_EXE.js $APP_EXE.worker.js $APP_EXE.wasm
|
2022-12-19 15:08:02 -06:00
|
|
|
elif [[ $PACKAGE_MODE == appimage ]]; then
|
2022-10-23 23:41:12 -05:00
|
|
|
# so far this can only happen with $BSH_HOST_PLATFORM-$BSH_HOST_LIBC == linux-gnu, but this may change later
|
2022-10-22 14:51:12 -05:00
|
|
|
case $BSH_HOST_ARCH in
|
|
|
|
aarch64) appimage_arch=aarch64;;
|
|
|
|
arm) appimage_arch=armhf ;;
|
|
|
|
x86) appimage_arch=i686 ;;
|
|
|
|
x86_64) appimage_arch=x86_64 ;;
|
|
|
|
esac
|
|
|
|
curl -fsSLo appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-$appimage_arch.AppImage"
|
|
|
|
curl -fsSLo AppRun "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-$appimage_arch"
|
|
|
|
chmod +x appimagetool
|
|
|
|
chmod +x AppRun
|
2022-11-02 00:44:58 -05:00
|
|
|
appdir=bagels.AppDir # doesn't matter, won't be visible in the resulting appimage
|
|
|
|
mkdir -p $appdir/usr/bin
|
|
|
|
mkdir -p $appdir/usr/share/metainfo
|
|
|
|
mkdir -p $appdir/usr/share/applications
|
|
|
|
mkdir -p $appdir/usr/share/icons
|
2022-12-17 06:53:37 -06:00
|
|
|
cp $APP_EXE $appdir/usr/bin/$APP_EXE
|
2022-11-02 00:44:58 -05:00
|
|
|
mv AppRun $appdir/AppRun
|
2022-10-23 04:41:26 -05:00
|
|
|
cp ../resources/icon_exe.svg $appdir/$APP_VENDOR-$APP_EXE.svg
|
2022-12-17 06:53:37 -06:00
|
|
|
cp resources/powder.desktop $appdir/$APP_ID.desktop
|
2022-12-19 15:08:02 -06:00
|
|
|
cp resources/appdata.xml $appdir/usr/share/metainfo/$APP_ID.appdata.xml
|
2022-10-23 04:41:26 -05:00
|
|
|
cp $appdir/$APP_VENDOR-$APP_EXE.svg $appdir/usr/share/icons/$APP_VENDOR-$APP_EXE.svg
|
2022-12-17 06:53:37 -06:00
|
|
|
cp $appdir/$APP_ID.desktop $appdir/usr/share/applications/$APP_ID.desktop
|
2022-11-03 01:05:31 -05:00
|
|
|
./appimagetool $appdir $ASSET_PATH
|
2022-10-22 14:51:12 -05:00
|
|
|
fi
|