Created
November 2, 2016 17:22
-
-
Save aperezdc/6ebbaad624e6440d554f66848bee494e to your computer and use it in GitHub Desktop.
Autoenv scripts to prepare an Android build environment in a directory
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
# Needs "curl", "sha1sum", some basic shell tools, | |
# plus the following Zsh plugins installed: | |
# | |
# https://github.com/Tarrasch/zsh-autoenv | |
# https://github.com/aperezdc/virtualz | |
# | |
# Drop this file into a new directory as .autoenv.zsh | |
# and enter it to have a virtualenv configured to use | |
# for building Android, and the "repo" tool installed | |
# and ready to be used. Bonus: ccache is configured. | |
# Obtain the directory where this script is located. | |
declare -r A=${0:A:h} | |
# Configure ccache | |
autostash USE_CCACHE=1 | |
autostash CCACHE_COMPRESS=1 | |
autostash CCACHE_DIR="${A}/,ccache" | |
autostash CCACHE_SIZE=50G | |
autostash CCACHE_MAXSIZE=${CCACHE_SIZE} | |
mkdir -p "${CCACHE_DIR}" | |
# Create or activate a virtualenv for Android, and use a | |
# local directory separate from the user's $VIRTUALZ_HOME. | |
autostash VIRTUALZ_HOME="${A}/,vz" | |
if vz _exists android ; then | |
vz activate android | |
else | |
echo '* Creating virtualenv...' | |
vz new android -p python2 | |
fi | |
# Download and verify "repo". | |
if [[ ! -x ${A}/,repo/repo ]] ; then | |
echo '* Installing repo...' | |
rm -rf "${A}/,repo" | |
mkdir "${A}/,repo" | |
curl -\#fLo "${A}/,repo/repo" https://storage.googleapis.com/git-repo-downloads/repo | |
if [[ ac9d646f6d699f6822a6bc787d3e7338ae7ab6ed != $(sha1sum "${A}/,repo/repo" | cut -d' ' -f1) ]] | |
then | |
echo '[1;31m== WARNING ==[0;0m' | |
echo 'SHA-1 mismatch (expected ac9d646f6d699f6822a6bc787d3e7338ae7ab6ed):' | |
echo '[1;31m== WARNING ==[0;0m' | |
sha1sum "${A}/,repo/repo" | |
fi | |
chmod +x "${A}/,repo/repo" | |
fi | |
# Add the location where "repo" lives to the $PATH. | |
autostash PATH="${A}/,repo:${PATH}" |
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
# Deactivate the virtualenv and undo the setup | |
vz deactivate | |
declare +r A | |
unset A |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment