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