blob: 2f0163b5b8597b9f35032c793a1cfb78ba6ad710 [file] [log] [blame]
Stephen Hinesbe965652013-12-20 16:46:25 -08001#!/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
Stephen Hinesa3957aa2014-01-09 02:08:10 -08007if [ $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)
Stephen Hines971d42a2014-02-20 01:42:40 -080016 NUM_CORES=`sysctl -n hw.ncpu`
Stephen Hinesa3957aa2014-01-09 02:08:10 -080017
18else
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 Hines971d42a2014-02-20 01:42:40 -080026 NUM_CORES=`cat /proc/cpuinfo | grep processor | tail -n 1 | cut -f 2 -d :`
27 NUM_CORES=$(($NUM_CORES+1))
Stephen Hinesa3957aa2014-01-09 02:08:10 -080028
29fi
30
Stephen Hines971d42a2014-02-20 01:42:40 -080031echo "Using $NUM_CORES cores"
32
33# Turn off the build cache and make sure we build all of LLVM from scratch.
34export ANDROID_USE_BUILDCACHE=false
35export 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.
40export FORCE_BUILD_RS_COMPAT=true
41
Stephen Hinesbe965652013-12-20 16:46:25 -080042# ANDROID_HOST_OUT is where the new prebuilts will be constructed/copied from.
Stephen Hinesa3957aa2014-01-09 02:08:10 -080043ANDROID_HOST_OUT=$MY_ANDROID_DIR/out/host/$SHORT_OSNAME-x86/
Stephen Hinesbe965652013-12-20 16:46:25 -080044
45# HOST_LIB_DIR allows us to pick up the built librsrt_*.bc libraries.
46HOST_LIB_DIR=$ANDROID_HOST_OUT/lib
47
48# PREBUILTS_DIR is where we want to copy our new files to.
49PREBUILTS_DIR=$MY_ANDROID_DIR/prebuilts/sdk/
50
Stephen Hinesbe965652013-12-20 16:46:25 -080051print_usage() {
52 echo "USAGE: $0 [-h|--help] [-n|--no-build] [-x]"
53 echo "OPTIONS:"
54 echo " -h, --help : Display this help message."
55 echo " -n, --no-build : Skip the build step and just copy files."
56 echo " -x : Display commands before they are executed."
57}
58
59build_rs_libs() {
60 echo Building for target $1
61 lunch $1
62 # Build the RS runtime libraries.
Stephen Hines971d42a2014-02-20 01:42:40 -080063 cd $MY_ANDROID_DIR/frameworks/rs/driver/runtime && mma -j$NUM_CORES && cd - || exit 1
Stephen Hinesbe965652013-12-20 16:46:25 -080064 # Build a sample support application to ensure that all the pieces are up to date.
Stephen Hines971d42a2014-02-20 01:42:40 -080065 cd $MY_ANDROID_DIR/frameworks/rs/java/tests/RSTest_CompatLib/ && mma -j$NUM_CORES && cd - || exit 2
Tim Murrayf38dea92014-01-27 15:09:07 -080066
Stephen Hinesbe965652013-12-20 16:46:25 -080067}
68
69# Build everything by default
70build_rs=1
71
72while [ $# -gt 0 ]; do
73 case "$1" in
74 -h|--help)
75 print_usage
76 exit 0
77 ;;
78 -n|--no-build)
79 build_rs=0
80 ;;
81 -x)
82 # set lets us enable bash -x mode.
83 set -x
84 ;;
85 *)
86 echo Unknown argument: "$1"
87 print_usage
88 exit 99
89 break
90 ;;
91 esac
92 shift
93done
94
95if [ $build_rs -eq 1 ]; then
96
97 echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
98 echo !!! BUILDING RS PREBUILTS !!!
99 echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
100
101 source build/envsetup.sh
102
103 for t in ${TARGETS[@]}; do
104 build_rs_libs aosp_${t}-userdebug
105 done
106
107 echo DONE BUILDING RS PREBUILTS
108
109else
110
111 echo SKIPPING BUILD OF RS PREBUILTS
112
113fi
114
115DATE=`date +%Y%m%d`
116
117cd $PREBUILTS_DIR || exit 3
118repo start pb_$DATE .
119
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800120# Don't copy device prebuilts on Darwin. We don't need/use them.
121if [ $DARWIN -eq 0 ]; then
122 for i in $(seq 0 $((${#TARGETS[@]} - 1))); do
123 t=${TARGETS[$i]}
124 sys_lib_dir=$MY_ANDROID_DIR/out/target/product/${SYS_NAMES[$i]}/system/lib
Stephen Hines1baebcd2014-05-06 10:08:53 -0700125 obj_lib_dir=$MY_ANDROID_DIR/out/target/product/${SYS_NAMES[$i]}/obj/lib
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800126 for a in `find renderscript/lib/$t -name \*.so`; do
127 file=`basename $a`
Stephen Hines1baebcd2014-05-06 10:08:53 -0700128 cp `find $sys_lib_dir $obj_lib_dir -name $file | head -1` $a || exit 4
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800129 done
130
131 for a in `find renderscript/lib/$t -name \*.bc`; do
132 file=`basename $a`
Stephen Hines1baebcd2014-05-06 10:08:53 -0700133 cp `find $HOST_LIB_DIR $sys_lib_dir $obj_lib_dir -name $file | head -1` $a || exit 5
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800134 done
Stephen Hinesbe965652013-12-20 16:46:25 -0800135 done
136
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800137 # javalib.jar
138 cp $MY_ANDROID_DIR/out/target/common/obj/JAVA_LIBRARIES/android-support-v8-renderscript_intermediates/javalib.jar renderscript/lib
Stephen Hinesbe965652013-12-20 16:46:25 -0800139
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800140fi
Stephen Hinesbe965652013-12-20 16:46:25 -0800141
142# Copy header files for compilers
143cp $MY_ANDROID_DIR/external/clang/lib/Headers/*.h renderscript/clang-include
144cp $MY_ANDROID_DIR/frameworks/rs/scriptc/* renderscript/include
145
146
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800147# Host-specific tools (bin/ and lib/)
Stephen Hinesbe965652013-12-20 16:46:25 -0800148TOOLS_BIN="
149bcc_compat
150llvm-rs-cc
151"
152
153TOOLS_LIB="
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800154libbcc.$SONAME
155libbcinfo.$SONAME
156libclang.$SONAME
Stephen Hines1baebcd2014-05-06 10:08:53 -0700157libc++.$SONAME
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800158libLLVM.$SONAME
Stephen Hinesbe965652013-12-20 16:46:25 -0800159"
160
161for a in $TOOLS_BIN; do
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800162 cp $ANDROID_HOST_OUT/bin/$a tools/$SHORT_OSNAME/
163 strip tools/$SHORT_OSNAME/$a
Stephen Hinesbe965652013-12-20 16:46:25 -0800164done
165
166for a in $TOOLS_LIB; do
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800167 cp $ANDROID_HOST_OUT/lib/$a tools/$SHORT_OSNAME/
168 strip tools/$SHORT_OSNAME/$a
Stephen Hinesbe965652013-12-20 16:46:25 -0800169done
170
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800171if [ $DARWIN -eq 0 ]; then
172 echo "DON'T FORGET TO UPDATE THE DARWIN COMPILER PREBUILTS!!!"
173fi