-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create build script * add build dirs to gitignore * fix typo * fix venv activation/deactivation * Keep line length at <=80 characters * clean up script by using functions * print output location * avoid reiteration in defaults * Keep line length at <=80 characters * allow for local ffmpeg tarball * allow for preinstalled ffmpeg * remove build files added before gitignore changes --------- Co-authored-by: Moritz Tim W. <[email protected]>
- Loading branch information
1 parent
d521fb0
commit 1ea4ee6
Showing
2 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -381,3 +381,5 @@ $RECYCLE.BIN/ | |
*.msm | ||
*.msp | ||
*.lnk | ||
/ffmpeg-master-latest-linux64-lgpl-godot | ||
/gdextension_build/scons-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#!/bin/bash | ||
|
||
# Exit on error | ||
set -e | ||
|
||
# User defined variables | ||
TARGET=${1:-"all"} | ||
PLATFORM=${2:-"linux"} | ||
SCONS_VERSION=${3:-"4.4.0"} | ||
FFMPEG_RELATIVE_PATH=${4:-"ffmpeg-master-latest-linux64-lgpl-godot"} | ||
FFMPEG_URL_OR_PATH=${5:-"https://github.com/EIRTeam/FFmpeg-Builds/releases/\ | ||
download/latest/${FFMPEG_RELATIVE_PATH}.tar.xz"} | ||
FFMPEG_TARBALL_PATH=${6:-"ffmpeg.tar.xz"} | ||
SKIP_FFMPEG_IMPORT=${7:-"false"} | ||
SCONS_FLAGS=${8:-"debug_symbols=no"} | ||
|
||
# Fixed variables | ||
SCONS_CACHE_DIR="scons-cache" | ||
SCONS_CACHE_LIMIT="7168" | ||
BUILD_DIR="gdextension_build" | ||
OUTPUT_DIR="${BUILD_DIR}/build" | ||
|
||
can_copy() { | ||
if [[ ! -f $1 ]]; then | ||
return 0 | ||
fi | ||
|
||
if [[ ! -f $2 ]]; then | ||
return 1 | ||
fi | ||
|
||
local src_inode=$(stat -c %i $1) | ||
local dest_inode=$(stat -c %i $2) | ||
if [[ $src_inode -eq $dest_inode ]]; then | ||
return 1 | ||
fi | ||
} | ||
|
||
setup() { | ||
echo "Setting up to build for ${TARGET} with SCons ${SCONS_VERSION}" | ||
|
||
if [ "${SKIP_FFMPEG_IMPORT}" != "true" ]; then | ||
echo "Setting up FFmpeg. Source: ${FFMPEG_URL_OR_PATH}" | ||
if [[ -f ${FFMPEG_URL_OR_PATH} ]]; then | ||
if \ | ||
[[ -f ${FFMPEG_TARBALL_PATH} ]] && \ | ||
can_copy ${FFMPEG_URL_OR_PATH} ${FFMPEG_TARBALL_PATH} | ||
then | ||
echo "Copying FFmpeg from local path..." | ||
cp ${FFMPEG_URL_OR_PATH} ${FFMPEG_TARBALL_PATH} | ||
else | ||
echo "Given source is the same as the target. Skipping copy." | ||
fi | ||
else | ||
echo "Downloading FFmpeg..." | ||
# Download FFmpeg | ||
wget -q --show-progress -O ${FFMPEG_TARBALL_PATH} ${FFMPEG_URL_OR_PATH} | ||
fi | ||
# Extract FFmpeg | ||
tar -xf ${FFMPEG_TARBALL_PATH} | ||
echo "FFmpeg extracted." | ||
fi | ||
|
||
# Ensure submodules are up to date | ||
git submodule update --init --recursive | ||
|
||
echo "Setting up SCons" | ||
# Set up virtual environment | ||
python -m venv venv | ||
source venv/bin/activate | ||
# Upgrade pip | ||
pip install --upgrade pip | ||
# Install SCons | ||
pip install scons==${SCONS_VERSION} | ||
# Exit virtual environment, as it will be re-entered later, | ||
# potentially from a different instance of the script (if TARGET is "all") | ||
deactivate | ||
echo "SCons $(scons --version) installed." | ||
|
||
echo "Setup complete." | ||
} | ||
|
||
build() { | ||
TARGET=${1:-"editor"} | ||
echo "Building ${TARGET}..." | ||
# Setup environment variables | ||
export SCONS_FLAGS="${SCONS_FLAGS}" | ||
export SCONS_CACHE="${SCONS_CACHE_DIR}" | ||
export SCONS_CACHE_LIMIT="${SCONS_CACHE_LIMIT}" | ||
export FFMPEG_PATH="${PWD}/${FFMPEG_RELATIVE_PATH}" | ||
|
||
# Enter virtual environment | ||
source venv/bin/activate | ||
# Enter build directory | ||
pushd ${BUILD_DIR} | ||
# Build | ||
scons \ | ||
platform=linux target=${TARGET} \ | ||
ffmpeg_path=${FFMPEG_PATH} \ | ||
${SCONS_FLAGS} | ||
# Show build results | ||
ls -R build/addons/ffmpeg | ||
|
||
# Exit build directory | ||
popd | ||
# Exit virtual environment | ||
deactivate | ||
} | ||
|
||
cleanup() { | ||
echo "Cleaning up..." | ||
# Remove the ffmpeg tarball | ||
rm -f ffmpeg.tar.xz | ||
echo "Cleanup complete." | ||
echo "The built addons folder is located at '${OUTPUT_DIR}'." | ||
} | ||
|
||
setup | ||
|
||
if [ "${TARGET}" == "all" ]; then | ||
for target in "editor" "template_release" "template_debug"; do | ||
build ${target} | ||
done | ||
echo "Builds completed." | ||
cleanup | ||
exit 0 | ||
else | ||
build ${TARGET} | ||
echo "${TARGET} build completed." | ||
cleanup | ||
fi | ||
|