mirror of
https://github.com/godotengine/godot-build-scripts.git
synced 2025-12-31 05:48:35 +03:00
Web: Refactor build script to run in parallel with full LTO
Fabio found that full LTO produces smaller binaries than ThinLTO, and that's quite important for the Web platform. But for an obscure reason LLVM's full LTO cannot linking with multiple threads, and so it's slow as heck (10-15 min per build). So we work it around by starting all builds in parallel so that they can all link at the same time. The code to do so is pretty ugly, could be refactored further.
This commit is contained in:
@@ -4,9 +4,20 @@ set -e
|
||||
|
||||
# Config
|
||||
|
||||
export SCONS="scons -j${NUM_CORES} verbose=yes warnings=no progress=no"
|
||||
# To speed up builds with single-threaded full LTO linking,
|
||||
# we run all builds in parallel each from their own folder.
|
||||
export NUM_JOBS=5
|
||||
declare -a JOBS=(
|
||||
"tools=yes target=release_debug use_closure_compiler=yes"
|
||||
"tools=no target=release_debug"
|
||||
"tools=no target=release"
|
||||
"tools=no target=release_debug dlink_enabled=yes"
|
||||
"tools=no target=release dlink_enabled=yes"
|
||||
)
|
||||
|
||||
export SCONS="scons -j$(expr ${NUM_CORES} / ${NUM_JOBS}) verbose=yes warnings=no progress=no"
|
||||
export OPTIONS="production=yes"
|
||||
export OPTIONS_MONO="module_mono_enabled=yes use_lto=no"
|
||||
export OPTIONS_MONO="module_mono_enabled=yes -j${NUM_CORES}"
|
||||
export TERM=xterm
|
||||
|
||||
source /root/emsdk/emsdk_env.sh
|
||||
@@ -21,21 +32,25 @@ tar xf /root/godot.tar.gz --strip-components=1
|
||||
if [ "${CLASSICAL}" == "1" ]; then
|
||||
echo "Starting classical build for Web..."
|
||||
|
||||
$SCONS platform=web ${OPTIONS} target=release_debug tools=no
|
||||
$SCONS platform=web ${OPTIONS} target=release tools=no
|
||||
for i in {0..4}; do
|
||||
cp -r /root/godot /root/godot$i
|
||||
cd /root/godot$i
|
||||
echo "$SCONS platform=web ${OPTIONS} ${JOBS[$i]}"
|
||||
$SCONS platform=web ${OPTIONS} ${JOBS[$i]} &
|
||||
pids[$i]=$!
|
||||
done
|
||||
|
||||
$SCONS platform=web ${OPTIONS} target=release_debug tools=no dlink_enabled=yes
|
||||
$SCONS platform=web ${OPTIONS} target=release tools=no dlink_enabled=yes
|
||||
|
||||
mkdir -p /root/out/templates
|
||||
cp -rvp bin/*.zip /root/out/templates
|
||||
rm -f bin/*.zip
|
||||
|
||||
$SCONS platform=web ${OPTIONS} target=release_debug tools=yes use_closure_compiler=yes
|
||||
for pid in ${pids[*]}; do
|
||||
wait $pid
|
||||
done
|
||||
|
||||
mkdir -p /root/out/tools
|
||||
cp -rvp bin/*.zip /root/out/tools
|
||||
rm -f bin/*.zip
|
||||
cp -rvp /root/godot0/bin/*tools*.zip /root/out/tools
|
||||
|
||||
mkdir -p /root/out/templates
|
||||
for i in {1..4}; do
|
||||
cp -rvp /root/godot$i/bin/*.zip /root/out/templates
|
||||
done
|
||||
fi
|
||||
|
||||
# Mono
|
||||
|
||||
Reference in New Issue
Block a user