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 | |
| 7 | # ANDROID_HOST_OUT is where the new prebuilts will be constructed/copied from. |
| 8 | ANDROID_HOST_OUT=$MY_ANDROID_DIR/out/host/linux-x86/ |
| 9 | |
| 10 | # HOST_LIB_DIR allows us to pick up the built librsrt_*.bc libraries. |
| 11 | HOST_LIB_DIR=$ANDROID_HOST_OUT/lib |
| 12 | |
| 13 | # PREBUILTS_DIR is where we want to copy our new files to. |
| 14 | PREBUILTS_DIR=$MY_ANDROID_DIR/prebuilts/sdk/ |
| 15 | |
| 16 | # Target architectures and their system library names. |
| 17 | TARGETS=(arm mips x86) |
| 18 | SYS_NAMES=(generic generic_mips generic_x86) |
| 19 | |
| 20 | print_usage() { |
| 21 | echo "USAGE: $0 [-h|--help] [-n|--no-build] [-x]" |
| 22 | echo "OPTIONS:" |
| 23 | echo " -h, --help : Display this help message." |
| 24 | echo " -n, --no-build : Skip the build step and just copy files." |
| 25 | echo " -x : Display commands before they are executed." |
| 26 | } |
| 27 | |
| 28 | build_rs_libs() { |
| 29 | echo Building for target $1 |
| 30 | lunch $1 |
| 31 | # Build the RS runtime libraries. |
| 32 | cd $MY_ANDROID_DIR/frameworks/rs/driver/runtime && mma -j32 && cd - || exit 1 |
| 33 | # Build a sample support application to ensure that all the pieces are up to date. |
| 34 | cd $MY_ANDROID_DIR/frameworks/rs/java/tests/RSTest_CompatLib/ && mma -j32 && cd - || exit 2 |
| 35 | } |
| 36 | |
| 37 | # Build everything by default |
| 38 | build_rs=1 |
| 39 | |
| 40 | while [ $# -gt 0 ]; do |
| 41 | case "$1" in |
| 42 | -h|--help) |
| 43 | print_usage |
| 44 | exit 0 |
| 45 | ;; |
| 46 | -n|--no-build) |
| 47 | build_rs=0 |
| 48 | ;; |
| 49 | -x) |
| 50 | # set lets us enable bash -x mode. |
| 51 | set -x |
| 52 | ;; |
| 53 | *) |
| 54 | echo Unknown argument: "$1" |
| 55 | print_usage |
| 56 | exit 99 |
| 57 | break |
| 58 | ;; |
| 59 | esac |
| 60 | shift |
| 61 | done |
| 62 | |
| 63 | if [ $build_rs -eq 1 ]; then |
| 64 | |
| 65 | echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 66 | echo !!! BUILDING RS PREBUILTS !!! |
| 67 | echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 68 | |
| 69 | source build/envsetup.sh |
| 70 | |
| 71 | for t in ${TARGETS[@]}; do |
| 72 | build_rs_libs aosp_${t}-userdebug |
| 73 | done |
| 74 | |
| 75 | echo DONE BUILDING RS PREBUILTS |
| 76 | |
| 77 | else |
| 78 | |
| 79 | echo SKIPPING BUILD OF RS PREBUILTS |
| 80 | |
| 81 | fi |
| 82 | |
| 83 | DATE=`date +%Y%m%d` |
| 84 | |
| 85 | cd $PREBUILTS_DIR || exit 3 |
| 86 | repo start pb_$DATE . |
| 87 | |
| 88 | for i in $(seq 0 $((${#TARGETS[@]} - 1))); do |
| 89 | t=${TARGETS[$i]} |
| 90 | sys_lib_dir=$MY_ANDROID_DIR/out/target/product/${SYS_NAMES[$i]}/system/lib |
| 91 | for a in `find renderscript/lib/$t -name \*.so`; do |
| 92 | file=`basename $a` |
| 93 | cp `find $sys_lib_dir -name $file` $a || exit 4 |
| 94 | done |
| 95 | |
| 96 | for a in `find renderscript/lib/$t -name \*.bc`; do |
| 97 | file=`basename $a` |
| 98 | cp `find $HOST_LIB_DIR $sys_lib_dir -name $file` $a || exit 5 |
| 99 | done |
| 100 | done |
| 101 | |
| 102 | # general |
| 103 | # javalib.jar |
| 104 | cp $MY_ANDROID_DIR/out/target/common/obj/JAVA_LIBRARIES/android-support-v8-renderscript_intermediates/javalib.jar renderscript/lib |
| 105 | |
| 106 | # Copy header files for compilers |
| 107 | cp $MY_ANDROID_DIR/external/clang/lib/Headers/*.h renderscript/clang-include |
| 108 | cp $MY_ANDROID_DIR/frameworks/rs/scriptc/* renderscript/include |
| 109 | |
| 110 | |
| 111 | # Linux-specific tools (bin/ and lib/) |
| 112 | TOOLS_BIN=" |
| 113 | bcc_compat |
| 114 | llvm-rs-cc |
| 115 | " |
| 116 | |
| 117 | TOOLS_LIB=" |
| 118 | libbcc.so |
| 119 | libbcinfo.so |
| 120 | libclang.so |
| 121 | libLLVM.so |
| 122 | " |
| 123 | |
| 124 | for a in $TOOLS_BIN; do |
| 125 | cp $ANDROID_HOST_OUT/bin/$a tools/linux/ |
| 126 | strip tools/linux/$a |
| 127 | done |
| 128 | |
| 129 | for a in $TOOLS_LIB; do |
| 130 | cp $ANDROID_HOST_OUT/lib/$a tools/linux/ |
| 131 | strip tools/linux/$a |
| 132 | done |
| 133 | |
| 134 | echo "DON'T FORGET TO UPDATE THE DARWIN COMPILER PREBUILTS!!!" |