Skip to content

Instantly share code, notes, and snippets.

@koumaza
Last active July 22, 2020 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koumaza/c4d651d08e05404475ae27238208645a to your computer and use it in GitHub Desktop.
Save koumaza/c4d651d08e05404475ae27238208645a to your computer and use it in GitHub Desktop.
Android Build Startup Script (ABSS)
#!/usr/bin/env bash
export origpwd=$PWD
export aftercd=$1
cat << 'EOF' > .bash-android.rc
sudo /koumazainit >/dev/null 2>/dev/null
export origpwd=$PWD
if [ -n "$aftercd" ]; then
cd $aftercd
fi
function build {
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope >/dev/null
export cpuj=$1
if [ -z "$cpuj" ]; then
export cpuj="12"
fi
echo '>> . build/envsetup.sh'
read -p '>> lunch ' device_codename_value
export device_codename_value=$device_codename_value
. build/envsetup.sh && \
lunch $device_codename_value && \
echo '>> mka bacon' && \
mkdir -p ~/log/$(pwd|tr / _|sed -E s/^_//) && \
mka bacon -j$(($(nproc --all) * $cpuj)) | tee ~/log/$(pwd|tr / _|sed -E s/^_//)/$(date +%Z_%m%d-%H:%M:%S.%N.log)
}
function cdir {
cd $origpwd/$*
}
function help {
echo -e 'Usage: > [build,cdir,clean,help,exit,sync,{make [clean,clobber]}]'"\n"'cdir == change directory'"\n"'clean == "make clean" and "make clobber"'"\n"'sync == repo sync'
}
function exit {
exit
}
function make {
. build/envsetup.sh
make $*
}
function clean {
. build/envsetup.sh
make clean
make clobber
}
function sync {
fish -c repo2sync
}
EOF
bash --init-file .bash-android.rc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment