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