#!/bin/bash set -e export LANG=C git config --global user.email "android-build-bot@fake-email.com" git config --global user.name "android-build-bot" mkdir -p ${HOME}/bin ${WORKSPACE}/build/out curl https://storage.googleapis.com/git-repo-downloads/repo > ${HOME}/bin/repo wget https://git.linaro.org/ci/publishing-api.git/blob_plain/HEAD:/linaro-cp.py -O ${HOME}/bin/linaro-cp.py chmod a+x ${HOME}/bin/* export PATH=${HOME}/bin:${PATH} export base_dir="${HOME}/srv/${JOB_NAME}" export cpu_count=$(getconf _NPROCESSORS_ONLN) export jcpu_count=$(expr ${cpu_count} '*' 2) sudo add-apt-repository "deb http://cz.archive.ubuntu.com/ubuntu utopic main universe" sudo apt-get update sudo apt-get install -y -f gcc-4.6 bc # Move to persistent drive if [ ! -d "${base_dir}" ]; then mkdir -p ${base_dir} chmod 777 ${base_dir} fi cd ${base_dir} if [ -z $BUILD_CONFIG_REPO ] && [ -z $BUILD_CONFIG_BRANCH ] && [ -z $BUILDCONFIG_FILENAME ]; then echo "ERROR: Please provide the config repository, branch and filename" exit 1 else rm -rf android-build-configs git clone $BUILD_CONFIG_REPO -b $BUILD_CONFIG_BRANCH fi source android-build-configs/$BUILD_CONFIG_FILENAME export PATH=$PATH:$PWD/tests/ if [ -z $MANIFEST_URL ]; then MANIFEST_URL=https://android.googlesource.com/platform/manifest/ fi if [ -z $MANIFEST_BRANCH ]; then MANIFEST_BRANCH=master fi if [ -z $LOCAL_MANIFEST_URL ]; then echo "WARNING: local manifest not specified" echo "build is using main manifest only" else if [ -z $LOCAL_MANIFEST_BRANCH ]; then echo "WARNING: local manifest branch not specified, using master branch" LOCAL_MANIFEST_BRANCH=master fi fi if [ -n $REPO_SEED_DIR ]; then REFERENCE="--reference=$REPO_SEED_DIR" fi if [ -z $BOOT_TO_GUI_TEST ]; then BOOT_TO_GUI_TEST=0 fi mkdir -p android cd android/ # setup tmpfs since we have enough free memory # The default is half of the memory (size=50%) mkdir -p out/target/product sudo mount -t tmpfs tmpfs out/target/product MAKE_TARGETS="${MAKE_TARGETS-droidcore}" echo "SYNCING CODE" REPO_START=$(date +%s.%N) repo init -u $MANIFEST_URL -b $MANIFEST_BRANCH $REFERENCE if [ -n $LOCAL_MANIFEST_URL ]; then cd .repo rm -rf local_manifests git clone $LOCAL_MANIFEST_URL -b $LOCAL_MANIFEST_BRANCH local_manifests cd - fi rm -rf art/ build/ external/vixl set +e # Download the code repo sync --force-sync -j${cpu_count} -c > $WORKSPACE/sync-logs.txt 2>&1 if [ $? -ne 0 ]; then echo "Error: *** Error repo sync failed" cat $WORKSPACE/sync-logs.txt exit -1 fi repo manifest -r -o $WORKSPACE/pinned-manifest.xml # Configure ccache USE_CCACHE=1 CCACHE_DIR="${base_dir}/.ccache" CCACHE_SLOPPINESS=file_macro,include_file_mtime,time_macros export USE_CCACHE CCACHE_DIR CCACHE_SLOPPINESS ccache -M 50G if [ -n "$PATCHSETS" ]; then for i in $PATCHSETS; do sh ./android-patchsets/$i done fi if [ -n "$GERRIT_PROJECT" ] && [ $GERRIT_EVENT_TYPE == "patchset-created" ]; then cd `grep -rni $GERRIT_PROJECT\" .repo/local_manifests | grep -Po 'path="\K[^"]*'` if git pull ssh://git@$GERRIT_HOST/$GERRIT_PROJECT $GERRIT_REFSPEC | grep -q "Automatic merge failed" ; then git reset --hard echo "Error: *** Error patch merge failed" exit -1 fi cd - else echo "Build Triggered by timer or after merging the patch" fi REPO_END=$(date +%s.%N) REPO_TIME=$(echo "$REPO_END - $REPO_START" | bc) MAKE_JOBS=${cpu_count} echo "BUILDING CODE" #Clean previous build artifacts rm -rf out/host/