update_rs_prebuilts.sh revision 648a1c137663ef7207684d0d7009dd5518942111
1#!/bin/bash 2 3# We are currently in frameworks/rs, so compute our top-level directory. 4MY_ANDROID_DIR=$PWD/../../ 5cd $MY_ANDROID_DIR 6 7if [ $OSTYPE == 'darwin14' ]; 8then 9 10 DARWIN=1 11 SHORT_OSNAME=darwin 12 SONAME=dylib 13 # Only build arm on darwin. 14 TARGETS=(arm) 15 SYS_NAMES=(generic) 16 NUM_CORES=`sysctl -n hw.ncpu` 17 18else 19 20 DARWIN=0 21 SHORT_OSNAME=linux 22 SONAME=so 23 # Target architectures and their system library names. 24 TARGETS=(arm mips x86 arm64) 25 SYS_NAMES=(generic generic_mips generic_x86 generic_arm64) 26 NUM_CORES=`cat /proc/cpuinfo | grep processor | tail -n 1 | cut -f 2 -d :` 27 NUM_CORES=$(($NUM_CORES+1)) 28 29fi 30 31echo "Using $NUM_CORES cores" 32 33# Turn off the build cache and make sure we build all of LLVM from scratch. 34export ANDROID_USE_BUILDCACHE=false 35export FORCE_BUILD_LLVM_COMPONENTS=true 36 37# Ensure that we have constructed the latest "bcc" for the host. Without 38# this variable, we don't build the .so files, hence we never construct the 39# actual required compiler pieces. 40export FORCE_BUILD_RS_COMPAT=true 41 42# ANDROID_HOST_OUT is where the new prebuilts will be constructed/copied from. 43ANDROID_HOST_OUT=$MY_ANDROID_DIR/out/host/$SHORT_OSNAME-x86/ 44 45# HOST_LIB_DIR allows us to pick up the built librsrt_*.bc libraries. 46HOST_LIB_DIR=$ANDROID_HOST_OUT/lib 47 48# HOST_LIB64_DIR 49HOST_LIB64_DIR=$ANDROID_HOST_OUT/lib64 50 51# PREBUILTS_DIR is where we want to copy our new files to. 52PREBUILTS_DIR=$MY_ANDROID_DIR/prebuilts/sdk/ 53 54print_usage() { 55 echo "USAGE: $0 [-h|--help] [-n|--no-build] [-x]" 56 echo "OPTIONS:" 57 echo " -h, --help : Display this help message." 58 echo " -n, --no-build : Skip the build step and just copy files." 59 echo " -x : Display commands before they are executed." 60} 61 62build_rs_libs() { 63 echo Building for target $1 64 lunch $1 65 # Build the RS runtime libraries. 66 cd $MY_ANDROID_DIR/frameworks/rs/driver/runtime && mma -j$NUM_CORES && cd - || exit 1 67 # Build a sample support application to ensure that all the pieces are up to date. 68 cd $MY_ANDROID_DIR/frameworks/rs/java/tests/RSTest_CompatLib/ && mma -j$NUM_CORES && cd - || exit 2 69 # Build libcompiler-rt.a 70 cd $MY_ANDROID_DIR/external/compiler-rt && mma -j$NUM_CORES && cd - || exit 3 71 # Build the blas libraries. 72 cd $MY_ANDROID_DIR/external/cblas && mma -j$NUM_CORES && cd - || exit 4 73} 74 75# Build everything by default 76build_rs=1 77 78while [ $# -gt 0 ]; do 79 case "$1" in 80 -h|--help) 81 print_usage 82 exit 0 83 ;; 84 -n|--no-build) 85 build_rs=0 86 ;; 87 -x) 88 # set lets us enable bash -x mode. 89 set -x 90 ;; 91 *) 92 echo Unknown argument: "$1" 93 print_usage 94 exit 99 95 break 96 ;; 97 esac 98 shift 99done 100 101if [ $build_rs -eq 1 ]; then 102 103 echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!! 104 echo !!! BUILDING RS PREBUILTS !!! 105 echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!! 106 107 source build/envsetup.sh 108 109 for t in ${TARGETS[@]}; do 110 build_rs_libs aosp_${t}-userdebug 111 done 112 113 echo DONE BUILDING RS PREBUILTS 114 115else 116 117 echo SKIPPING BUILD OF RS PREBUILTS 118 119fi 120 121DATE=`date +%Y%m%d` 122 123cd $PREBUILTS_DIR || exit 3 124repo start pb_$DATE . 125 126# Don't copy device prebuilts on Darwin. We don't need/use them. 127if [ $DARWIN -eq 0 ]; then 128 for i in $(seq 0 $((${#TARGETS[@]} - 1))); do 129 t=${TARGETS[$i]} 130 sys_name=${SYS_NAMES[$i]} 131 case "$sys_name" in 132 *64) 133 sys_lib_dir=$MY_ANDROID_DIR/out/target/product/$sys_name/system/lib64 134 ;; 135 *) 136 sys_lib_dir=$MY_ANDROID_DIR/out/target/product/$sys_name/system/lib 137 ;; 138 esac 139 obj_lib_dir=$MY_ANDROID_DIR/out/target/product/$sys_name/obj/lib 140 obj_static_lib_dir=$MY_ANDROID_DIR/out/target/product/$sys_name/obj/STATIC_LIBRARIES 141 142 for a in `find renderscript/lib/$t -name \*.so`; do 143 file=`basename $a` 144 cp `find $sys_lib_dir $obj_lib_dir -name $file | head -1` $a || exit 4 145 done 146 147 for a in `find renderscript/lib/$t -name \*.bc`; do 148 file=`basename $a` 149 cp `find $HOST_LIB_DIR $HOST_LIB64_DIR $sys_lib_dir $obj_lib_dir -name $file | head -1` $a || exit 5 150 done 151 152 for a in `find renderscript/lib/$t -name \*.a`; do 153 file=`basename $a` 154 cp `find $obj_static_lib_dir -name $file | head -1` $a || exit 4 155 done 156 157 done 158 159 # javalib.jar 160 cp $MY_ANDROID_DIR/out/target/common/obj/JAVA_LIBRARIES/android-support-v8-renderscript_intermediates/classes.jar renderscript/lib/javalib.jar 161 162fi 163 164# Copy header files for compilers 165cp $MY_ANDROID_DIR/external/clang/lib/Headers/*.h renderscript/clang-include 166cp $MY_ANDROID_DIR/frameworks/rs/scriptc/* renderscript/include 167 168 169# Host-specific tools (bin/ and lib/) 170TOOLS_BIN=" 171bcc_compat 172llvm-rs-cc 173" 174 175TOOLS_LIB=" 176libbcc.$SONAME 177libbcinfo.$SONAME 178libclang.$SONAME 179libc++.$SONAME 180libLLVM.$SONAME 181" 182 183TOOLS_LIB32="libc++.$SONAME" 184 185for a in $TOOLS_BIN; do 186 cp $ANDROID_HOST_OUT/bin/$a tools/$SHORT_OSNAME/bin 187 strip tools/$SHORT_OSNAME/bin/$a 188done 189 190for a in $TOOLS_LIB; do 191 cp $HOST_LIB64_DIR/$a tools/$SHORT_OSNAME/lib64 192 strip tools/$SHORT_OSNAME/lib64/$a 193done 194 195for a in $TOOLS_LIB32; do 196 cp $HOST_LIB_DIR/$a tools/$SHORT_OSNAME/lib 197 strip tools/$SHORT_OSNAME/lib/$a 198done 199 200if [ $DARWIN -eq 0 ]; then 201 echo "DON'T FORGET TO UPDATE THE DARWIN COMPILER PREBUILTS!!!" 202fi 203