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=$DEFAULT_ARCHS
     54 register_var_option "--arch=<arch>" ARCHS "Specify target architecture(s)"
     55 
     56 # set to 'yes' if we should use 'git ls-files' to list the files to
     57 # be copied into the archive.
     58 NO_GIT=no
     59 register_var_option "--no-git" NO_GIT "Don't use git to list input files, take all of them."
     60 
     61 # set of toolchain prebuilts we need to package
     62 TOOLCHAINS=$(get_toolchain_name_list_for_arch arm)
     63 OPTION_TOOLCHAINS=$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 LLVM_VERSION_LIST=$DEFAULT_LLVM_VERSION_LIST
     83 register_var_option "--llvm=<versions>" LLVM_VERSION_LIST "List of LLVM release versions"
     84 
     85 WITH_LIBCXX=
     86 register_var_option "--with-libcxx" WITH_LIBCXX "Package experimental Libc++ sources"
     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 # Do we need to support x86?
    128 ARCHS=$(commas_to_spaces $ARCHS)
    129 echo "$ARCHS" | tr ' ' '\n' | grep -q x86
    130 if [ $? = 0 ] ; then
    131     TRY_X86=yes
    132 else
    133     TRY_X86=no
    134 fi
    135 # Do we need to support mips?
    136 echo "$ARCHS" | tr ' ' '\n' | grep -q mips
    137 if [ $? = 0 ] ; then
    138     TRY_mips=yes
    139 else
    140     TRY_mips=no
    141 fi
    142 
    143 # Compute ABIS from ARCHS
    144 ABIS=
    145 for ARCH in $ARCHS; do
    146     DEFAULT_ABIS=$(get_default_abis_for_arch $ARCH)
    147     if [ -z "$ABIS" ]; then
    148         ABIS=$DEFAULT_ABIS
    149     else
    150         ABIS=$ABIS" $DEFAULT_ABIS"
    151     fi
    152 done
    153 
    154 # Convert comma-separated list to space-separated list
    155 LLVM_VERSION_LIST=$(commas_to_spaces $LLVM_VERSION_LIST)
    156 
    157 # If --arch is used to list x86 as a target architecture, Add x86-4.6 to
    158 # the list of default toolchains to package. That is, unless you also
    159 # explicitely use --toolchains=<list>
    160 #
    161 # Ensure that TOOLCHAINS is space-separated after this.
    162 #
    163 if [ "$OPTION_TOOLCHAINS" != "$TOOLCHAINS" ]; then
    164     TOOLCHAINS=$(commas_to_spaces $OPTION_TOOLCHAINS)
    165 else
    166     if [ "$TRY_X86" = "yes" ]; then
    167         TOOLCHAINS=$TOOLCHAINS" "$(get_toolchain_name_list_for_arch x86)
    168     fi
    169     if [ "$TRY_mips" = "yes" ]; then
    170         TOOLCHAINS=$TOOLCHAINS" "$(get_toolchain_name_list_for_arch mips)
    171     fi
    172     TOOLCHAINS=$(commas_to_spaces $TOOLCHAINS)
    173 fi
    174 
    175 # Check the prebuilt path
    176 #
    177 if [ -n "$PREBUILT_NDK" -a -n "$PREBUILT_DIR" ] ; then
    178     echo "ERROR: You cannot use both --prebuilt-ndk and --prebuilt-dir at the same time."
    179     exit 1
    180 fi
    181 
    182 if [ -z "$PREBUILT_DIR" -a -z "$PREBUILT_NDK" ] ; then
    183     echo "ERROR: You must use one of --prebuilt-dir or --prebuilt-ndk. See --help for details."
    184     exit 1
    185 fi
    186 
    187 # Check the option directory.
    188 if [ -n "$OPTION_OUT_DIR" ] ; then
    189     OUT_DIR="$OPTION_OUT_DIR"
    190     mkdir -p $OUT_DIR
    191     if [ $? != 0 ] ; then
    192         echo "ERROR: Could not create output directory: $OUT_DIR"
    193         exit 1
    194     fi
    195 else
    196     rm -rf $OUT_DIR && mkdir -p $OUT_DIR
    197 fi
    198 
    199 # Handle the prebuilt binaries now
    200 #
    201 if [ -n "$PREBUILT_DIR" ] ; then
    202     if [ ! -d "$PREBUILT_DIR" ] ; then
    203         echo "ERROR: the --prebuilt-dir argument is not a directory: $PREBUILT_DIR"
    204         exit 1
    205     fi
    206     if [ -z "$SYSTEMS" ] ; then
    207         echo "ERROR: Your systems list is empty, use --systems=LIST to specify a different one."
    208         exit 1
    209     fi
    210 else
    211     if [ ! -f "$PREBUILT_NDK" ] ; then
    212         echo "ERROR: the --prebuilt-ndk argument is not a file: $PREBUILT_NDK"
    213         exit 1
    214     fi
    215     # Check that the name ends with the proper host tag
    216     HOST_NDK_SUFFIX="$HOST_TAG.zip"
    217     echo "$PREBUILT_NDK" | grep -q "$HOST_NDK_SUFFIX"
    218     fail_panic "The name of the prebuilt NDK must end in $HOST_NDK_SUFFIX"
    219     SYSTEMS=$HOST_TAG
    220 fi
    221 
    222 echo "Architectures: $ARCHS"
    223 echo "CPU ABIs: $ABIS"
    224 echo "Toolchains: $TOOLCHAINS"
    225 echo "Host systems: $SYSTEMS"
    226 
    227 
    228 # The list of git files to copy into the archives
    229 if [ "$NO_GIT" != "yes" ] ; then
    230     echo "Collecting sources from git (use --no-git to copy all files instead)."
    231     GIT_FILES=`cd $NDK_ROOT_DIR && git ls-files`
    232 else
    233     echo "Collecting all sources files under tree."
    234     # Cleanup everything that is likely to not be part of the final NDK
    235     # i.e. generated files...
    236     rm -rf $NDK_ROOT_DIR/samples/*/obj
    237     rm -rf $NDK_ROOT_DIR/samples/*/libs
    238     # Get all files under the NDK root
    239     GIT_FILES=`cd $NDK_ROOT_DIR && find .`
    240     GIT_FILES=`echo $GIT_FILES | sed -e "s!\./!!g"`
    241 fi
    242 
    243 # temporary directory used for packaging
    244 TMPDIR=$NDK_TMPDIR
    245 
    246 RELEASE_PREFIX=$PREFIX-$RELEASE
    247 
    248 # ensure that the generated files are ug+rx
    249 umask 0022
    250 
    251 # Translate name to 64-bit's counterpart
    252 # $1: prebuilt name
    253 name64 ()
    254 {
    255     local NAME=$1
    256     case $NAME in
    257         *windows)
    258             NAME=${NAME}-x86_64
    259             ;;
    260         *linux-x86|*darwin-x86)
    261             NAME=${NAME}_64
    262             ;;
    263     esac
    264     echo $NAME
    265 }
    266 
    267 # Unpack a prebuilt into specified destination directory
    268 # $1: prebuilt name, relative to $PREBUILT_DIR
    269 # $2: destination directory
    270 # $3: optional destination directory for 64-bit toolchain
    271 # $4: optional flag to use 32-bit prebuilt in place of 64-bit
    272 unpack_prebuilt ()
    273 {
    274     local PREBUILT=
    275     local PREBUILT64=null
    276     local DDIR="$2"
    277     local DDIR64="${3:-$DDIR}"
    278     local USE32="${4:-no}"
    279 
    280     if [ "$TRY64" = "yes" -a "$USE32" = "no" ]; then
    281         PREBUILT=`name64 $1`
    282     else
    283         PREBUILT=$1
    284         PREBUILT64=`name64 $1`
    285     fi
    286 
    287     PREBUILT=${PREBUILT}.tar.bz2
    288     PREBUILT64=${PREBUILT64}.tar.bz2
    289 
    290     echo "Unpacking $PREBUILT"
    291     if [ -f "$PREBUILT_DIR/$PREBUILT" ] ; then
    292         unpack_archive "$PREBUILT_DIR/$PREBUILT" "$DDIR"
    293         fail_panic "Could not unpack prebuilt $PREBUILT. Aborting."
    294         if [ -f "$PREBUILT_DIR/$PREBUILT64" ] ; then
    295             echo "Unpacking $PREBUILT64"
    296             unpack_archive "$PREBUILT_DIR/$PREBUILT64" "$DDIR64"
    297             fail_panic "Could not unpack prebuilt $PREBUILT64. Aborting."
    298         fi
    299     else
    300         echo "WARNING: Could not find $PREBUILT in $PREBUILT_DIR"
    301     fi
    302 }
    303 
    304 # Copy a prebuilt directory from the previous
    305 # $1: Source directory relative to
    306 copy_prebuilt ()
    307 {
    308     local SUBDIR="$1"
    309     if [ -d "$1" ] ; then
    310         echo "Copying: $SUBDIR"
    311         copy_directory "$SUBDIR" "$DSTDIR/$2"
    312     else
    313         echo "Ignored: $SUBDIR"
    314     fi
    315 }
    316 
    317 
    318 rm -rf $TMPDIR && mkdir -p $TMPDIR
    319 
    320 # Unpack the previous NDK package if any
    321 if [ -n "$PREBUILT_NDK" ] ; then
    322     echo "Unpacking prebuilt toolchains from $PREBUILT_NDK"
    323     UNZIP_DIR=$TMPDIR/prev-ndk
    324     rm -rf $UNZIP_DIR && mkdir -p $UNZIP_DIR
    325     fail_panic "Could not create temporary directory: $UNZIP_DIR"
    326     unpack_archive "$PREBUILT_NDK" "$UNZIP_DIR"
    327     fail_panic "Could not unzip NDK package $PREBUILT_NDK"
    328 fi
    329 
    330 # first create the reference ndk directory from the git reference
    331 echo "Creating reference from source files"
    332 REFERENCE=$TMPDIR/reference && rm -rf $REFERENCE/* &&
    333 copy_file_list "$NDK_ROOT_DIR" "$REFERENCE" $GIT_FILES &&
    334 rm -f $REFERENCE/Android.mk
    335 fail_panic "Could not create reference. Aborting."
    336 
    337 # Copy platform and sample files
    338 if [ "$PREBUILT_DIR" ]; then
    339     echo "Unpacking platform files" &&
    340     unpack_archive "$PREBUILT_DIR/platforms.tar.bz2" "$REFERENCE" &&
    341     echo "Unpacking samples files" &&
    342     unpack_archive "$PREBUILT_DIR/samples.tar.bz2" "$REFERENCE"
    343     fail_panic "Could not unpack platform and sample files"
    344 elif [ "$PREBUILT_NDK" ]; then
    345     echo "ERROR: NOT IMPLEMENTED!"
    346     exit 1
    347 else
    348     # copy platform and sample files
    349     echo "Copying platform and sample files"
    350     FLAGS="--src-dir=$DEVELOPMENT_ROOT --dst-dir=$REFERENCE"
    351     if [ "$VERBOSE2" = "yes" ] ; then
    352         FLAGS="$FLAGS --verbose"
    353     fi
    354 
    355     FLAGS="$FLAGS --platform=$(spaces_to_commas $PLATFORMS)"
    356     FLAGS="$FLAGS --arch=$(spaces_to_commas $ARCHS)"
    357     $NDK_ROOT_DIR/build/tools/gen-platforms.sh $FLAGS
    358     fail_panic "Could not copy platform files. Aborting."
    359 fi
    360 
    361 # Remove the source for host tools to make the final package smaller
    362 rm -rf $REFERENCE/sources/host-tools
    363 
    364 # Remove leftovers, just in case...
    365 rm -rf $REFERENCE/samples/*/{obj,libs,build.xml,local.properties,Android.mk} &&
    366 rm -rf $REFERENCE/tests/build/*/{obj,libs} &&
    367 rm -rf $REFERENCE/tests/device/*/{obj,libs}
    368 
    369 if [ "$WITH_LIBCXX" ]; then
    370     # Remove the libc++ test suite, it's large (28 MiB) and not useful for
    371     # developers using the NDK.
    372     rm -rf $REFERENCE/sources/cxx-stl/llvm-libc++/libcxx/test
    373 else
    374     # Remove the libc++ sources, they're not ready for release.
    375     # http://b.android.com/36496
    376     rm -rf $REFERENCE/sources/cxx-stl/llvm-libc++
    377 fi
    378 
    379 # Regenerate HTML documentation, place the files under .../docs/
    380 $NDK_ROOT_DIR/build/tools/build-docs.sh \
    381     --in-dir=$NDK_ROOT_DIR/docs/text \
    382     --out-dir=$REFERENCE/docs
    383 
    384 # copy sources files
    385 if [ -d $DEVELOPMENT_ROOT/sources ] ; then
    386     echo "Copying NDK sources files"
    387     copy_file_list "$DEVELOPMENT_ROOT" "$REFERENCE" "sources"
    388     fail_panic "Could not copy sources. Aborting."
    389 fi
    390 
    391 # Unpack prebuilt C++ runtimes headers and libraries
    392 if [ -z "$PREBUILT_NDK" ]; then
    393     # Unpack gdbserver
    394     for ARCH in $ARCHS; do
    395         unpack_prebuilt $ARCH-gdbserver "$REFERENCE"
    396     done
    397     # Unpack C++ runtimes
    398     for VERSION in $DEFAULT_GCC_VERSION_LIST; do
    399         unpack_prebuilt gnu-libstdc++-headers-$VERSION "$REFERENCE"
    400     done
    401     for ABI in $ABIS; do
    402         unpack_prebuilt gabixx-libs-$ABI "$REFERENCE"
    403         unpack_prebuilt stlport-libs-$ABI "$REFERENCE"
    404         if [ "$WITH_LIBCXX" ]; then
    405             unpack_prebuilt libcxx-libs-$ABI "$REFERENCE"
    406         fi
    407         for VERSION in $DEFAULT_GCC_VERSION_LIST; do
    408             unpack_prebuilt gnu-libstdc++-libs-$VERSION-$ABI "$REFERENCE"
    409         done
    410         unpack_prebuilt libportable-libs-$ABI "$REFERENCE"
    411         unpack_prebuilt compiler-rt-libs-$ABI "$REFERENCE"
    412     done
    413 fi
    414 
    415 # create a release file named 'RELEASE.TXT' containing the release
    416 # name. This is used by the build script to detect whether you're
    417 # invoking the NDK from a release package or from the development
    418 # tree.
    419 #
    420 if [ "$TRY64" = "yes" ]; then
    421     echo "$RELEASE (64-bit)" > $REFERENCE/RELEASE.TXT
    422 else
    423     echo "$RELEASE" > $REFERENCE/RELEASE.TXT
    424 fi
    425 
    426 # Remove un-needed files
    427 rm -f $REFERENCE/CleanSpec.mk
    428 
    429 # now, for each system, create a package
    430 #
    431 DSTDIR=$TMPDIR/$RELEASE_PREFIX
    432 DSTDIR64=${DSTDIR}
    433 if [ "$SEPARATE_64" = "yes" ] ; then
    434     DSTDIR64=$TMPDIR/64/${RELEASE_PREFIX}
    435 fi
    436 
    437 for SYSTEM in $SYSTEMS; do
    438     echo "Preparing package for system $SYSTEM."
    439     BIN_RELEASE=$RELEASE_PREFIX-$SYSTEM
    440     rm -rf "$DSTDIR" "$DSTDIR64" &&
    441     mkdir -p "$DSTDIR" "$DSTDIR64" &&
    442     copy_directory "$REFERENCE" "$DSTDIR"
    443     fail_panic "Could not copy reference. Aborting."
    444 
    445     if [ "$PREBUILT_NDK" ]; then
    446         cd $UNZIP_DIR/android-ndk-* && cp -rP toolchains/* $DSTDIR/toolchains/
    447         fail_panic "Could not copy toolchain files from $PREBUILT_NDK"
    448 
    449         if [ -d "$DSTDIR/$GABIXX_SUBDIR" ]; then
    450             GABIXX_ABIS=$PREBUILT_ABIS
    451             for GABIXX_ABI in $GABIXX_ABIS; do
    452                 copy_prebuilt "$GABIXX_SUBDIR/libs/$GABIXX_ABI" "$GABIXX_SUBDIR/libs"
    453             done
    454         else
    455             echo "WARNING: Could not find GAbi++ source tree!"
    456         fi
    457 
    458         if [ -d "$DSTDIR/$STLPORT_SUBDIR" ] ; then
    459             STLPORT_ABIS=$PREBUILT_ABIS
    460             for STL_ABI in $STLPORT_ABIS; do
    461                 copy_prebuilt "$STLPORT_SUBDIR/libs/$STL_ABI" "$STLPORT_SUBDIR/libs"
    462             done
    463         else
    464             echo "WARNING: Could not find STLport source tree!"
    465         fi
    466 
    467         if [ "$WITH_LIBCXX" ]; then
    468             if [ -d "$DSTDIR/$LIBCXX_SUBDIR" ]; then
    469                 LIBCXX_ABIS=$PREBUILT_ABIS
    470                 for STL_ABI in $LIBCXX_ABIS; do
    471                     copy_prebuilt "$LIBCXX_SUBDIR/libs/$STL_ABI" "$LIBCXX_SUBDIR/libs"
    472                 done
    473             else
    474                 echo "WARNING: Could not find Libc++ source tree!"
    475             fi
    476         fi
    477 
    478         for VERSION in $DEFAULT_GCC_VERSION_LIST; do
    479             copy_prebuilt "$GNUSTL_SUBDIR/$VERSION/include" "$GNUSTL_SUBDIR/$VERSION/"
    480             for STL_ABI in $PREBUILT_ABIS; do
    481                 copy_prebuilt "$GNUSTL_SUBDIR/$VERSION/libs/$STL_ABI" "$GNUSTL_SUBDIR/$VERSION/libs"
    482             done
    483         done
    484 
    485         if [ -d "$DSTDIR/$LIBPORTABLE_SUBDIR" ]; then
    486             LIBPORTABLE_ABIS=$PREBUILT_ABIS
    487             for LIBPORTABLE_ABI in $LIBPORTABLE_ABIS; do
    488                 copy_prebuilt "$LIBPORTABLE_SUBDIR/libs/$LIBPORTABLE_ABI" "$LIBPORTABLE_SUBDIR/libs"
    489             done
    490         else
    491             echo "WARNING: Could not find libportable source tree!"
    492         fi
    493 
    494         if [ -d "$DSTDIR/$COMPILER_RT_SUBDIR" ]; then
    495             COMPILER_RT_ABIS=$PREBUILT_ABIS
    496             for COMPILER_RT_ABI in $COMPILER_RT_ABIS; do
    497                 copy_prebuilt "$COMPILER_RT_SUBDIR/libs/$COMPILER_RT_ABI" "$COMPILER_RT_SUBDIR/libs"
    498             done
    499         else
    500             echo "WARNING: Could not find compiler-rt source tree!"
    501         fi
    502     else
    503         # Unpack toolchains
    504         for TC in $TOOLCHAINS; do
    505             unpack_prebuilt $TC-$SYSTEM "$DSTDIR" "$DSTDIR64"
    506             echo "Removing sysroot for $TC"
    507             rm -rf $DSTDIR/toolchains/$TC/prebuilt/$SYSTEM/sysroot
    508             rm -rf $DSTDIR64/toolchains/$TC/prebuilt/${SYSTEM}_64/sysroot
    509             rm -rf $DSTDIR64/toolchains/$TC/prebuilt/${SYSTEM}-x86_64/sysroot
    510         done
    511         echo "Remove ld.mcld deployed/packaged earlier by accident "
    512         find $DSTDIR/toolchains $DSTDIR64/toolchains  -name "*ld.mcld*" -exec rm -f {} \;
    513 
    514         # Unpack llvm and clang
    515         for LLVM_VERSION in $LLVM_VERSION_LIST; do
    516             unpack_prebuilt llvm-$LLVM_VERSION-$SYSTEM "$DSTDIR" "$DSTDIR64"
    517         done
    518 
    519         unpack_prebuilt ld.mcld-$SYSTEM "$DSTDIR" "$DSTDIR64"
    520 
    521         # Unpack prebuilt ndk-stack and other host tools
    522         unpack_prebuilt ndk-stack-$SYSTEM "$DSTDIR" "$DSTDIR64" "yes"
    523         unpack_prebuilt ndk-depends-$SYSTEM "$DSTDIR" "$DSTDIR64" "yes"
    524         unpack_prebuilt ndk-make-$SYSTEM "$DSTDIR" "$DSTDIR64"
    525         unpack_prebuilt ndk-sed-$SYSTEM "$DSTDIR" "$DSTDIR64"
    526         unpack_prebuilt ndk-awk-$SYSTEM "$DSTDIR" "$DSTDIR64"
    527         unpack_prebuilt ndk-perl-$SYSTEM "$DSTDIR" "$DSTDIR64"
    528         unpack_prebuilt ndk-python-$SYSTEM "$DSTDIR" "$DSTDIR64"
    529 
    530         if [ "$SYSTEM" = "windows" ]; then
    531             unpack_prebuilt toolbox-$SYSTEM "$DSTDIR" "$DSTDIR64"
    532         fi
    533     fi
    534 
    535     # Unpack other host tools
    536     unpack_prebuilt scan-build-view "$DSTDIR" "$DSTDIR64"
    537 
    538     # Create an archive for the final package. Extension depends on the
    539     # host system.
    540     ARCHIVE=$BIN_RELEASE
    541     if [ "$TRY64" = "yes" ]; then
    542         ARCHIVE=`name64 $ARCHIVE`
    543     elif [ "$SYSTEM" = "windows" ]; then
    544         ARCHIVE=$ARCHIVE-x86
    545     fi
    546     case "$SYSTEM" in
    547         windows)
    548             ARCHIVE64="$ARCHIVE-64bit-tools.zip"
    549             ARCHIVE="$ARCHIVE.zip"
    550             ;;
    551         *)
    552             ARCHIVE64="$ARCHIVE-64bit-tools.tar.bz2"
    553             ARCHIVE="$ARCHIVE.tar.bz2"
    554             ;;
    555     esac
    556     echo "Creating $ARCHIVE"
    557     # make all file universally readable, and all executable (including directory)
    558     # universally executable, punt intended
    559     find $DSTDIR $DSTDIR64 -exec chmod a+r {} \;
    560     find $DSTDIR $DSTDIR64 -executable -exec chmod a+x {} \;
    561     pack_archive "$OUT_DIR/$ARCHIVE" "$TMPDIR" "$RELEASE_PREFIX"
    562     fail_panic "Could not create archive: $OUT_DIR/$ARCHIVE"
    563     if [ "$SEPARATE_64" = "yes" ] ; then
    564         pack_archive "$OUT_DIR/$ARCHIVE64" "$TMPDIR/64" "${RELEASE_PREFIX}"
    565         fail_panic "Could not create archive: $OUT_DIR/$ARCHIVE64"
    566     fi
    567 done
    568 
    569 echo "Cleaning up."
    570 rm -rf $TMPDIR/reference
    571 rm -rf $TMPDIR/prev-ndk
    572 
    573 echo "Done, please see packages in $OUT_DIR:"
    574 ls -l $OUT_DIR
    575