godot-xterm/addons/godot_xterm/native/build.sh
Leroy Hopson 5f7dc2c247
Use default export templates for HTML5
Changes Emscripten SDK version to match that used to compile the default export
templates used by Godot 3.4 (in this case 2.0.25 as can be seen here:
https://github.com/godotengine/build-containers/blob/3.4/Dockerfile.javascript).

This means we no longer need to compile custom export templates when
exporting HTML5 for Godot 3.4. Exports from other Godot versions may
requiring compiling the GDNative library with a different version of the
Emscripten SDK.
2022-08-03 12:29:10 +12:00

86 lines
2.2 KiB
Bash
Executable file

#!/bin/sh
set -e
# Parse args.
args=$@
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-t|--target)
target="$2"
shift
shift
;;
--disable-pty)
disable_pty="yes"
shift
;;
*)
echo "Usage: ./build.sh [-t|--target <release|debug>] [--disable_pty]";
exit 128
shift
;;
esac
done
# Set defaults.
target=${target:-debug}
disable_pty=${disable_pty:-no}
nproc=$(nproc || sysctl -n hw.ncpu)
#GODOT_DIR Get the absolute path to the directory this script is in.
NATIVE_DIR="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
# Run script inside a nix shell if it is available.
if command -v nix-shell && [ $NIX_PATH ] && [ -z $IN_NIX_SHELL ]; then
cd ${NATIVE_DIR}
nix-shell --pure --run "NIX_PATH=${NIX_PATH} ./build.sh $args"
exit
fi
# Update git submodules.
updateSubmodules() {
eval $1=$2 # E.g LIBUV_DIR=${NATIVE_DIR}/thirdparty/libuv
if [ -z "$(ls -A -- "$2")" ]; then
cd ${NATIVE_DIR}
git submodule update --init --recursive -- $2
fi
}
updateSubmodules LIBUV_DIR ${NATIVE_DIR}/thirdparty/libuv
updateSubmodules LIBTSM_DIR ${NATIVE_DIR}/thirdparty/libtsm
updateSubmodules GODOT_CPP_DIR ${NATIVE_DIR}/thirdparty/godot-cpp
# Build godot-cpp bindings.
cd ${GODOT_CPP_DIR}
echo "scons generate_bindings=yes target=$target -j$nproc"
scons generate_bindings=yes macos_arch=$(uname -m) target=$target -j$nproc
# Build libuv as a static library.
cd ${LIBUV_DIR}
mkdir build || true
cd build
args="-DCMAKE_BUILD_TYPE=$target -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \
-DCMAKE_OSX_ARCHITECTURES=$(uname -m)"
if [ "$target" == "release" ]; then
args="$args -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL"
else
args="$args -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL"
fi
cmake .. $args
cd ..
cmake --build build --config $target -j$nproc
# Build libgodot-xterm.
cd ${NATIVE_DIR}
scons target=$target macos_arch=$(uname -m) disable_pty=$disable_pty -j$nproc
# Use Docker to build libgodot-xterm javascript.
if [ -x "$(command -v docker-compose)" ]; then
UID_GID="0:0" TARGET=$target docker-compose build javascript
UID_GID="$(id -u):$(id -g)" TARGET=$target docker-compose run --rm javascript
fi