Home | History | Annotate | Download | only in tools
      1 #!/bin/sh
      2 #
      3 # Copyright (C) 2009-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 # This script is used to package complete Android NDK release packages.
     18 #
     19 # You will need prebuilt toolchain binary tarballs or a previous
     20 # NDK release package to do that.
     21 #
     22 # See make-release.sh if you want to make a new release completely from
     23 # scratch.
     24 #
     25 
     26 . `dirname $0`/prebuilt-common.sh
     27 
     28 NDK_ROOT_DIR="$ANDROID_NDK_ROOT"
     29 
     30 # the list of platforms / API levels we want to package in
     31 # this release. This can be overriden with the --platforms
     32 # option, see below.
     33 #
     34 PLATFORMS="$API_LEVELS"
     35 
     36 # the default release name (use today's date)
     37 RELEASE=`date +%Y%m%d`
     38 register_var_option "--release=<name>" RELEASE "Specify release name"
     39 
     40 # the directory containing all prebuilts
     41 PREBUILT_DIR=
     42 register_var_option "--prebuilt-dir=<path>" PREBUILT_DIR "Specify prebuilt directory"
     43 
     44 # a prebuilt NDK archive (.zip file). empty means don't use any
     45 PREBUILT_NDK=
     46 register_var_option "--prebuilt-ndk=<file>" PREBUILT_NDK "Specify prebuilt ndk package"
     47 
     48 # the list of supported host development systems
     49 SYSTEMS=$DEFAULT_SYSTEMS
     50 register_var_option "--systems=<list>" SYSTEMS "Specify host systems"
     51 
     52 # ARCH to build for
     53 ARCHS=$(find_ndk_unknown_archs)
     54 ARCHS="$DEFAULT_ARCHS $ARCHS"
     55 register_var_option "--arch=<arch>" ARCHS "Specify target architecture(s)"
     56 
     57 # set to 'yes' if we should use 'git ls-files' to list the files to
     58 # be copied into the archive.
     59 NO_GIT=no
     60 register_var_option "--no-git" NO_GIT "Don't use git to list input files, take all of them."
     61 
     62 # set of toolchain prebuilts we need to package
     63 OPTION_TOOLCHAINS=
     64 register_var_option "--toolchains=<list>" OPTION_TOOLCHAINS "Specify list of toolchains."
     65 
     66 # set of platforms to package (all by default)
     67 register_var_option "--platforms=<list>" PLATFORMS "Specify API levels"
     68 
     69 # the package prefix
     70 PREFIX=android-ndk
     71 register_var_option "--prefix=<name>" PREFIX "Specify package prefix"
     72 
     73 # default location for generated packages
     74 OUT_DIR=/tmp/ndk-$USER/release
     75 OPTION_OUT_DIR=
     76 register_var_option "--out-dir=<path>" OPTION_OUT_DIR "Specify output package directory" "$OUT_DIR"
     77 
     78 # Find the location of the platforms root directory
     79 DEVELOPMENT_ROOT=`dirname $ANDROID_NDK_ROOT`/development/ndk
     80 register_var_option "--development-root=<path>" DEVELOPMENT_ROOT "Specify platforms/samples directory"
     81 
     82 GCC_VERSION_LIST="default" # it's arch defined by default so use default keyword
     83 register_var_option "--gcc-version-list=<vers>" GCC_VERSION_LIST "List of GCC release versions"
     84 
     85 LLVM_VERSION_LIST=$DEFAULT_LLVM_VERSION_LIST
     86 register_var_option "--llvm-version-list=<versions>" LLVM_VERSION_LIST "List of LLVM release versions"
     87 
     88 register_try64_option
     89 
     90 SEPARATE_64=no
     91 register_option "--separate-64" do_SEPARATE_64 "Separate 64-bit host toolchain to its own package"
     92 do_SEPARATE_64 ()
     93 {
     94     if [ "$TRY64" = "yes" ]; then
     95         echo "ERROR: You cannot use both --try-64 and --separate-64 at the same time."
     96         exit 1
     97     fi
     98     SEPARATE_64=yes;
     99 }
    100 
    101 PROGRAM_PARAMETERS=
    102 PROGRAM_DESCRIPTION=\
    103 "Package a new set of release packages for the Android NDK.
    104 
    105 You will need to have generated one or more prebuilt binary tarballs
    106 with the build/tools/rebuild-all-prebuilts.sh script. These files should
    107 be named like <toolname>-<system>.tar.bz2, where <toolname> is an arbitrary
    108 tool name, and <system> is one of: $SYSTEMS
    109 
    110 Use the --prebuilt-dir=<path> option to build release packages from the
    111 binary tarballs stored in <path>.
    112 
    113 Alternatively, you can use --prebuilt-ndk=<file> where <file> is the path
    114 to a previous NDK release package. It will be used to extract the toolchain
    115 binaries and copy them to your new release. Only use this for experimental
    116 package releases.
    117 
    118 The generated release packages will be stored in a temporary directory that
    119 will be printed at the end of the generation process.
    120 "
    121 
    122 extract_parameters "$@"
    123 
    124 # Ensure that SYSTEMS is space-separated
    125 SYSTEMS=$(commas_to_spaces $SYSTEMS)
    126 
    127 # Detect unknown archs
    128 ARCHS=$(commas_to_spaces $ARCHS)
    129 # FIXME after 64-bit arch become DEFAULT_ARCHS
    130 UNKNOWN_ARCH=$(filter_out "$DEFAULT_ARCHS arm64 x86_64 mips64" "$ARCHS")
    131 if [ ! -z "$UNKNOWN_ARCH" ]; then
    132     ARCHS=$(filter_out "$UNKNOWN_ARCH" "$ARCHS")
    133 fi
    134 
    135 # Compute ABIS from ARCHS
    136 ABIS=
    137 for ARCH in $ARCHS; do
    138     DEFAULT_ABIS=$(get_default_abis_for_arch $ARCH)
    139     if [ -z "$ABIS" ]; then
    140         ABIS=$DEFAULT_ABIS
    141     else
    142         ABIS=$ABIS" $DEFAULT_ABIS"
    143     fi
    144 done
    145 
    146 UNKNOWN_ABIS=$(convert_archs_to_abis $UNKNOWN_ARCH)
    147 
    148 # Convert comma-separated list to space-separated list
    149 LLVM_VERSION_LIST=$(commas_to_spaces $LLVM_VERSION_LIST)
    150 
    151 # If --arch is used to list x86 as a target architecture, Add x86-4.8 to
    152 # the list of default toolchains to package. That is, unless you also
    153 # explicitely use --toolchains=<list>
    154 #
    155 # Ensure that TOOLCHAINS is space-separated after this.
    156 #
    157 if [ "$OPTION_TOOLCHAINS" != "$TOOLCHAINS" ]; then
    158     TOOLCHAINS=$(commas_to_spaces $OPTION_TOOLCHAINS)
    159 else
    160     for ARCH in $ARCHS; do
    161        case $ARCH in
    162            arm|arm64|x86|x86_64|mips|mips64) TOOLCHAINS=$TOOLCHAINS" "$(get_toolchain_name_list_for_arch $ARCH) ;;
    163            *) echo "ERROR: Unknown arch to package: $ARCH"; exit 1 ;;
    164        esac
    165     done
    166     TOOLCHAINS=$(commas_to_spaces $TOOLCHAINS)
    167 fi
    168 
    169 if [ "$GCC_VERSION_LIST" != "default" ]; then
    170    TOOLCHAIN_NAMES=
    171    for VERSION in $(commas_to_spaces $GCC_VERSION_LIST); do
    172       for TOOLCHAIN in $TOOLCHAINS; do
    173          if [ $TOOLCHAIN != ${TOOLCHAIN%%$VERSION} ]; then
    174             TOOLCHAIN_NAMES="$TOOLCHAIN $TOOLCHAIN_NAMES"
    175          fi
    176       done
    177    done
    178    TOOLCHAINS=$TOOLCHAIN_NAMES
    179 fi
    180 
    181 # Check the prebuilt path
    182 #
    183 if [ -n "$PREBUILT_NDK" -a -n "$PREBUILT_DIR" ] ; then
    184     echo "ERROR: You cannot use both --prebuilt-ndk and --prebuilt-dir at the same time."
    185     exit 1
    186 fi
    187 
    188 if [ -z "$PREBUILT_DIR" -a -z "$PREBUILT_NDK" ] ; then
    189     echo "ERROR: You must use one of --prebuilt-dir or --prebuilt-ndk. See --help for details."
    190     exit 1
    191 fi
    192 
    193 # Check the option directory.
    194 if [ -n "$OPTION_OUT_DIR" ] ; then
    195     OUT_DIR="$OPTION_OUT_DIR"
    196     mkdir -p $OUT_DIR
    197     if [ $? != 0 ] ; then
    198         echo "ERROR: Could not create output directory: $OUT_DIR"
    199         exit 1
    200     fi
    201 else
    202     rm -rf $OUT_DIR && mkdir -p $OUT_DIR
    203 fi
    204 
    205 # Handle the prebuilt binaries now
    206 #
    207 if [ -n "$PREBUILT_DIR" ] ; then
    208     if [ ! -d "$PREBUILT_DIR" ] ; then
    209         echo "ERROR: the --prebuilt-dir argument is not a directory: $PREBUILT_DIR"
    210         exit 1
    211     fi
    212     if [ -z "$SYSTEMS" ] ; then
    213         echo "ERROR: Your systems list is empty, use --systems=LIST to specify a different one."
    214         exit 1
    215     fi
    216 else
    217     if [ ! -f "$PREBUILT_NDK" ] ; then
    218         echo "ERROR: the --prebuilt-ndk argument is not a file: $PREBUILT_NDK"
    219         exit 1
    220     fi
    221     # Check that the name ends with the proper host tag
    222     HOST_NDK_SUFFIX="$HOST_TAG.zip"
    223     echo "$PREBUILT_NDK" | grep -q "$HOST_NDK_SUFFIX"
    224     fail_panic "The name of the prebuilt NDK must end in $HOST_NDK_SUFFIX"
    225     SYSTEMS=$HOST_TAG
    226 fi
    227 
    228 echo "Architectures: $ARCHS"
    229 echo "CPU ABIs: $ABIS"
    230 echo "GCC Toolchains: $TOOLCHAINS"
    231 echo "LLVM Toolchains: $LLVM_VERSION_LIST"
    232 echo "Host systems: $SYSTEMS"
    233 
    234 
    235 # The list of git files to copy into the archives
    236 if [ "$NO_GIT" != "yes" ] ; then
    237     echo "Collecting sources from git (use --no-git to copy all files instead)."
    238     GIT_FILES=`cd $NDK_ROOT_DIR && git ls-files`
    239 else
    240     echo "Collecting all sources files under tree."
    241     # Cleanup everything that is likely to not be part of the final NDK
    242     # i.e. generated files...
    243     rm -rf $NDK_ROOT_DIR/samples/*/obj
    244     rm -rf $NDK_ROOT_DIR/samples/*/libs
    245     # Get all files under the NDK root
    246     GIT_FILES=`cd $NDK_ROOT_DIR && find .`
    247     GIT_FILES=`echo $GIT_FILES | sed -e "s!\./!!g"`
    248 fi
    249 
    250 # temporary directory used for packaging
    251 TMPDIR=$NDK_TMPDIR
    252 
    253 RELEASE_PREFIX=$PREFIX-$RELEASE
    254 
    255 # ensure that the generated files are ug+rx
    256 umask 0022
    257 
    258 # Translate name to 64-bit's counterpart
    259 # $1: prebuilt name
    260 name64 ()
    261 {
    262     local NAME=$1
    263     case $NAME in
    264         *windows)
    265             NAME=${NAME}-x86_64
    266             ;;
    267         *linux-x86|*darwin-x86)
    268             NAME=${NAME}_64
    269             ;;
    270     esac
    271     echo $NAME
    272 }
    273 
    274 # Unpack a prebuilt into specified destination directory
    275 # $1: prebuilt name, relative to $PREBUILT_DIR
    276 # $2: destination directory
    277 # $3: optional destination directory for 64-bit toolchain
    278 # $4: optional flag to use 32-bit prebuilt in place of 64-bit
    279 unpack_prebuilt ()
    280 {
    281     local PREBUILT=
    282     local PREBUILT64=null
    283     local DDIR="$2"
    284     local DDIR64="${3:-$DDIR}"
    285     local USE32="${4:-no}"
    286 
    287     if [ "$TRY64" = "yes" -a "$USE32" = "no" ]; then
    288         PREBUILT=`name64 $1`
    289     else
    290         PREBUILT=$1
    291         PREBUILT64=`name64 $1`
    292     fi
    293 
    294     PREBUILT=${PREBUILT}.tar.bz2
    295     PREBUILT64=${PREBUILT64}.tar.bz2
    296 
    297     echo "Unpacking $PREBUILT"
    298     if [ -f "$PREBUILT_DIR/$PREBUILT" ] ; then
    299         unpack_archive "$PREBUILT_DIR/$PREBUILT" "$DDIR"
    300         fail_panic "Could not unpack prebuilt $PREBUILT. Aborting."
    301         if [ -f "$PREBUILT_DIR/$PREBUILT64" ] ; then
    302             echo "Unpacking $PREBUILT64"
    303             unpack_archive "$PREBUILT_DIR/$PREBUILT64" "$DDIR64"
    304             fail_panic "Could not unpack prebuilt $PREBUILT64. Aborting."
    305         fi
    306     else
    307         echo "WARNING: Could not find $PREBUILT in $PREBUILT_DIR"
    308     fi
    309 }
    310 
    311 # Copy a prebuilt directory from the previous
    312 # $1: Source directory relative to
    313 copy_prebuilt ()
    314 {
    315     local SUBDIR="$1"
    316     if [ -d "$1" ] ; then
    317         echo "Copying: $SUBDIR"
    318         copy_directory "$SUBDIR" "$DSTDIR/$2"
    319     else
    320         echo "Ignored: $SUBDIR"
    321     fi
    322 }
    323 
    324 
    325 rm -rf $TMPDIR && mkdir -p $TMPDIR
    326 
    327 # Unpack the previous NDK package if any
    328 if [ -n "$PREBUILT_NDK" ] ; then
    329     echo "Unpacking prebuilt toolchains from $PREBUILT_NDK"
    330     UNZIP_DIR=$TMPDIR/prev-ndk
    331     rm -rf $UNZIP_DIR && mkdir -p $UNZIP_DIR
    332     fail_panic "Could not create temporary directory: $UNZIP_DIR"
    333     unpack_archive "$PREBUILT_NDK" "$UNZIP_DIR"
    334     fail_panic "Could not unzip NDK package $PREBUILT_NDK"
    335 fi
    336 
    337 # first create the reference ndk directory from the git reference
    338 echo "Creating reference from source files"
    339 REFERENCE=$TMPDIR/reference && rm -rf $REFERENCE/* &&
    340 copy_file_list "$NDK_ROOT_DIR" "$REFERENCE" $GIT_FILES &&
    341 rm -f $REFERENCE/Android.mk
    342 fail_panic "Could not create reference. Aborting."
    343 
    344 # Copy platform and sample files
    345 if [ "$PREBUILT_DIR" ]; then
    346     echo "Unpacking platform files" &&
    347     unpack_archive "$PREBUILT_DIR/platforms.tar.bz2" "$REFERENCE" &&
    348     echo "Unpacking samples files" &&
    349     unpack_archive "$PREBUILT_DIR/samples.tar.bz2" "$REFERENCE"
    350     fail_panic "Could not unpack platform and sample files"
    351 elif [ "$PREBUILT_NDK" ]; then
    352     echo "ERROR: NOT IMPLEMENTED!"
    353     exit 1
    354 else
    355     # copy platform and sample files
    356     echo "Copying platform and sample files"
    357     FLAGS="--src-dir=$DEVELOPMENT_ROOT --dst-dir=$REFERENCE"
    358     if [ "$VERBOSE2" = "yes" ] ; then
    359         FLAGS="$FLAGS --verbose"
    360     fi
    361 
    362     FLAGS="$FLAGS --platform=$(spaces_to_commas $PLATFORMS)"
    363     FLAGS="$FLAGS --arch=$(spaces_to_commas $ARCHS)"
    364     $NDK_ROOT_DIR/build/tools/gen-platforms.sh $FLAGS
    365     fail_panic "Could not copy platform files. Aborting."
    366 fi
    367 
    368 # Remove the source for host tools to make the final package smaller
    369 rm -rf $REFERENCE/sources/host-tools
    370 
    371 # Remove leftovers, just in case...
    372 rm -rf $REFERENCE/samples/*/{obj,libs,build.xml,local.properties,Android.mk} &&
    373 rm -rf $REFERENCE/tests/build/*/{obj,libs} &&
    374 rm -rf $REFERENCE/tests/device/*/{obj,libs}
    375 
    376 # copy sources files
    377 if [ -d $DEVELOPMENT_ROOT/sources ] ; then
    378     echo "Copying NDK sources files"
    379     copy_file_list "$DEVELOPMENT_ROOT" "$REFERENCE" "sources"
    380     fail_panic "Could not copy sources. Aborting."
    381 fi
    382 
    383 # Unpack prebuilt C++ runtimes headers and libraries
    384 if [ -z "$PREBUILT_NDK" ]; then
    385     # Unpack gdbserver
    386     for ARCH in $ARCHS; do
    387         unpack_prebuilt $ARCH-gdbserver "$REFERENCE"
    388     done
    389     # Unpack C++ runtimes
    390     for VERSION in $DEFAULT_GCC_VERSION_LIST; do
    391         unpack_prebuilt gnu-libstdc++-headers-$VERSION "$REFERENCE"
    392     done
    393     for ABI in $ABIS; do
    394         unpack_prebuilt gabixx-libs-$ABI-g "$REFERENCE"
    395         unpack_prebuilt stlport-libs-$ABI-g "$REFERENCE"
    396         unpack_prebuilt libcxx-libs-$ABI-g "$REFERENCE"
    397         for VERSION in $DEFAULT_GCC_VERSION_LIST; do
    398             unpack_prebuilt gnu-libstdc++-libs-$VERSION-$ABI-g "$REFERENCE"
    399         done
    400         unpack_prebuilt libportable-libs-$ABI "$REFERENCE"
    401         unpack_prebuilt compiler-rt-libs-$ABI "$REFERENCE"
    402         unpack_prebuilt libgccunwind-libs-$ABI "$REFERENCE"
    403     done
    404 fi
    405 
    406 # create a release file named 'RELEASE.TXT' containing the release
    407 # name. This is used by the build script to detect whether you're
    408 # invoking the NDK from a release package or from the development
    409 # tree.
    410 #
    411 if [ "$TRY64" = "yes" ]; then
    412     echo "$RELEASE (64-bit)" > $REFERENCE/RELEASE.TXT
    413 else
    414     echo "$RELEASE" > $REFERENCE/RELEASE.TXT
    415 fi
    416 
    417 # Remove un-needed files
    418 rm -f $REFERENCE/CleanSpec.mk
    419 
    420 # now, for each system, create a package
    421 #
    422 DSTDIR=$TMPDIR/$RELEASE_PREFIX
    423 DSTDIR64=${DSTDIR}
    424 if [ "$SEPARATE_64" = "yes" ] ; then
    425     DSTDIR64=$TMPDIR/64/${RELEASE_PREFIX}
    426 fi
    427 
    428 for SYSTEM in $SYSTEMS; do
    429     echo "Preparing package for system $SYSTEM."
    430     BIN_RELEASE=$RELEASE_PREFIX-$SYSTEM
    431     rm -rf "$DSTDIR" "$DSTDIR64" &&
    432     mkdir -p "$DSTDIR" "$DSTDIR64" &&
    433     copy_directory "$REFERENCE" "$DSTDIR"
    434     fail_panic "Could not copy reference. Aborting."
    435 
    436     if [ "$DSTDIR" != "$DSTDIR64" ]; then
    437         copy_directory "$DSTDIR" "$DSTDIR64"
    438         echo "$RELEASE (64-bit)" > $DSTDIR64/RELEASE.TXT
    439     fi
    440 
    441     if [ "$PREBUILT_NDK" ]; then
    442         cd $UNZIP_DIR/android-ndk-* && cp -rP toolchains/* $DSTDIR/toolchains/
    443         fail_panic "Could not copy toolchain files from $PREBUILT_NDK"
    444 
    445         if [ -d "$DSTDIR/$GABIXX_SUBDIR" ]; then
    446             GABIXX_ABIS=$PREBUILT_ABIS
    447             for GABIXX_ABI in $GABIXX_ABIS; do
    448                 copy_prebuilt "$GABIXX_SUBDIR/libs/$GABIXX_ABI" "$GABIXX_SUBDIR/libs"
    449             done
    450         else
    451             echo "WARNING: Could not find GAbi++ source tree!"
    452         fi
    453 
    454         if [ -d "$DSTDIR/$STLPORT_SUBDIR" ] ; then
    455             STLPORT_ABIS=$PREBUILT_ABIS $UNKNOWN_ABIS
    456             for STL_ABI in $STLPORT_ABIS; do
    457                 copy_prebuilt "$STLPORT_SUBDIR/libs/$STL_ABI" "$STLPORT_SUBDIR/libs"
    458             done
    459         else
    460             echo "WARNING: Could not find STLport source tree!"
    461         fi
    462 
    463         if [ -d "$DSTDIR/$LIBCXX_SUBDIR" ]; then
    464             LIBCXX_ABIS=$PREBUILT_ABIS $UNKNOWN_ABIS
    465             for STL_ABI in $LIBCXX_ABIS; do
    466                 copy_prebuilt "$LIBCXX_SUBDIR/libs/$STL_ABI" "$LIBCXX_SUBDIR/libs"
    467             done
    468         else
    469             echo "WARNING: Could not find Libc++ source tree!"
    470         fi
    471 
    472         for VERSION in $DEFAULT_GCC_VERSION_LIST; do
    473             copy_prebuilt "$GNUSTL_SUBDIR/$VERSION/include" "$GNUSTL_SUBDIR/$VERSION/"
    474             for STL_ABI in $PREBUILT_ABIS; do
    475                 copy_prebuilt "$GNUSTL_SUBDIR/$VERSION/libs/$STL_ABI" "$GNUSTL_SUBDIR/$VERSION/libs"
    476             done
    477         done
    478 
    479         if [ -d "$DSTDIR/$LIBPORTABLE_SUBDIR" ]; then
    480             LIBPORTABLE_ABIS=$PREBUILT_ABIS
    481             for LIBPORTABLE_ABI in $LIBPORTABLE_ABIS; do
    482                 copy_prebuilt "$LIBPORTABLE_SUBDIR/libs/$LIBPORTABLE_ABI" "$LIBPORTABLE_SUBDIR/libs"
    483             done
    484         else
    485             echo "WARNING: Could not find libportable source tree!"
    486         fi
    487 
    488         if [ -d "$DSTDIR/$COMPILER_RT_SUBDIR" ]; then
    489             COMPILER_RT_ABIS=$PREBUILT_ABIS
    490             for COMPILER_RT_ABI in $COMPILER_RT_ABIS; do
    491                 copy_prebuilt "$COMPILER_RT_SUBDIR/libs/$COMPILER_RT_ABI" "$COMPILER_RT_SUBDIR/libs"
    492             done
    493         else
    494             echo "WARNING: Could not find compiler-rt source tree!"
    495         fi
    496 
    497         if [ -d "$DSTDIR/$GCCUNWIND_SUBDIR" ]; then
    498             GCCUNWIND_ABIS=$PREBUILT_ABIS
    499             for GCCUNWIND_ABI in $GCCUNWIND_ABIS; do
    500                 copy_prebuilt "$GCCUNWIND_SUBDIR/libs/$GCCUNWIND_ABI" "$GCCUNWIND_SUBDIR/libs"
    501             done
    502         else
    503             echo "WARNING: Could not find libgccunwind source tree!"
    504         fi
    505     else
    506         # Unpack toolchains
    507         for TC in $TOOLCHAINS; do
    508             unpack_prebuilt $TC-$SYSTEM "$DSTDIR" "$DSTDIR64"
    509             echo "Removing sysroot for $TC"
    510             rm -rf $DSTDIR/toolchains/$TC/prebuilt/$SYSTEM/sysroot
    511             rm -rf $DSTDIR64/toolchains/$TC/prebuilt/${SYSTEM}_64/sysroot
    512             rm -rf $DSTDIR64/toolchains/$TC/prebuilt/${SYSTEM}-x86_64/sysroot
    513         done
    514         echo "Remove ld.mcld deployed/packaged earlier by accident "
    515         find $DSTDIR/toolchains $DSTDIR64/toolchains  -name "*ld.mcld*" -exec rm -f {} \;
    516 
    517         # Unpack clang/llvm
    518         for LLVM_VERSION in $LLVM_VERSION_LIST; do
    519             unpack_prebuilt llvm-$LLVM_VERSION-$SYSTEM "$DSTDIR" "$DSTDIR64"
    520         done
    521 
    522         # Unpack mclinker
    523         if [ -n "$LLVM_VERSION_LIST" ]; then
    524             unpack_prebuilt ld.mcld-$SYSTEM "$DSTDIR" "$DSTDIR64"
    525         fi
    526         rm -rf $DSTDIR/toolchains/*l
    527         rm -rf $DSTDIR64/toolchains/*l
    528 
    529         # Unpack renderscript tools
    530         unpack_prebuilt renderscript-$SYSTEM "$DSTDIR" "$DSTDIR64"
    531 
    532         # Unpack prebuilt ndk-stack and other host tools
    533         unpack_prebuilt ndk-stack-$SYSTEM "$DSTDIR" "$DSTDIR64" "yes"
    534         unpack_prebuilt ndk-depends-$SYSTEM "$DSTDIR" "$DSTDIR64" "yes"
    535         unpack_prebuilt ndk-make-$SYSTEM "$DSTDIR" "$DSTDIR64"
    536         unpack_prebuilt ndk-awk-$SYSTEM "$DSTDIR" "$DSTDIR64"
    537         unpack_prebuilt ndk-perl-$SYSTEM "$DSTDIR" "$DSTDIR64"
    538         unpack_prebuilt ndk-python-$SYSTEM "$DSTDIR" "$DSTDIR64"
    539         unpack_prebuilt ndk-yasm-$SYSTEM "$DSTDIR" "$DSTDIR64"
    540 
    541         if [ "$SYSTEM" = "windows" ]; then
    542             unpack_prebuilt toolbox-$SYSTEM "$DSTDIR" "$DSTDIR64"
    543         fi
    544     fi
    545 
    546     # Unpack other host tools
    547     unpack_prebuilt scan-build-view "$DSTDIR" "$DSTDIR64"
    548 
    549     # Unpack renderscript headers/libs
    550     unpack_prebuilt renderscript "$DSTDIR" "$DSTDIR64"
    551 
    552     # Unpack misc stuff
    553     if [ -f "$PREBUILT_DIR/misc.tar.bz2" ]; then
    554         unpack_prebuilt misc "$DSTDIR" "$DSTDIR64"
    555     fi
    556 
    557     # Remove duplicated files in case-insensitive file system
    558     if [ "$SYSTEM" = "windows" -o "$SYSTEM" = "darwin-x86" ]; then
    559         rm -rf $DSTDIR/tests/build/c++-stl-source-extensions
    560         rm -rf $DSTDIR64/tests/build/c++-stl-source-extensions
    561         find "$DSTDIR/platforms" | sort -f | uniq -di | xargs rm
    562         find "$DSTDIR64/platforms" | sort -f | uniq -di | xargs rm
    563     fi
    564 
    565     # Remove include-fixed/linux/a.out.h.   See b.android.com/73728
    566     find "$DSTDIR/toolchains" "$DSTDIR64/toolchains" -name a.out.h | grep include-fixed/ | xargs rm
    567 
    568     # Create an archive for the final package. Extension depends on the
    569     # host system.
    570     ARCHIVE=$BIN_RELEASE
    571     if [ "$TRY64" = "yes" ]; then
    572         ARCHIVE=`name64 $ARCHIVE`
    573     elif [ "$SYSTEM" = "windows" ]; then
    574         ARCHIVE=$ARCHIVE-x86
    575     fi
    576     case "$SYSTEM" in
    577         windows)
    578             ARCHIVE64="${ARCHIVE}_64.zip"
    579             ARCHIVE="$ARCHIVE.zip"
    580             ;;
    581         *)
    582             ARCHIVE64="${ARCHIVE}_64.tar.bz2"
    583             ARCHIVE="$ARCHIVE.tar.bz2"
    584             ;;
    585     esac
    586     if [ "$TRY64" = "yes" ]; then
    587         ARCHIVE=$ARCHIVE64
    588     fi
    589     echo "Creating $ARCHIVE"
    590     # make all file universally readable, and all executable (including directory)
    591     # universally executable, punt intended
    592     find $DSTDIR $DSTDIR64 -exec chmod a+r {} \;
    593     find $DSTDIR $DSTDIR64 -executable -exec chmod a+x {} \;
    594     pack_archive "$OUT_DIR/$ARCHIVE" "$TMPDIR" "$RELEASE_PREFIX"
    595     fail_panic "Could not create archive: $OUT_DIR/$ARCHIVE"
    596     if [ "$SEPARATE_64" = "yes" ] ; then
    597         pack_archive "$OUT_DIR/$ARCHIVE64" "$TMPDIR/64" "${RELEASE_PREFIX}"
    598         fail_panic "Could not create archive: $OUT_DIR/$ARCHIVE64"
    599     fi
    600 done
    601 
    602 echo "Cleaning up."
    603 rm -rf $TMPDIR/reference
    604 rm -rf $TMPDIR/prev-ndk
    605 
    606 echo "Done, please see packages in $OUT_DIR:"
    607 ls -l $OUT_DIR
    608