Home | History | Annotate | Download | only in tools
      1 #!/bin/sh
      2 #
      3 # Copyright (C) 2010 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 
     18 # Rebuild all prebuilts. This requires that you have a toolchain source tree
     19 #
     20 
     21 . `dirname $0`/prebuilt-common.sh
     22 PROGDIR=`dirname $0`
     23 
     24 NDK_DIR=$ANDROID_NDK_ROOT
     25 register_var_option "--ndk-dir=<path>" NDK_DIR "Put binaries into NDK install directory"
     26 
     27 BUILD_DIR=/tmp/ndk-$USER/build
     28 register_var_option "--build-dir=<path>" BUILD_DIR "Specify temporary build directory"
     29 
     30 ARCHS=$DEFAULT_ARCHS
     31 register_var_option "--arch=<arch>" ARCHS "Specify target architectures"
     32 
     33 SYSTEMS=$HOST_TAG32
     34 if [ "$HOST_TAG32" = "linux-x86" ]; then
     35     SYSTEMS=$SYSTEMS",windows"
     36     # If darwin toolchain exist, build darwin too
     37     if [ -f "${DARWIN_TOOLCHAIN}-gcc" ]; then
     38         SYSTEMS=$SYSTEMS",darwin-x86"
     39     fi
     40 fi
     41 CUSTOM_SYSTEMS=
     42 register_option "--systems=<list>" do_SYSTEMS "Specify host systems"
     43 do_SYSTEMS () { CUSTOM_SYSTEMS=true; SYSTEMS=$1; }
     44 
     45 ALSO_64=
     46 register_option "--also-64" do_ALSO_64 "Also build 64-bit host toolchain"
     47 do_ALSO_64 () { ALSO_64=yes; }
     48 
     49 RELEASE=`date +%Y%m%d`
     50 PACKAGE_DIR=/tmp/ndk-$USER/prebuilt-$RELEASE
     51 register_var_option "--package-dir=<path>" PACKAGE_DIR "Put prebuilt tarballs into <path>."
     52 
     53 DARWIN_SSH=
     54 if [ "$HOST_OS" = "linux" ] ; then
     55 register_var_option "--darwin-ssh=<hostname>" DARWIN_SSH "Specify Darwin hostname for remote build."
     56 fi
     57 
     58 register_try64_option
     59 
     60 PROGRAM_PARAMETERS="<toolchain-src-dir>"
     61 PROGRAM_DESCRIPTION=\
     62 "This script is used to rebuild all host and target prebuilts from scratch.
     63 You will need to give the path of a toolchain source directory, one which
     64 is typically created with the download-toolchain-sources.sh script.
     65 
     66 Unless you use the --ndk-dir option, all binaries will be installed to the
     67 current NDK directory.
     68 
     69 All prebuilts will then be archived into tarball that will be stored into a
     70 specific 'package directory'. Unless you use the --package-dir option, this
     71 will be: $PACKAGE_DIR
     72 
     73 Please read docs/DEV-SCRIPTS-USAGE.TXT for more usage information about this
     74 script.
     75 "
     76 
     77 extract_parameters "$@"
     78 
     79 SRC_DIR="$PARAMETERS"
     80 check_toolchain_src_dir "$SRC_DIR"
     81 
     82 if [ "$DARWIN_SSH" -a -z "$CUSTOM_SYSTEMS" ]; then
     83     SYSTEMS=$SYSTEMS",darwin-x86"
     84 fi
     85 
     86 FLAGS=
     87 if [ "$VERBOSE" = "yes" ]; then
     88     FLAGS=$FLAGS" --verbose"
     89 fi
     90 if [ "$VERBOSE2" = "yes" ]; then
     91     FLAGS=$FLAGS" --verbose"
     92 fi
     93 FLAGS=$FLAGS" --ndk-dir=$NDK_DIR"
     94 FLAGS=$FLAGS" --package-dir=$PACKAGE_DIR"
     95 FLAGS=$FLAGS" --arch=$(spaces_to_commas $ARCHS)"
     96 
     97 HOST_FLAGS=$FLAGS" --systems=$(spaces_to_commas $SYSTEMS)"
     98 if [ "$TRY64" = "yes" ]; then
     99     HOST_FLAGS=$HOST_FLAGS" --try-64"
    100 fi
    101 if [ "$DARWIN_SSH" ]; then
    102     HOST_FLAGS=$HOST_FLAGS" --darwin-ssh=$DARWIN_SSH"
    103 fi
    104 
    105 if [ "$ALSO_64" = "yes" -a "$TRY64" != "yes" ] ; then
    106     $PROGDIR/build-host-prebuilts.sh $HOST_FLAGS "$SRC_DIR" --try-64
    107     fail_panic "Could not build host prebuilts in 64-bit!"
    108 fi
    109 $PROGDIR/build-host-prebuilts.sh $HOST_FLAGS "$SRC_DIR"
    110 fail_panic "Could not build host prebuilts!"
    111 
    112 TARGET_FLAGS=$FLAGS
    113 
    114 $PROGDIR/build-target-prebuilts.sh $TARGET_FLAGS "$SRC_DIR"
    115 fail_panic "Could not build target prebuilts!"
    116 
    117 echo "Done, see $PACKAGE_DIR:"
    118 ls -l $PACKAGE_DIR
    119 
    120 exit 0
    121