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. |
Miao Wang | 38b26af | 2016-03-30 13:27:47 -0700 | [diff] [blame] | 24 | TARGETS=(arm mips x86 arm64 x86_64) |
| 25 | SYS_NAMES=(generic generic_mips generic_x86 generic_arm64 generic_x86_64) |
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 | |
Dan Willemsen | ed2d4bd | 2017-05-22 20:47:11 -0700 | [diff] [blame] | 31 | # Make sure we build all of LLVM from scratch. |
Stephen Hines | 971d42a | 2014-02-20 01:42:40 -0800 | [diff] [blame] | 32 | export FORCE_BUILD_LLVM_COMPONENTS=true |
| 33 | |
Pirama Arumuga Nainar | 651a38e | 2016-03-14 13:44:31 -0700 | [diff] [blame] | 34 | # Skip building LLVM and compiler-rt tests while updating prebuilts |
| 35 | export SKIP_LLVM_TESTS=true |
| 36 | |
Miao Wang | d0c4580 | 2016-02-26 11:39:22 -0800 | [diff] [blame] | 37 | # RENDERSCRIPT_V8_JAR is the generated JAVA static lib for RenderScript Support Lib. |
| 38 | 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] | 39 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 40 | # 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] | 41 | ANDROID_HOST_OUT=$MY_ANDROID_DIR/out/host/$SHORT_OSNAME-x86/ |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 42 | |
| 43 | # HOST_LIB_DIR allows us to pick up the built librsrt_*.bc libraries. |
| 44 | HOST_LIB_DIR=$ANDROID_HOST_OUT/lib |
| 45 | |
Tim Murray | f7dfd22 | 2014-09-30 12:37:22 -0700 | [diff] [blame] | 46 | # HOST_LIB64_DIR |
| 47 | HOST_LIB64_DIR=$ANDROID_HOST_OUT/lib64 |
| 48 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 49 | # PREBUILTS_DIR is where we want to copy our new files to. |
| 50 | PREBUILTS_DIR=$MY_ANDROID_DIR/prebuilts/sdk/ |
| 51 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 52 | print_usage() { |
David Gross | 75e0547 | 2016-06-16 12:29:16 -0700 | [diff] [blame] | 53 | echo "USAGE: $0 [-h|--help] [-j <num>] [-n|--no-build] [--no-start] [-x]" |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 54 | echo "OPTIONS:" |
David Gross | 75e0547 | 2016-06-16 12:29:16 -0700 | [diff] [blame] | 55 | echo " -j <num> : Specify parallelism for builds." |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 56 | echo " -h, --help : Display this help message." |
| 57 | echo " -n, --no-build : Skip the build step and just copy files." |
David Gross | 75e0547 | 2016-06-16 12:29:16 -0700 | [diff] [blame] | 58 | echo " --no-start : Do not \"repo start\" a new branch for the copied files." |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 59 | echo " -x : Display commands before they are executed." |
| 60 | } |
| 61 | |
| 62 | build_rs_libs() { |
| 63 | echo Building for target $1 |
| 64 | lunch $1 |
| 65 | # Build the RS runtime libraries. |
Stephen Hines | 971d42a | 2014-02-20 01:42:40 -0800 | [diff] [blame] | 66 | cd $MY_ANDROID_DIR/frameworks/rs/driver/runtime && mma -j$NUM_CORES && cd - || exit 1 |
Pirama Arumuga Nainar | a60ca5d | 2016-10-03 15:53:36 -0700 | [diff] [blame] | 67 | # Build libRSSupport.so |
Miao Wang | 262bbae | 2017-01-09 15:42:30 -0800 | [diff] [blame] | 68 | cd $MY_ANDROID_DIR/frameworks/rs/support && mma -j$NUM_CORES && cd - || exit 2 |
Miao Wang | d0c4580 | 2016-02-26 11:39:22 -0800 | [diff] [blame] | 69 | # Build android-support-v8-renderscript.jar |
| 70 | # We need to explicitly do so, since JACK won't generate a jar by default. |
| 71 | 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] | 72 | # Build libcompiler-rt.a |
Miao Wang | d0c4580 | 2016-02-26 11:39:22 -0800 | [diff] [blame] | 73 | 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] | 74 | # Build the blas libraries. |
Miao Wang | d0c4580 | 2016-02-26 11:39:22 -0800 | [diff] [blame] | 75 | 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] | 76 | } |
| 77 | |
Pirama Arumuga Nainar | a60ca5d | 2016-10-03 15:53:36 -0700 | [diff] [blame] | 78 | build_rstest_compatlib() { |
| 79 | echo Building for target $1 |
| 80 | lunch $1 |
| 81 | # Build a sample support application to ensure that all the pieces are up to date. |
Jean-Luc Brouillet | 89e35a5 | 2017-01-13 01:56:09 -0800 | [diff] [blame] | 82 | cd $MY_ANDROID_DIR/frameworks/rs/tests/java_api/RSTest_CompatLib/ && mma -j$NUM_CORES FORCE_BUILD_RS_COMPAT=true && cd - || exit 6 |
Pirama Arumuga Nainar | a60ca5d | 2016-10-03 15:53:36 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | build_rs_host_tools() { |
| 86 | echo "Building RS host tools (llvm-rs-cc and bcc_compat)" |
| 87 | lunch aosp_arm64-userdebug |
| 88 | |
| 89 | cd $MY_ANDROID_DIR/frameworks/compile/slang && mma -j$NUM_CORES && cd - || exit 7 |
| 90 | cd $MY_ANDROID_DIR/frameworks/compile/libbcc && mma -j$NUM_CORES && cd - || exit 8 |
| 91 | } |
| 92 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 93 | # Build everything by default |
| 94 | build_rs=1 |
| 95 | |
David Gross | 75e0547 | 2016-06-16 12:29:16 -0700 | [diff] [blame] | 96 | # repo start by default |
| 97 | repo_start=1 |
| 98 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 99 | while [ $# -gt 0 ]; do |
| 100 | case "$1" in |
| 101 | -h|--help) |
| 102 | print_usage |
| 103 | exit 0 |
| 104 | ;; |
David Gross | 75e0547 | 2016-06-16 12:29:16 -0700 | [diff] [blame] | 105 | -j) |
| 106 | if [[ $# -gt 1 && "$2" =~ ^[0-9]+$ ]]; then |
| 107 | NUM_CORES="$2" |
| 108 | shift |
| 109 | else |
| 110 | echo Expected numeric argument after "$1" |
| 111 | print_usage |
| 112 | exit 99 |
| 113 | fi |
| 114 | ;; |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 115 | -n|--no-build) |
| 116 | build_rs=0 |
| 117 | ;; |
David Gross | 75e0547 | 2016-06-16 12:29:16 -0700 | [diff] [blame] | 118 | --no-start) |
| 119 | repo_start=0 |
| 120 | ;; |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 121 | -x) |
| 122 | # set lets us enable bash -x mode. |
| 123 | set -x |
| 124 | ;; |
| 125 | *) |
| 126 | echo Unknown argument: "$1" |
| 127 | print_usage |
| 128 | exit 99 |
| 129 | break |
| 130 | ;; |
| 131 | esac |
| 132 | shift |
| 133 | done |
| 134 | |
| 135 | if [ $build_rs -eq 1 ]; then |
| 136 | |
| 137 | echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 138 | echo !!! BUILDING RS PREBUILTS !!! |
| 139 | echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 140 | |
David Gross | 75e0547 | 2016-06-16 12:29:16 -0700 | [diff] [blame] | 141 | echo "Using $NUM_CORES cores" |
| 142 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 143 | source build/envsetup.sh |
| 144 | |
Pirama Arumuga Nainar | a60ca5d | 2016-10-03 15:53:36 -0700 | [diff] [blame] | 145 | build_rs_host_tools |
| 146 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 147 | for t in ${TARGETS[@]}; do |
| 148 | build_rs_libs aosp_${t}-userdebug |
| 149 | done |
| 150 | |
| 151 | echo DONE BUILDING RS PREBUILTS |
| 152 | |
| 153 | else |
| 154 | |
| 155 | echo SKIPPING BUILD OF RS PREBUILTS |
| 156 | |
| 157 | fi |
| 158 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 159 | cd $PREBUILTS_DIR || exit 3 |
David Gross | 75e0547 | 2016-06-16 12:29:16 -0700 | [diff] [blame] | 160 | |
| 161 | # Verify that project is "clean" |
| 162 | if [ `git status --short --untracked-files=no | wc -l` -ne 0 ]; then |
| 163 | echo $PREBUILTS_DIR contains modified files -- aborting. |
| 164 | git status --untracked-files=no |
| 165 | exit 1 |
| 166 | fi |
| 167 | |
| 168 | if [ $repo_start -eq 1 ]; then |
| 169 | DATE=`date +%Y%m%d` |
| 170 | repo start pb_$DATE . |
| 171 | if [ $? -ne 0 ]; then |
| 172 | echo repo start failed -- aborting. |
| 173 | exit 1 |
| 174 | fi |
| 175 | fi |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 176 | |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 177 | # Don't copy device prebuilts on Darwin. We don't need/use them. |
| 178 | if [ $DARWIN -eq 0 ]; then |
| 179 | for i in $(seq 0 $((${#TARGETS[@]} - 1))); do |
| 180 | t=${TARGETS[$i]} |
Stephen Hines | 648a1c1 | 2015-07-24 16:45:36 -0700 | [diff] [blame] | 181 | sys_name=${SYS_NAMES[$i]} |
Miao Wang | d0c4580 | 2016-02-26 11:39:22 -0800 | [diff] [blame] | 182 | case "$sys_name" in |
Stephen Hines | 648a1c1 | 2015-07-24 16:45:36 -0700 | [diff] [blame] | 183 | *64) |
| 184 | sys_lib_dir=$MY_ANDROID_DIR/out/target/product/$sys_name/system/lib64 |
| 185 | ;; |
| 186 | *) |
| 187 | sys_lib_dir=$MY_ANDROID_DIR/out/target/product/$sys_name/system/lib |
| 188 | ;; |
| 189 | esac |
Dan Willemsen | ed2d4bd | 2017-05-22 20:47:11 -0700 | [diff] [blame] | 190 | obj_lib_dir=$MY_ANDROID_DIR/out/target/product/$sys_name/obj/SHARED_LIBRARIES |
Stephen Hines | 648a1c1 | 2015-07-24 16:45:36 -0700 | [diff] [blame] | 191 | obj_static_lib_dir=$MY_ANDROID_DIR/out/target/product/$sys_name/obj/STATIC_LIBRARIES |
| 192 | |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 193 | for a in `find renderscript/lib/$t -name \*.so`; do |
| 194 | file=`basename $a` |
Dan Willemsen | ed2d4bd | 2017-05-22 20:47:11 -0700 | [diff] [blame] | 195 | name="${file%.*}" |
| 196 | cp $obj_lib_dir/${name}_intermediates/$file $a || exit 4 |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 197 | done |
| 198 | |
| 199 | for a in `find renderscript/lib/$t -name \*.bc`; do |
| 200 | file=`basename $a` |
Tim Murray | f7dfd22 | 2014-09-30 12:37:22 -0700 | [diff] [blame] | 201 | 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] | 202 | done |
Stephen Hines | 648a1c1 | 2015-07-24 16:45:36 -0700 | [diff] [blame] | 203 | |
| 204 | for a in `find renderscript/lib/$t -name \*.a`; do |
| 205 | file=`basename $a` |
Dan Willemsen | ed2d4bd | 2017-05-22 20:47:11 -0700 | [diff] [blame] | 206 | name="${file%.*}" |
| 207 | cp $obj_static_lib_dir/${name}_intermediates/$file $a || exit 4 |
Stephen Hines | 648a1c1 | 2015-07-24 16:45:36 -0700 | [diff] [blame] | 208 | done |
| 209 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 210 | done |
| 211 | |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 212 | # javalib.jar |
Miao Wang | d0c4580 | 2016-02-26 11:39:22 -0800 | [diff] [blame] | 213 | cp $MY_ANDROID_DIR/$RENDERSCRIPT_V8_JAR renderscript/lib/javalib.jar |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 214 | |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 215 | fi |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 216 | |
| 217 | # Copy header files for compilers |
| 218 | cp $MY_ANDROID_DIR/external/clang/lib/Headers/*.h renderscript/clang-include |
Jean-Luc Brouillet | 2a85b6b | 2017-01-08 17:35:31 -0800 | [diff] [blame] | 219 | cp $MY_ANDROID_DIR/frameworks/rs/script_api/include/* renderscript/include |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 220 | |
| 221 | |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 222 | # Host-specific tools (bin/ and lib/) |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 223 | TOOLS_BIN=" |
| 224 | bcc_compat |
| 225 | llvm-rs-cc |
| 226 | " |
| 227 | |
| 228 | TOOLS_LIB=" |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 229 | libbcc.$SONAME |
| 230 | libbcinfo.$SONAME |
| 231 | libclang.$SONAME |
Stephen Hines | 1baebcd | 2014-05-06 10:08:53 -0700 | [diff] [blame] | 232 | libc++.$SONAME |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 233 | libLLVM.$SONAME |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 234 | " |
| 235 | |
Pirama Arumuga Nainar | f562784 | 2015-05-11 14:36:37 -0700 | [diff] [blame] | 236 | TOOLS_LIB32="libc++.$SONAME" |
| 237 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 238 | for a in $TOOLS_BIN; do |
Pirama Arumuga Nainar | f562784 | 2015-05-11 14:36:37 -0700 | [diff] [blame] | 239 | cp $ANDROID_HOST_OUT/bin/$a tools/$SHORT_OSNAME/bin |
| 240 | strip tools/$SHORT_OSNAME/bin/$a |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 241 | done |
| 242 | |
| 243 | for a in $TOOLS_LIB; do |
Pirama Arumuga Nainar | f562784 | 2015-05-11 14:36:37 -0700 | [diff] [blame] | 244 | cp $HOST_LIB64_DIR/$a tools/$SHORT_OSNAME/lib64 |
| 245 | strip tools/$SHORT_OSNAME/lib64/$a |
| 246 | done |
| 247 | |
| 248 | for a in $TOOLS_LIB32; do |
| 249 | cp $HOST_LIB_DIR/$a tools/$SHORT_OSNAME/lib |
| 250 | strip tools/$SHORT_OSNAME/lib/$a |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 251 | done |
| 252 | |
Pirama Arumuga Nainar | a60ca5d | 2016-10-03 15:53:36 -0700 | [diff] [blame] | 253 | if [ $build_rs -eq 1 ]; then |
| 254 | |
| 255 | echo BUILDING RSTest_CompatLib with the new prebuilts |
| 256 | |
| 257 | echo "Using $NUM_CORES cores" |
| 258 | |
| 259 | source $MY_ANDROID_DIR/build/envsetup.sh |
| 260 | |
| 261 | for t in ${TARGETS[@]}; do |
| 262 | build_rstest_compatlib aosp_${t}-userdebug |
| 263 | done |
| 264 | |
| 265 | echo DONE BUILDING RSTest_CompatLib |
| 266 | |
| 267 | else |
| 268 | |
| 269 | echo SKIPPING BUILD OF RSTest_CompatLib |
| 270 | |
| 271 | fi |
| 272 | |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 273 | if [ $DARWIN -eq 0 ]; then |
| 274 | echo "DON'T FORGET TO UPDATE THE DARWIN COMPILER PREBUILTS!!!" |
| 275 | fi |