• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
28NDK_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#
34PLATFORMS="$API_LEVELS"
35
36# the default release name (use today's date)
37RELEASE=`date +%Y%m%d`
38register_var_option "--release=<name>" RELEASE "Specify release name"
39
40# the directory containing all prebuilts
41PREBUILT_DIR=
42register_var_option "--prebuilt-dir=<path>" PREBUILT_DIR "Specify prebuilt directory"
43
44# a prebuilt NDK archive (.zip file). empty means don't use any
45PREBUILT_NDK=
46register_var_option "--prebuilt-ndk=<file>" PREBUILT_NDK "Specify prebuilt ndk package"
47
48# the list of supported host development systems
49SYSTEMS=$DEFAULT_SYSTEMS
50register_var_option "--systems=<list>" SYSTEMS "Specify host systems"
51
52# ARCH to build for
53ARCHS=$(find_ndk_unknown_archs)
54ARCHS="$DEFAULT_ARCHS $ARCHS"
55register_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.
59NO_GIT=no
60register_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
63OPTION_TOOLCHAINS=
64register_var_option "--toolchains=<list>" OPTION_TOOLCHAINS "Specify list of toolchains."
65
66# set of platforms to package (all by default)
67register_var_option "--platforms=<list>" PLATFORMS "Specify API levels"
68
69# the package prefix
70PREFIX=android-ndk
71register_var_option "--prefix=<name>" PREFIX "Specify package prefix"
72
73# default location for generated packages
74OUT_DIR=/tmp/ndk-$USER/release
75OPTION_OUT_DIR=
76register_var_option "--out-dir=<path>" OPTION_OUT_DIR "Specify output package directory" "$OUT_DIR"
77
78# Find the location of the platforms root directory
79DEVELOPMENT_ROOT=`dirname $ANDROID_NDK_ROOT`/development/ndk
80register_var_option "--development-root=<path>" DEVELOPMENT_ROOT "Specify platforms/samples directory"
81
82GCC_VERSION_LIST="default" # it's arch defined by default so use default keyword
83register_var_option "--gcc-version-list=<vers>" GCC_VERSION_LIST "List of GCC release versions"
84
85LLVM_VERSION_LIST=$DEFAULT_LLVM_VERSION_LIST
86register_var_option "--llvm-version-list=<versions>" LLVM_VERSION_LIST "List of LLVM release versions"
87
88register_try64_option
89
90SEPARATE_64=no
91register_option "--separate-64" do_SEPARATE_64 "Separate 64-bit host toolchain to its own package"
92do_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
101PROGRAM_PARAMETERS=
102PROGRAM_DESCRIPTION=\
103"Package a new set of release packages for the Android NDK.
104
105You will need to have generated one or more prebuilt binary tarballs
106with the build/tools/rebuild-all-prebuilts.sh script. These files should
107be named like <toolname>-<system>.tar.bz2, where <toolname> is an arbitrary
108tool name, and <system> is one of: $SYSTEMS
109
110Use the --prebuilt-dir=<path> option to build release packages from the
111binary tarballs stored in <path>.
112
113Alternatively, you can use --prebuilt-ndk=<file> where <file> is the path
114to a previous NDK release package. It will be used to extract the toolchain
115binaries and copy them to your new release. Only use this for experimental
116package releases.
117
118The generated release packages will be stored in a temporary directory that
119will be printed at the end of the generation process.
120"
121
122extract_parameters "$@"
123
124# Ensure that SYSTEMS is space-separated
125SYSTEMS=$(commas_to_spaces $SYSTEMS)
126
127# Detect unknown archs
128ARCHS=$(commas_to_spaces $ARCHS)
129# FIXME after 64-bit arch become DEFAULT_ARCHS
130UNKNOWN_ARCH=$(filter_out "$DEFAULT_ARCHS arm64 x86_64 mips64" "$ARCHS")
131if [ ! -z "$UNKNOWN_ARCH" ]; then
132    ARCHS=$(filter_out "$UNKNOWN_ARCH" "$ARCHS")
133fi
134
135# Compute ABIS from ARCHS
136ABIS=
137for 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
144done
145
146UNKNOWN_ABIS=$(convert_archs_to_abis $UNKNOWN_ARCH)
147
148# Convert comma-separated list to space-separated list
149LLVM_VERSION_LIST=$(commas_to_spaces $LLVM_VERSION_LIST)
150
151# If --arch is used to list x86 as a target architecture, Add x86-4.6 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#
157if [ "$OPTION_TOOLCHAINS" != "$TOOLCHAINS" ]; then
158    TOOLCHAINS=$(commas_to_spaces $OPTION_TOOLCHAINS)
159else
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)
167fi
168
169if [ "$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
179fi
180
181# Check the prebuilt path
182#
183if [ -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
186fi
187
188if [ -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
191fi
192
193# Check the option directory.
194if [ -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
201else
202    rm -rf $OUT_DIR && mkdir -p $OUT_DIR
203fi
204
205# Handle the prebuilt binaries now
206#
207if [ -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
216else
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
226fi
227
228echo "Architectures: $ARCHS"
229echo "CPU ABIs: $ABIS"
230echo "GCC Toolchains: $TOOLCHAINS"
231echo "LLVM Toolchains: $LLVM_VERSION_LIST"
232echo "Host systems: $SYSTEMS"
233
234
235# The list of git files to copy into the archives
236if [ "$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`
239else
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"`
248fi
249
250# temporary directory used for packaging
251TMPDIR=$NDK_TMPDIR
252
253RELEASE_PREFIX=$PREFIX-$RELEASE
254
255# ensure that the generated files are ug+rx
256umask 0022
257
258# Translate name to 64-bit's counterpart
259# $1: prebuilt name
260name64 ()
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
279unpack_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
313copy_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
325rm -rf $TMPDIR && mkdir -p $TMPDIR
326
327# Unpack the previous NDK package if any
328if [ -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"
335fi
336
337# first create the reference ndk directory from the git reference
338echo "Creating reference from source files"
339REFERENCE=$TMPDIR/reference && rm -rf $REFERENCE/* &&
340copy_file_list "$NDK_ROOT_DIR" "$REFERENCE" $GIT_FILES &&
341rm -f $REFERENCE/Android.mk
342fail_panic "Could not create reference. Aborting."
343
344# Copy platform and sample files
345if [ "$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"
351elif [ "$PREBUILT_NDK" ]; then
352    echo "ERROR: NOT IMPLEMENTED!"
353    exit 1
354else
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."
366fi
367
368# Remove the source for host tools to make the final package smaller
369rm -rf $REFERENCE/sources/host-tools
370
371# Remove leftovers, just in case...
372rm -rf $REFERENCE/samples/*/{obj,libs,build.xml,local.properties,Android.mk} &&
373rm -rf $REFERENCE/tests/build/*/{obj,libs} &&
374rm -rf $REFERENCE/tests/device/*/{obj,libs}
375
376# Regenerate HTML documentation, place the files under .../docs/
377$NDK_ROOT_DIR/build/tools/build-docs.sh \
378    --in-dir=$NDK_ROOT_DIR/docs/text \
379    --out-dir=$REFERENCE/docs
380
381# copy sources files
382if [ -d $DEVELOPMENT_ROOT/sources ] ; then
383    echo "Copying NDK sources files"
384    copy_file_list "$DEVELOPMENT_ROOT" "$REFERENCE" "sources"
385    fail_panic "Could not copy sources. Aborting."
386fi
387
388# Unpack prebuilt C++ runtimes headers and libraries
389if [ -z "$PREBUILT_NDK" ]; then
390    # Unpack gdbserver
391    for ARCH in $ARCHS; do
392        unpack_prebuilt $ARCH-gdbserver "$REFERENCE"
393    done
394    # Unpack C++ runtimes
395    for VERSION in $DEFAULT_GCC_VERSION_LIST; do
396        unpack_prebuilt gnu-libstdc++-headers-$VERSION "$REFERENCE"
397    done
398    for ABI in $ABIS; do
399        unpack_prebuilt gabixx-libs-$ABI "$REFERENCE"
400        unpack_prebuilt stlport-libs-$ABI "$REFERENCE"
401        unpack_prebuilt libcxx-libs-$ABI "$REFERENCE"
402        for VERSION in $DEFAULT_GCC_VERSION_LIST; do
403            unpack_prebuilt gnu-libstdc++-libs-$VERSION-$ABI "$REFERENCE"
404        done
405        unpack_prebuilt libportable-libs-$ABI "$REFERENCE"
406        unpack_prebuilt compiler-rt-libs-$ABI "$REFERENCE"
407        unpack_prebuilt libgccunwind-libs-$ABI "$REFERENCE"
408    done
409fi
410
411# create a release file named 'RELEASE.TXT' containing the release
412# name. This is used by the build script to detect whether you're
413# invoking the NDK from a release package or from the development
414# tree.
415#
416if [ "$TRY64" = "yes" ]; then
417    echo "$RELEASE (64-bit)" > $REFERENCE/RELEASE.TXT
418else
419    echo "$RELEASE" > $REFERENCE/RELEASE.TXT
420fi
421
422# Remove un-needed files
423rm -f $REFERENCE/CleanSpec.mk
424
425# now, for each system, create a package
426#
427DSTDIR=$TMPDIR/$RELEASE_PREFIX
428DSTDIR64=${DSTDIR}
429if [ "$SEPARATE_64" = "yes" ] ; then
430    DSTDIR64=$TMPDIR/64/${RELEASE_PREFIX}
431fi
432
433for SYSTEM in $SYSTEMS; do
434    echo "Preparing package for system $SYSTEM."
435    BIN_RELEASE=$RELEASE_PREFIX-$SYSTEM
436    rm -rf "$DSTDIR" "$DSTDIR64" &&
437    mkdir -p "$DSTDIR" "$DSTDIR64" &&
438    copy_directory "$REFERENCE" "$DSTDIR"
439    fail_panic "Could not copy reference. Aborting."
440
441    # Remove tests containing duplicated files in case-insensitive file system
442    if [ "$SYSTEM" = "windows" -o "$SYSTEM" = "darwin-x86" ]; then
443        rm -rf $DSTDIR/tests/build/c++-stl-source-extensions
444        find $DSTDIR/platforms | sort  | uniq -di | xargs rm
445    fi
446
447    if [ "$PREBUILT_NDK" ]; then
448        cd $UNZIP_DIR/android-ndk-* && cp -rP toolchains/* $DSTDIR/toolchains/
449        fail_panic "Could not copy toolchain files from $PREBUILT_NDK"
450
451        if [ -d "$DSTDIR/$GABIXX_SUBDIR" ]; then
452            GABIXX_ABIS=$PREBUILT_ABIS
453            for GABIXX_ABI in $GABIXX_ABIS; do
454                copy_prebuilt "$GABIXX_SUBDIR/libs/$GABIXX_ABI" "$GABIXX_SUBDIR/libs"
455            done
456        else
457            echo "WARNING: Could not find GAbi++ source tree!"
458        fi
459
460        if [ -d "$DSTDIR/$STLPORT_SUBDIR" ] ; then
461            STLPORT_ABIS=$PREBUILT_ABIS $UNKNOWN_ABIS
462            for STL_ABI in $STLPORT_ABIS; do
463                copy_prebuilt "$STLPORT_SUBDIR/libs/$STL_ABI" "$STLPORT_SUBDIR/libs"
464            done
465        else
466            echo "WARNING: Could not find STLport source tree!"
467        fi
468
469        if [ -d "$DSTDIR/$LIBCXX_SUBDIR" ]; then
470            LIBCXX_ABIS=$PREBUILT_ABIS $UNKNOWN_ABIS
471            for STL_ABI in $LIBCXX_ABIS; do
472                copy_prebuilt "$LIBCXX_SUBDIR/libs/$STL_ABI" "$LIBCXX_SUBDIR/libs"
473            done
474        else
475            echo "WARNING: Could not find Libc++ source tree!"
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
503        if [ -d "$DSTDIR/$GCCUNWIND_SUBDIR" ]; then
504            GCCUNWIND_ABIS=$PREBUILT_ABIS
505            for GCCUNWIND_ABI in $GCCUNWIND_ABIS; do
506                copy_prebuilt "$GCCUNWIND_SUBDIR/libs/$GCCUNWIND_ABI" "$GCCUNWIND_SUBDIR/libs"
507            done
508        else
509            echo "WARNING: Could not find libgccunwind source tree!"
510        fi
511    else
512        # Unpack toolchains
513        for TC in $TOOLCHAINS; do
514            unpack_prebuilt $TC-$SYSTEM "$DSTDIR" "$DSTDIR64"
515            echo "Removing sysroot for $TC"
516            rm -rf $DSTDIR/toolchains/$TC/prebuilt/$SYSTEM/sysroot
517            rm -rf $DSTDIR64/toolchains/$TC/prebuilt/${SYSTEM}_64/sysroot
518            rm -rf $DSTDIR64/toolchains/$TC/prebuilt/${SYSTEM}-x86_64/sysroot
519        done
520        echo "Remove ld.mcld deployed/packaged earlier by accident "
521        find $DSTDIR/toolchains $DSTDIR64/toolchains  -name "*ld.mcld*" -exec rm -f {} \;
522
523        # Unpack llvm and clang
524        for LLVM_VERSION in $LLVM_VERSION_LIST; do
525            unpack_prebuilt llvm-$LLVM_VERSION-$SYSTEM "$DSTDIR" "$DSTDIR64"
526        done
527
528        # Unpack mclinker
529        if [ -n "$LLVM_VERSION_LIST" ]; then
530            unpack_prebuilt ld.mcld-$SYSTEM "$DSTDIR" "$DSTDIR64"
531        fi
532        rm -rf $DSTDIR/toolchains/*l
533        rm -rf $DSTDIR64/toolchains/*l
534
535        # Unpack renderscript tools
536        unpack_prebuilt renderscript-$SYSTEM "$DSTDIR" "$DSTDIR64"
537
538        # Unpack prebuilt ndk-stack and other host tools
539        unpack_prebuilt ndk-stack-$SYSTEM "$DSTDIR" "$DSTDIR64" "yes"
540        unpack_prebuilt ndk-depends-$SYSTEM "$DSTDIR" "$DSTDIR64" "yes"
541        unpack_prebuilt ndk-make-$SYSTEM "$DSTDIR" "$DSTDIR64"
542        unpack_prebuilt ndk-sed-$SYSTEM "$DSTDIR" "$DSTDIR64"
543        unpack_prebuilt ndk-awk-$SYSTEM "$DSTDIR" "$DSTDIR64"
544        unpack_prebuilt ndk-perl-$SYSTEM "$DSTDIR" "$DSTDIR64"
545        unpack_prebuilt ndk-python-$SYSTEM "$DSTDIR" "$DSTDIR64"
546        unpack_prebuilt ndk-yasm-$SYSTEM "$DSTDIR" "$DSTDIR64"
547
548        if [ "$SYSTEM" = "windows" ]; then
549            unpack_prebuilt toolbox-$SYSTEM "$DSTDIR" "$DSTDIR64"
550        fi
551    fi
552
553    # Unpack other host tools
554    unpack_prebuilt scan-build-view "$DSTDIR" "$DSTDIR64"
555
556    # Unpack renderscript headers/libs
557    unpack_prebuilt renderscript "$DSTDIR" "$DSTDIR64"
558
559    # Unpack misc stuff
560    if [ -f "$PREBUILT_DIR/misc.tar.bz2" ]; then
561        unpack_prebuilt misc "$DSTDIR" "$DSTDIR64"
562    fi
563
564    # Create an archive for the final package. Extension depends on the
565    # host system.
566    ARCHIVE=$BIN_RELEASE
567    if [ "$TRY64" = "yes" ]; then
568        ARCHIVE=`name64 $ARCHIVE`
569    elif [ "$SYSTEM" = "windows" ]; then
570        ARCHIVE=$ARCHIVE-x86
571    fi
572    case "$SYSTEM" in
573        windows)
574            ARCHIVE64="$ARCHIVE-64bit-tools.zip"
575            ARCHIVE="$ARCHIVE.zip"
576            ;;
577        *)
578            ARCHIVE64="$ARCHIVE-64bit-tools.tar.bz2"
579            ARCHIVE="$ARCHIVE.tar.bz2"
580            ;;
581    esac
582    echo "Creating $ARCHIVE"
583    # make all file universally readable, and all executable (including directory)
584    # universally executable, punt intended
585    find $DSTDIR $DSTDIR64 -exec chmod a+r {} \;
586    find $DSTDIR $DSTDIR64 -executable -exec chmod a+x {} \;
587    pack_archive "$OUT_DIR/$ARCHIVE" "$TMPDIR" "$RELEASE_PREFIX"
588    fail_panic "Could not create archive: $OUT_DIR/$ARCHIVE"
589    if [ "$SEPARATE_64" = "yes" ] ; then
590        pack_archive "$OUT_DIR/$ARCHIVE64" "$TMPDIR/64" "${RELEASE_PREFIX}"
591        fail_panic "Could not create archive: $OUT_DIR/$ARCHIVE64"
592    fi
593done
594
595echo "Cleaning up."
596rm -rf $TMPDIR/reference
597rm -rf $TMPDIR/prev-ndk
598
599echo "Done, please see packages in $OUT_DIR:"
600ls -l $OUT_DIR
601