blob: f6ed95a96987e05ad886c4c95770506112b92790 [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
Miao Wangf149b322016-02-27 12:01:59 -08007if [[ $OSTYPE == darwin* ]];
Stephen Hinesa3957aa2014-01-09 02:08:10 -08008then
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.
Pirama Arumuga Nainar97d6bec2017-11-06 13:24:50 -080024 TARGETS=(arm x86 arm64 x86_64)
25 SYS_NAMES=(generic generic_x86 generic_arm64 generic_x86_64)
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
Dan Willemsened2d4bd2017-05-22 20:47:11 -070031# Make sure we build all of LLVM from scratch.
Stephen Hines971d42a2014-02-20 01:42:40 -080032export FORCE_BUILD_LLVM_COMPONENTS=true
33
Pirama Arumuga Nainar651a38e2016-03-14 13:44:31 -070034# Skip building LLVM and compiler-rt tests while updating prebuilts
35export SKIP_LLVM_TESTS=true
36
Miao Wangd0c45802016-02-26 11:39:22 -080037# RENDERSCRIPT_V8_JAR is the generated JAVA static lib for RenderScript Support Lib.
38RENDERSCRIPT_V8_JAR=out/target/common/obj/JAVA_LIBRARIES/android-support-v8-renderscript_intermediates/classes.jar
Miao Wang4581f032015-07-25 17:34:21 -070039
Stephen Hinesbe965652013-12-20 16:46:25 -080040# ANDROID_HOST_OUT is where the new prebuilts will be constructed/copied from.
Stephen Hinesa3957aa2014-01-09 02:08:10 -080041ANDROID_HOST_OUT=$MY_ANDROID_DIR/out/host/$SHORT_OSNAME-x86/
Stephen Hinesbe965652013-12-20 16:46:25 -080042
43# HOST_LIB_DIR allows us to pick up the built librsrt_*.bc libraries.
44HOST_LIB_DIR=$ANDROID_HOST_OUT/lib
45
Tim Murrayf7dfd222014-09-30 12:37:22 -070046# HOST_LIB64_DIR
47HOST_LIB64_DIR=$ANDROID_HOST_OUT/lib64
48
Stephen Hinesbe965652013-12-20 16:46:25 -080049# PREBUILTS_DIR is where we want to copy our new files to.
50PREBUILTS_DIR=$MY_ANDROID_DIR/prebuilts/sdk/
51
Stephen Hinesbe965652013-12-20 16:46:25 -080052print_usage() {
David Gross75e05472016-06-16 12:29:16 -070053 echo "USAGE: $0 [-h|--help] [-j <num>] [-n|--no-build] [--no-start] [-x]"
Stephen Hinesbe965652013-12-20 16:46:25 -080054 echo "OPTIONS:"
David Gross75e05472016-06-16 12:29:16 -070055 echo " -j <num> : Specify parallelism for builds."
Stephen Hinesbe965652013-12-20 16:46:25 -080056 echo " -h, --help : Display this help message."
57 echo " -n, --no-build : Skip the build step and just copy files."
David Gross75e05472016-06-16 12:29:16 -070058 echo " --no-start : Do not \"repo start\" a new branch for the copied files."
Stephen Hinesbe965652013-12-20 16:46:25 -080059 echo " -x : Display commands before they are executed."
60}
61
62build_rs_libs() {
63 echo Building for target $1
64 lunch $1
65 # Build the RS runtime libraries.
Stephen Hines971d42a2014-02-20 01:42:40 -080066 cd $MY_ANDROID_DIR/frameworks/rs/driver/runtime && mma -j$NUM_CORES && cd - || exit 1
Pirama Arumuga Nainara60ca5d2016-10-03 15:53:36 -070067 # Build libRSSupport.so
Miao Wang262bbae2017-01-09 15:42:30 -080068 cd $MY_ANDROID_DIR/frameworks/rs/support && mma -j$NUM_CORES && cd - || exit 2
Miao Wangd0c45802016-02-26 11:39:22 -080069 # 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 Hines648a1c12015-07-24 16:45:36 -070072 # Build libcompiler-rt.a
Miao Wangd0c45802016-02-26 11:39:22 -080073 cd $MY_ANDROID_DIR/external/compiler-rt && mma -j$NUM_CORES && cd - || exit 4
Stephen Hines648a1c12015-07-24 16:45:36 -070074 # Build the blas libraries.
Miao Wangd0c45802016-02-26 11:39:22 -080075 cd $MY_ANDROID_DIR/external/cblas && mma -j$NUM_CORES && cd - || exit 5
Stephen Hinesbe965652013-12-20 16:46:25 -080076}
77
Pirama Arumuga Nainara60ca5d2016-10-03 15:53:36 -070078build_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 Brouillet89e35a52017-01-13 01:56:09 -080082 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 Nainara60ca5d2016-10-03 15:53:36 -070083}
84
85build_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 Hinesbe965652013-12-20 16:46:25 -080093# Build everything by default
94build_rs=1
95
David Gross75e05472016-06-16 12:29:16 -070096# repo start by default
97repo_start=1
98
Stephen Hinesbe965652013-12-20 16:46:25 -080099while [ $# -gt 0 ]; do
100 case "$1" in
101 -h|--help)
102 print_usage
103 exit 0
104 ;;
David Gross75e05472016-06-16 12:29:16 -0700105 -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 Hinesbe965652013-12-20 16:46:25 -0800115 -n|--no-build)
116 build_rs=0
117 ;;
David Gross75e05472016-06-16 12:29:16 -0700118 --no-start)
119 repo_start=0
120 ;;
Stephen Hinesbe965652013-12-20 16:46:25 -0800121 -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
133done
134
135if [ $build_rs -eq 1 ]; then
136
137 echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
138 echo !!! BUILDING RS PREBUILTS !!!
139 echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
140
David Gross75e05472016-06-16 12:29:16 -0700141 echo "Using $NUM_CORES cores"
142
Stephen Hinesbe965652013-12-20 16:46:25 -0800143 source build/envsetup.sh
144
Pirama Arumuga Nainara60ca5d2016-10-03 15:53:36 -0700145 build_rs_host_tools
146
Stephen Hinesbe965652013-12-20 16:46:25 -0800147 for t in ${TARGETS[@]}; do
148 build_rs_libs aosp_${t}-userdebug
149 done
150
151 echo DONE BUILDING RS PREBUILTS
152
153else
154
155 echo SKIPPING BUILD OF RS PREBUILTS
156
157fi
158
Stephen Hinesbe965652013-12-20 16:46:25 -0800159cd $PREBUILTS_DIR || exit 3
David Gross75e05472016-06-16 12:29:16 -0700160
161# Verify that project is "clean"
162if [ `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
166fi
167
168if [ $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
175fi
Stephen Hinesbe965652013-12-20 16:46:25 -0800176
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800177# Don't copy device prebuilts on Darwin. We don't need/use them.
178if [ $DARWIN -eq 0 ]; then
179 for i in $(seq 0 $((${#TARGETS[@]} - 1))); do
180 t=${TARGETS[$i]}
Stephen Hines648a1c12015-07-24 16:45:36 -0700181 sys_name=${SYS_NAMES[$i]}
Miao Wangd0c45802016-02-26 11:39:22 -0800182 case "$sys_name" in
Stephen Hines648a1c12015-07-24 16:45:36 -0700183 *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 Willemsened2d4bd2017-05-22 20:47:11 -0700190 obj_lib_dir=$MY_ANDROID_DIR/out/target/product/$sys_name/obj/SHARED_LIBRARIES
Stephen Hines648a1c12015-07-24 16:45:36 -0700191 obj_static_lib_dir=$MY_ANDROID_DIR/out/target/product/$sys_name/obj/STATIC_LIBRARIES
192
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800193 for a in `find renderscript/lib/$t -name \*.so`; do
194 file=`basename $a`
Dan Willemsened2d4bd2017-05-22 20:47:11 -0700195 name="${file%.*}"
196 cp $obj_lib_dir/${name}_intermediates/$file $a || exit 4
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800197 done
198
199 for a in `find renderscript/lib/$t -name \*.bc`; do
200 file=`basename $a`
Tim Murrayf7dfd222014-09-30 12:37:22 -0700201 cp `find $HOST_LIB_DIR $HOST_LIB64_DIR $sys_lib_dir $obj_lib_dir -name $file | head -1` $a || exit 5
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800202 done
Stephen Hines648a1c12015-07-24 16:45:36 -0700203
204 for a in `find renderscript/lib/$t -name \*.a`; do
205 file=`basename $a`
Dan Willemsened2d4bd2017-05-22 20:47:11 -0700206 name="${file%.*}"
207 cp $obj_static_lib_dir/${name}_intermediates/$file $a || exit 4
Stephen Hines648a1c12015-07-24 16:45:36 -0700208 done
209
Stephen Hinesbe965652013-12-20 16:46:25 -0800210 done
211
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800212 # javalib.jar
Miao Wangd0c45802016-02-26 11:39:22 -0800213 cp $MY_ANDROID_DIR/$RENDERSCRIPT_V8_JAR renderscript/lib/javalib.jar
Stephen Hinesbe965652013-12-20 16:46:25 -0800214
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800215fi
Stephen Hinesbe965652013-12-20 16:46:25 -0800216
217# Copy header files for compilers
218cp $MY_ANDROID_DIR/external/clang/lib/Headers/*.h renderscript/clang-include
Jean-Luc Brouillet2a85b6b2017-01-08 17:35:31 -0800219cp $MY_ANDROID_DIR/frameworks/rs/script_api/include/* renderscript/include
Stephen Hinesbe965652013-12-20 16:46:25 -0800220
221
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800222# Host-specific tools (bin/ and lib/)
Stephen Hinesbe965652013-12-20 16:46:25 -0800223TOOLS_BIN="
224bcc_compat
225llvm-rs-cc
226"
227
228TOOLS_LIB="
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800229libbcc.$SONAME
230libbcinfo.$SONAME
Pirama Arumuga Nainar42dccd12017-08-03 15:35:32 -0700231libclang_android.$SONAME
Stephen Hines1baebcd2014-05-06 10:08:53 -0700232libc++.$SONAME
Pirama Arumuga Nainar42dccd12017-08-03 15:35:32 -0700233libLLVM_android.$SONAME
Stephen Hinesbe965652013-12-20 16:46:25 -0800234"
235
Pirama Arumuga Nainarf5627842015-05-11 14:36:37 -0700236TOOLS_LIB32="libc++.$SONAME"
237
Stephen Hinesbe965652013-12-20 16:46:25 -0800238for a in $TOOLS_BIN; do
Pirama Arumuga Nainarf5627842015-05-11 14:36:37 -0700239 cp $ANDROID_HOST_OUT/bin/$a tools/$SHORT_OSNAME/bin
240 strip tools/$SHORT_OSNAME/bin/$a
Stephen Hinesbe965652013-12-20 16:46:25 -0800241done
242
243for a in $TOOLS_LIB; do
Pirama Arumuga Nainarf5627842015-05-11 14:36:37 -0700244 cp $HOST_LIB64_DIR/$a tools/$SHORT_OSNAME/lib64
245 strip tools/$SHORT_OSNAME/lib64/$a
246done
247
248for a in $TOOLS_LIB32; do
249 cp $HOST_LIB_DIR/$a tools/$SHORT_OSNAME/lib
250 strip tools/$SHORT_OSNAME/lib/$a
Stephen Hinesbe965652013-12-20 16:46:25 -0800251done
252
Pirama Arumuga Nainara60ca5d2016-10-03 15:53:36 -0700253if [ $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
267else
268
269 echo SKIPPING BUILD OF RSTest_CompatLib
270
271fi
272
Stephen Hinesa3957aa2014-01-09 02:08:10 -0800273if [ $DARWIN -eq 0 ]; then
274 echo "DON'T FORGET TO UPDATE THE DARWIN COMPILER PREBUILTS!!!"
275fi