1 #!/bin/sh 2 # 3 # Copyright (C) 2011 The Android Open Source Project 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 # 17 # Rebuild all target-specific prebuilts 18 # 19 20 PROGDIR=$(dirname $0) 21 . $PROGDIR/prebuilt-common.sh 22 23 NDK_DIR=$ANDROID_NDK_ROOT 24 register_var_option "--ndk-dir=<path>" NDK_DIR "NDK installation directory" 25 26 ARCHS=$DEFAULT_ARCHS 27 register_var_option "--arch=<list>" ARCHS "List of target archs to build for" 28 29 PACKAGE_DIR= 30 register_var_option "--package-dir=<path>" PACKAGE_DIR "Package toolchain into this directory" 31 32 VISIBLE_LIBGNUSTL_STATIC= 33 register_var_option "--visible-libgnustl-static" VISIBLE_LIBGNUSTL_STATIC "Do not use hidden visibility for libgnustl_static.a" 34 35 register_jobs_option 36 37 PROGRAM_PARAMETERS="<toolchain-src-dir>" 38 PROGRAM_DESCRIPTION=\ 39 "This script can be used to rebuild all the target NDK prebuilts at once. 40 You need to give it the path to the toolchain source directory, as 41 downloaded by the 'download-toolchain-sources.sh' dev-script." 42 43 extract_parameters "$@" 44 45 # Check toolchain source path 46 SRC_DIR="$PARAMETERS" 47 check_toolchain_src_dir "$SRC_DIR" 48 SRC_DIR=`cd $SRC_DIR; pwd` 49 50 # Now we can do the build 51 BUILDTOOLS=$ANDROID_NDK_ROOT/build/tools 52 53 dump "Building platforms and samples..." 54 PACKAGE_FLAGS= 55 if [ "$PACKAGE_DIR" ]; then 56 PACKAGE_FLAGS="--package-dir=$PACKAGE_DIR" 57 fi 58 59 run $BUILDTOOLS/gen-platforms.sh --samples --fast-copy --dst-dir=$NDK_DIR --ndk-dir=$NDK_DIR --arch=$(spaces_to_commas $ARCHS) $PACKAGE_FLAGS 60 fail_panic "Could not generate platforms and samples directores!" 61 62 ARCHS=$(commas_to_spaces $ARCHS) 63 64 FLAGS= 65 if [ "$VERBOSE" = "yes" ]; then 66 FLAGS=$FLAGS" --verbose" 67 fi 68 if [ "$VERBOSE2" = "yes" ]; then 69 FLAGS=$FLAGS" --verbose" 70 fi 71 if [ "$PACKAGE_DIR" ]; then 72 mkdir -p "$PACKAGE_DIR" 73 fail_panic "Could not create package directory: $PACKAGE_DIR" 74 FLAGS=$FLAGS" --package-dir=\"$PACKAGE_DIR\"" 75 fi 76 FLAGS=$FLAGS" -j$NUM_JOBS" 77 78 # First, gdbserver 79 for ARCH in $ARCHS; do 80 GDB_TOOLCHAINS=$(get_default_toolchain_name_for_arch $ARCH) 81 for GDB_TOOLCHAIN in $GDB_TOOLCHAINS; do 82 dump "Building $GDB_TOOLCHAIN gdbserver binaries..." 83 run $BUILDTOOLS/build-gdbserver.sh "$SRC_DIR" "$NDK_DIR" "$GDB_TOOLCHAIN" $FLAGS 84 fail_panic "Could not build $GDB_TOOLCHAIN gdb-server!" 85 done 86 done 87 88 FLAGS=$FLAGS" --ndk-dir=\"$NDK_DIR\"" 89 ABIS=$(convert_archs_to_abis $ARCHS) 90 91 FLAGS=$FLAGS" --abis=$ABIS" 92 dump "Building $ABIS gabi++ binaries..." 93 run $BUILDTOOLS/build-cxx-stl.sh --stl=gabi++ $FLAGS 94 fail_panic "Could not build gabi++!" 95 96 dump "Building $ABIS stlport binaries..." 97 run $BUILDTOOLS/build-cxx-stl.sh --stl=stlport $FLAGS 98 fail_panic "Could not build stlport!" 99 100 dump "Building $ABIS libc++ binaries..." 101 run $BUILDTOOLS/build-cxx-stl.sh --stl=libc++ $FLAGS 102 fail_panic "Could not build libc++!" 103 104 if [ ! -z $VISIBLE_LIBGNUSTL_STATIC ]; then 105 GNUSTL_STATIC_VIS_FLAG=--visible-libgnustl-static 106 fi 107 108 dump "Building $ABIS gnustl binaries..." 109 run $BUILDTOOLS/build-gnu-libstdc++.sh $FLAGS $GNUSTL_STATIC_VIS_FLAG "$SRC_DIR" 110 fail_panic "Could not build gnustl!" 111 112 dump "Building $ABIS libportable binaries..." 113 run $BUILDTOOLS/build-libportable.sh $FLAGS 114 fail_panic "Could not build libportable!" 115 116 dump "Building $ABIS compiler-rt binaries..." 117 run $BUILDTOOLS/build-compiler-rt.sh $FLAGS --src-dir="$SRC_DIR/llvm-$DEFAULT_LLVM_VERSION/compiler-rt" 118 fail_panic "Could not build compiler-rt!" 119 120 if [ "$PACKAGE_DIR" ]; then 121 dump "Done, see $PACKAGE_DIR" 122 else 123 dump "Done" 124 fi 125 126 exit 0 127