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 | |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 7 | if [ $OSTYPE == 'darwin13' ]; |
| 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. |
| 24 | TARGETS=(arm mips x86) |
| 25 | SYS_NAMES=(generic generic_mips generic_x86) |
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 | |
| 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. |
| 40 | export FORCE_BUILD_RS_COMPAT=true |
| 41 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 42 | # 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] | 43 | ANDROID_HOST_OUT=$MY_ANDROID_DIR/out/host/$SHORT_OSNAME-x86/ |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 44 | |
| 45 | # HOST_LIB_DIR allows us to pick up the built librsrt_*.bc libraries. |
| 46 | HOST_LIB_DIR=$ANDROID_HOST_OUT/lib |
| 47 | |
Tim Murray | f7dfd22 | 2014-09-30 12:37:22 -0700 | [diff] [blame] | 48 | # HOST_LIB64_DIR |
| 49 | HOST_LIB64_DIR=$ANDROID_HOST_OUT/lib64 |
| 50 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 51 | # PREBUILTS_DIR is where we want to copy our new files to. |
| 52 | PREBUILTS_DIR=$MY_ANDROID_DIR/prebuilts/sdk/ |
| 53 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 54 | print_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 | |
| 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 |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 67 | # 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] | 68 | cd $MY_ANDROID_DIR/frameworks/rs/java/tests/RSTest_CompatLib/ && mma -j$NUM_CORES && cd - || exit 2 |
Tim Murray | f38dea9 | 2014-01-27 15:09:07 -0800 | [diff] [blame] | 69 | |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | # Build everything by default |
| 73 | build_rs=1 |
| 74 | |
| 75 | while [ $# -gt 0 ]; do |
| 76 | case "$1" in |
| 77 | -h|--help) |
| 78 | print_usage |
| 79 | exit 0 |
| 80 | ;; |
| 81 | -n|--no-build) |
| 82 | build_rs=0 |
| 83 | ;; |
| 84 | -x) |
| 85 | # set lets us enable bash -x mode. |
| 86 | set -x |
| 87 | ;; |
| 88 | *) |
| 89 | echo Unknown argument: "$1" |
| 90 | print_usage |
| 91 | exit 99 |
| 92 | break |
| 93 | ;; |
| 94 | esac |
| 95 | shift |
| 96 | done |
| 97 | |
| 98 | if [ $build_rs -eq 1 ]; then |
| 99 | |
| 100 | echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 101 | echo !!! BUILDING RS PREBUILTS !!! |
| 102 | echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 103 | |
| 104 | source build/envsetup.sh |
| 105 | |
| 106 | for t in ${TARGETS[@]}; do |
| 107 | build_rs_libs aosp_${t}-userdebug |
| 108 | done |
| 109 | |
| 110 | echo DONE BUILDING RS PREBUILTS |
| 111 | |
| 112 | else |
| 113 | |
| 114 | echo SKIPPING BUILD OF RS PREBUILTS |
| 115 | |
| 116 | fi |
| 117 | |
| 118 | DATE=`date +%Y%m%d` |
| 119 | |
| 120 | cd $PREBUILTS_DIR || exit 3 |
| 121 | repo start pb_$DATE . |
| 122 | |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 123 | # Don't copy device prebuilts on Darwin. We don't need/use them. |
| 124 | if [ $DARWIN -eq 0 ]; then |
| 125 | for i in $(seq 0 $((${#TARGETS[@]} - 1))); do |
| 126 | t=${TARGETS[$i]} |
| 127 | sys_lib_dir=$MY_ANDROID_DIR/out/target/product/${SYS_NAMES[$i]}/system/lib |
Stephen Hines | 1baebcd | 2014-05-06 10:08:53 -0700 | [diff] [blame] | 128 | obj_lib_dir=$MY_ANDROID_DIR/out/target/product/${SYS_NAMES[$i]}/obj/lib |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 129 | for a in `find renderscript/lib/$t -name \*.so`; do |
| 130 | file=`basename $a` |
Stephen Hines | 1baebcd | 2014-05-06 10:08:53 -0700 | [diff] [blame] | 131 | 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] | 132 | done |
| 133 | |
| 134 | for a in `find renderscript/lib/$t -name \*.bc`; do |
| 135 | file=`basename $a` |
Tim Murray | f7dfd22 | 2014-09-30 12:37:22 -0700 | [diff] [blame] | 136 | 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] | 137 | done |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 138 | done |
| 139 | |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 140 | # javalib.jar |
| 141 | cp $MY_ANDROID_DIR/out/target/common/obj/JAVA_LIBRARIES/android-support-v8-renderscript_intermediates/javalib.jar renderscript/lib |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 142 | |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 143 | fi |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 144 | |
| 145 | # Copy header files for compilers |
| 146 | cp $MY_ANDROID_DIR/external/clang/lib/Headers/*.h renderscript/clang-include |
| 147 | cp $MY_ANDROID_DIR/frameworks/rs/scriptc/* renderscript/include |
| 148 | |
| 149 | |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 150 | # Host-specific tools (bin/ and lib/) |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 151 | TOOLS_BIN=" |
| 152 | bcc_compat |
| 153 | llvm-rs-cc |
| 154 | " |
| 155 | |
| 156 | TOOLS_LIB=" |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 157 | libbcc.$SONAME |
| 158 | libbcinfo.$SONAME |
| 159 | libclang.$SONAME |
Stephen Hines | 1baebcd | 2014-05-06 10:08:53 -0700 | [diff] [blame] | 160 | libc++.$SONAME |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 161 | libLLVM.$SONAME |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 162 | " |
| 163 | |
| 164 | for a in $TOOLS_BIN; do |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 165 | cp $ANDROID_HOST_OUT/bin/$a tools/$SHORT_OSNAME/ |
| 166 | strip tools/$SHORT_OSNAME/$a |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 167 | done |
| 168 | |
| 169 | for a in $TOOLS_LIB; do |
Stephen Hines | b184dc0 | 2014-12-02 17:06:55 -0800 | [diff] [blame] | 170 | cp $HOST_LIB64_DIR/$a tools/$SHORT_OSNAME/ |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 171 | strip tools/$SHORT_OSNAME/$a |
Stephen Hines | be96565 | 2013-12-20 16:46:25 -0800 | [diff] [blame] | 172 | done |
| 173 | |
Stephen Hines | a3957aa | 2014-01-09 02:08:10 -0800 | [diff] [blame] | 174 | if [ $DARWIN -eq 0 ]; then |
| 175 | echo "DON'T FORGET TO UPDATE THE DARWIN COMPILER PREBUILTS!!!" |
| 176 | fi |