Skip to content

Instantly share code, notes, and snippets.

@matgis
Created February 29, 2024 10:00
Show Gist options
  • Save matgis/cd552f043cb041f74cd09d0ea9adaa88 to your computer and use it in GitHub Desktop.
Save matgis/cd552f043cb041f74cd09d0ea9adaa88 to your computer and use it in GitHub Desktop.
Simple `zsh` shell script for building the Defold Engine
#!/bin/zsh
# `defbuild` is a quick and simple zsh shell script for rebuilding the stuff the
# Defold editor depends on. It will rebuild the engine runtime, Bob, and the
# builtins, and then run `lein init` so the updated dependencies are available
# to the editor.
#
# Usage:
# ```
# cd defold
# ./scripts/build.py shell
# defbuild
# ```
# This rebuilds the engine runtime, Bob, and the builtins. Optionally, a mode
# parameter can be specified to control what gets built.
#
# ```
# defbuild full
# ```
# Cleans the `DYNAMO_HOME` directory, runs `install_ext`, and `install_sdk`
# before proceeding with the build.
#
# ```
# defbuild bob
# ```
# Only rebuilds Bob. Useful when you've made changes to Bob, but not the engine.
set -e
if ! [[ -v DYNAMO_HOME ]]; then
echo "Fatal: DYNAMO_HOME must be set."
exit 255
fi
if ! [[ -v DM_PACKAGES_URL ]]; then
echo "Fatal: DM_PACKAGES_URL must be set."
exit 255
fi
arg=$1
case $arg in
full)
distclean=1
install_ext=1
install_sdk=1
build_engine=1
build_builtins=1
build_bob=1
lein_init=1
;;
bob)
build_bob=1
lein_init=1
;;
"")
build_engine=1
build_builtins=1
build_bob=1
lein_init=1
;;
*)
echo "Fatal: Unsupported mode '$arg'."
echo "Supported modes: full, bob"
exit 254
;;
esac
if [[ $distclean -eq 1 ]]; then
echo
echo "Performing distclean..."
./scripts/build.py distclean
fi
if [[ $install_ext -eq 1 ]]; then
echo
echo "Performing install_ext..."
./scripts/build.py install_ext --platform=arm64-macos
fi
if [[ $install_sdk -eq 1 ]]; then
echo
echo "Performing install_sdk..."
./scripts/build.py install_sdk --platform=arm64-macos
fi
if [[ $build_engine -eq 1 ]]; then
echo
echo "Performing build_engine..."
./scripts/build.py build_engine --platform=arm64-macos --skip-tests -- --skip-build-tests
fi
if [[ $build_builtins -eq 1 ]]; then
echo
echo "Performing build_builtins..."
./scripts/build.py build_builtins
fi
if [[ $build_bob -eq 1 ]]; then
echo
echo "Performing build_bob..."
./scripts/build.py build_bob --skip-tests
fi
if [[ $lein_init -eq 1 ]]; then
echo
echo "Performing lein_init..."
pushd editor
lein init
popd
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment