Skip to content

Instantly share code, notes, and snippets.

@easyaspi314
Last active October 26, 2018 02:33
Show Gist options
  • Save easyaspi314/7c7f80c134ca86e6c9e8261edbc50b12 to your computer and use it in GitHub Desktop.
Save easyaspi314/7c7f80c134ca86e6c9e8261edbc50b12 to your computer and use it in GitHub Desktop.
easyaspi314's agbcc and pokeruby build script for Termux
#!/data/data/com.termux/files/usr/bin/sh
note() {
printf "\033[1m%s\n\033[0m" "$1" >&2
}
die() {
printf "%b\n" <<EOF >&2
\033[31;1mDamn it! \033[0;1m$1
You should be able to find a log in ~/agbcc-build-log.txt.
To upload this, go to the default file manager as if you were to upload a normal file, open the left pull-out menu,
find the one that says Termux, and agbcc-build-log.txt should be right there.
EOF
exit 1
}
if [ "$1" != "force" ]; then
note "Setting up storage... please follow any instructions given."
termux-setup-storage || note "Couldn't setup storage."
# reexecute it with a log
exec /data/data/com.termux/files/usr/bin/sh -c "sh $0 force $@ 2>&1 | tee ~/agbcc-build-log.txt"
fi
note "Updating packages..."
{ apt-get update && apt-get upgrade -y; } || die "Couldn't update packages!"
note "Installing required packages..."
apt-get install -y git clang make libpng coreutils libpng-dev termux-exec ndk-sysroot || die "Couldn't install packages!"
note "Cloning git repos..."
cd ~
git clone -b new_layout https://github.com/easyaspi314/agbcc agbcc314 || die "Couldn't clone to agbcc314. Does that file exist? Try rm -rf agbcc314."
git clone -b scaninc https://github.com/easyaspi314/pokeruby pokeruby314 || die "Couldn't clone to pokeruby314. Does that file exist? Try rm -rf pokeruby314"
cd pokeruby314
note "Initializing submodules..."
git submodule init || die "Couldn't init submodules."
git submodule update || die "Couldn't update submodules."
cd ..
note "Ok, now to the real stuff."
note "Building agbcc and binutils..."
cd agbcc314
JOBS="$(nproc || true)"
if [ $JOBS -gt 4 ]; then
echo "You have way too many cores."
echo "Limiting jobs to 4 to prevent race conditions."
JOBS=4
elif [ -z $JOBS ]; then
JOBS=1
fi
make -j $JOBS || die "Something went wrong when building agbcc/binutils."
make install prefix="~/pokeruby314" || die "Something went wrong with make install."
note "That looks fine, let's try building pokeruby."
cd ../pokeruby314
make -j4 || die "Something went wrong building pokeruby."
note "Everything seems okay!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment