Created
March 5, 2019 18:54
-
-
Save mikecriggs/7abd57df279af8d9301311787cc4bcab to your computer and use it in GitHub Desktop.
build-statix.sh
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
#!/bin/bash | |
# | |
# A simple build script for StatiXOS | |
# Written by Michael S Corigliano (Mike Criggs) <[email protected]> | |
# | |
# Usage: ./build.sh <DEVICE> <CLEAN OPTION> <OFFICIAL OPTION> | |
# Clean options: rm, clean, clobber, installclean | |
# Official options: official, nuclear | |
# | |
# Definitions | |
# Arguments | |
DEVICE="$1" | |
CLEAN="$2" | |
#OFFICIAL="$3" | |
# Variables | |
TIMESTAMP=$(date +"%Y-%m-%d-%S") | |
JOBS="$(nproc --all)" | |
# Terminal colors | |
BLDRED="\033[1m""\033[31m" | |
RST="\033[0m" | |
# Functions | |
# Echo message | |
echoMSG () { | |
echo -e ${BLDRED}"$TXT"${RST} | |
echo -e "" | |
echo -e "" | |
} | |
# CCACHE | |
ccacheFun() { | |
export USE_CCACHE=1 | |
export CCACHE_DIR=~/projects/statix/.ccache/$DEVICE | |
export ccache -M 30G | |
} | |
# Build official | |
buildOfficial () { | |
clear | |
TXT="Official StatiXOS build initiated..." | |
echoMSG | |
sleep 2 | |
. build/envsetup.sh | |
ccacheFun | |
export STATIX_BUILD_TYPE="OFFICIAL" | |
lunch statix_$DEVICE-user | |
make -j${JOBS} bacon 2>&1 | tee build-logs/$DEVICE/statix_OFFICIAL-$DEVICE-$TIMESTAMP.log | |
} | |
# Build nuclear | |
buildNuclear () { | |
clear | |
TXT="Nuclear StatiXOS build initiated..." | |
echoMSG | |
sleep 2 | |
. build/envsetup.sh | |
ccacheFun | |
export LC_ALL=C | |
export STATIX_BUILD_TYPE="NUCLEAR" | |
lunch statix_$DEVICE-userdebug | |
make -j${JOBS} bacon 2>&1 | tee build-logs/$DEVICE/statix_NUCLEAR-$DEVICE-$TIMESTAMP.log | |
} | |
# Tell the user to kill the script if no device was defined | |
if [[ ! $1 ]] | |
then | |
clear | |
TXT="ERROR: No device defined. Please press CTRL+C to kill this script in the next 20 seconds." | |
echoMSG | |
TXT="USAGE: ./build.sh <DEVICE> <CLEAN OPTION>" | |
echoMSG | |
sleep 20 | |
else | |
clear | |
TXT="Building StatiXOS for $DEVICE..." | |
echoMSG | |
sleep 2 | |
clear | |
fi | |
# Build logs | |
# Make a build-logs directory for device | |
mkdir -p build-logs/$DEVICE | |
# Remove old build logs (uncomment if desired) | |
# rm -rf build-logs/$DEVICE/* | |
# Clean options | |
case $CLEAN in | |
rm) | |
printf "Removing OUT directories...\n\n" | |
sleep 2 | |
clear | |
rm -rf $OUT | |
;; | |
clean) | |
printf "Making clean...\n\n" | |
sleep 2 | |
clear | |
make clean | |
;; | |
clobber) | |
printf "Making clobber...\n\n" | |
sleep 2 | |
clear | |
make clobber | |
;; | |
installclean) | |
printf "Making installclean...\n\n" | |
sleep 2 | |
clear | |
. build/envsetup.sh | |
make installclean | |
;; | |
*) | |
TXT="WARNING: No clean option was given so building dirty" | |
echoMSG | |
TXT="USAGE: ./build-statix.sh <DEVICE> <CLEAN OPTION> <OFFICIAL OPTION>" | |
echoMSG | |
TXT="Please use the following options for clean:" | |
echoMSG | |
echo -e ${BLDRED}"1: rm (removes OUT directory with rm -rf)"${RST} | |
echo -e ${BLDRED}"2: clean (make clean )"${RST} | |
echo -e ${BLDRED}"3: clobber (make clobber )"${RST} | |
echo -e ${BLDRED}"4: installclean (make installclean )"${RST} | |
sleep 5 | |
printf "\n\n" | |
esac | |
# Official options | |
#case $OFFICIAL in | |
# official) | |
# buildOffical | |
# ;; | |
# nuclear) | |
# buildNuclear | |
# ;; | |
# *) | |
# clear | |
# TXT="WARNING: No official option was given so building nuclear" | |
# echoMSG | |
# TXT="USAGE: ./build-statix.sh <DEVICE> <CLEAN OPTION> <OFFICIAL OPTION>" | |
# echoMSG | |
# TXT="Please use the following options for clean:" | |
# echoMSG | |
# echo -e ${BLDRED}"1: official (Builds an official user ZIP signed with private keys )"${RST} | |
# echo -e ${BLDRED}"2: nuclear (Builds a nuclear userdebug ZIP not signed with private keys)"${RST} | |
# printf "\n\n" | |
# sleep 5 | |
# clear | |
# buildNuclear | |
#esac | |
buildNuclear |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment