############################################################################### # Copyright (c) 2011 Linaro # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html ############################################################################### set -o errtrace if [ ! -n "$SOURCE_OVERLAY" ]; then echo "ERROR: Missing SOURCE_OVERLAY in the configuration." exit 1 fi if [ "$SOURCE_OVERLAY_OPTIONAL" == "1" -o -n "$SOURCE_OVERLAY_OPTIONAL" ]; then echo "ERROR: SOURCE_OVERLAY_OPTIONAL should not be set in official build configuration." echo " It is meant to be set only in local build scripts to bypass overlays." exit 1 fi source "${BUILD_SCRIPT_ROOT}"/helpers trap infrastructure_error ERR # Set TARGET_OUT_DIR since few TARGET_PRODUCT include "full_" keyword as well export TARGET_OUT_DIR=`echo $TARGET_PRODUCT | sed 's/_/\n/;s/.*\n//'` if [ -n "$BUILD_COPYCAT" ]; then download_another_build "$BUILD_COPYCAT" else # Download overlays ASAP for fail-fast approach if [ -n "$SOURCE_OVERLAY" ]; then download_overlays "$SOURCE_OVERLAY" fi if [ -n "$REPO_SEED_URL" ]; then repo-sync-from-seed "${1}" else repo-sync-from-mirror "${1}" fi if [ -n "$POST_CHECKOUT_HOOK" ]; then # if echo "$POST_CHECKOUT_HOOK" | grep -F / >/dev/null; then # echo "Invalid POST_CHECKOUT_HOOK: $POST_CHECKOUT_HOOK" # exit 1 # fi $BUILD_SCRIPT_ROOT/$POST_CHECKOUT_HOOK fi trap - ERR . build/envsetup.sh trap infrastructure_error ERR # We evaluate the configuration again because envsetup.sh might well # have stomped on some of the values in it. set -a eval $CONFIGURATION set +a export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.22/ export ANDROID_JAVA_HOME=$JAVA_HOME # Setup CCACHE to be used between different builds export USE_CCACHE=1 export CCACHE_DIR=/Android/ccache if [ "$MAKE_TARGETS" != "combine_kernel_prebuilt" ]; then prebuilts/misc/linux-x86/ccache/ccache -M 75G fi MAKE_TARGETS="${MAKE_TARGETS-boottarball systemtarball userdatatarball}" calc_make_jobs if test -n "$TOOLCHAIN_URL"; then wget -nv --no-check-certificate $TOOLCHAIN_URL toolchain_filename=`echo $TOOLCHAIN_URL | sed -e 's/.*\/\([^/]*\)$/\1/'` mkdir toolchain tar -C toolchain --strip-components 1 -xf $toolchain_filename if test -z "$TOOLCHAIN_TRIPLET"; then # Android 2.x usually needs to be built with arm-eabi, # Android 4.x usually needs to be built with arm-linux-androideabi... if echo $MANIFEST_BRANCH |grep -qE 'android.2\.3'; then p=`find $PWD/toolchain/bin/arm-eabi-gcc 2>/dev/null |head -n1` else p=`find $PWD/toolchain/bin/arm-linux-androideabi-gcc 2>/dev/null |head -n1` fi [ -z "$p" ] && p=`find $PWD/toolchain/bin/*-gcc |head -n1` else p=`find $PWD/toolchain/bin/$TOOLCHAIN_TRIPLET-gcc |head -n1` fi export TARGET_TOOLS_PREFIX=`echo $p | sed -e 's/-gcc$/-/'` fi if [ "$TOOLCHAIN_FINGERPRINT" != "0" -a -n "$toolchain_filename" ]; then mkdir -p fingerprints cp $toolchain_filename fingerprints/ fi if test -z "$TARGET_ARCH_VARIANT"; then TARGET_ARCH_VARIANT=armv7-a-neon fi if test -z "$WITH_HOST_DALVIK"; then WITH_HOST_DALVIK=false fi SHOWCOMMANDS= if test -z "$QUIET" || test "$QUIET" = "0"; then SHOWCOMMANDS=showcommands fi if [ -n "$SOURCE_OVERLAY" ]; then unpack_overlays "$SOURCE_OVERLAY" fi if [ -n "$EXTERNAL_TARBALL" ]; then unpack_external_tarball "$EXTERNAL_TARBALL" fi if [ -x "${TARGET_TOOLS_PREFIX}gcc" ]; then ${TARGET_TOOLS_PREFIX}gcc -v fi if [ -z "$MAKE" ]; then MAKE=make fi trap - ERR export TIMEFORMAT="TIME: Compilation: %lR" time $MAKE $MAKE_OPTS -j$MAKE_JOBS $MAKE_TARGETS $SHOWCOMMANDS WITH_HOST_DALVIK="$WITH_HOST_DALVIK" unset TIMEFORMAT trap infrastructure_error ERR # Show remaining disk space to catch early if # we're approaching ramdisk limit again echo "Remaining disk space after build:" df if [ -n "$BUILD_SYSROOT" ]; then git clone git://git.linaro.org/android/toolchain/build.git toolchain-build rm -rf /tmp/sysroot toolchain-build/build-sysroot.sh out/target/product/`ls -1 out/target/product | head -n1` /tmp/sysroot tar -cj -C /tmp/sysroot -f out/sysroot.tar.bz2 . fi fi # Create filesystem images if [ -n "$BUILD_FS_IMAGE" ]; then FS_IMAGE_SIZE=${FS_IMAGE_SIZE-2G} sudo linaro-android-media-create \ --dev `product2lamc_dev $TARGET_PRODUCT` \ --system $PWD/out/target/product/$TARGET_OUT_DIR/system.tar.bz2 \ --userdata $PWD/out/target/product/$TARGET_OUT_DIR/userdata.tar.bz2 \ --boot $PWD/out/target/product/$TARGET_OUT_DIR/boot.tar.bz2 \ --image-size "$FS_IMAGE_SIZE" \ --image-file out/target/product/$TARGET_OUT_DIR/$TARGET_PRODUCT.img bzip2 -9 out/target/product/$TARGET_PRODUCT/$TARGET_PRODUCT.img fi # Store kernel .config as a build artifact if [ -f kernel/.config ]; then cp kernel/.config out/kernel_config elif [ -f "out/target/product/$TARGET_OUT_DIR/obj/kernel/.config" ]; then cp "out/target/product/$TARGET_OUT_DIR/obj/kernel/.config" out/kernel_config fi # Create md5sums file for platform artifacts (cd out/target/product/*/; md5sum *.tar.bz2 *.img >MD5SUMS) || true (cd out/; ${BUILD_SCRIPT_ROOT}/create-user-build-script) if [ -f out/kernel_config ]; then (cd out/; ${BUILD_SCRIPT_ROOT}/create-user-kernel-script) || true fi if [ ! -n "$SKIP_LICENSE_CHECK" ]; then ${BUILD_SCRIPT_ROOT}/license-verification.sh out/pinned-manifest.xml out/target/product/$TARGET_PRODUCT/BUILD-INFO.txt fi ${BUILD_SCRIPT_ROOT}/../utils/manifest-descriptions/make.sh out/source-manifest.xml out/pinned-manifest.xml flatten_artifacts