Skip to content

Commit 245c428

Browse files
digit-androidAndroid Git Automerger
authored andcommitted
am f3ec7a0: Merge change If72f81fb into eclair
Merge commit 'f3ec7a02777ed9fcbe995711b8cb3f31de01d274' into eclair-mr2 * commit 'f3ec7a02777ed9fcbe995711b8cb3f31de01d274': Add a script to download and package the toolchain sources.
2 parents 12ed1a7 + f3ec7a0 commit 245c428

File tree

1 file changed

+202
-0
lines changed

1 file changed

+202
-0
lines changed
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (C) 2009 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 shell script is used to download the sources of the Android NDK toolchain
18+
# from the git server at android.git.kernel.org and package them in a nice tarball
19+
# that can later be used with the 'built-toolchain.sh' script.
20+
#
21+
22+
# include common function and variable definitions
23+
. `dirname $0`/../core/ndk-common.sh
24+
25+
OPTION_HELP=no
26+
OPTION_RELEASE=
27+
OPTION_GIT=
28+
OPTION_BRANCH=
29+
30+
# the default release name (use today's date)
31+
RELEASE=`date +%Y%m%d`
32+
33+
# the default branch to use
34+
BRANCH=eclair
35+
36+
GITCMD=git
37+
38+
VERBOSE=no
39+
VERBOSE2=no
40+
41+
for opt do
42+
optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
43+
case "$opt" in
44+
--help|-h|-\?) OPTION_HELP=yes
45+
;;
46+
--branch=*)
47+
OPTION_BRANCH="$optarg"
48+
;;
49+
--git=*)
50+
OPTION_GIT="$optarg"
51+
;;
52+
--verbose)
53+
if [ "$VERBOSE" = "yes" ] ; then
54+
VERBOSE2=yes
55+
else
56+
VERBOSE=yes
57+
fi
58+
;;
59+
--release=*)
60+
OPTION_RELEASE=$optarg
61+
;;
62+
*)
63+
echo "unknown option '$opt', use --help"
64+
exit 1
65+
esac
66+
done
67+
68+
if [ $OPTION_HELP = "yes" ] ; then
69+
echo "Download the NDK toolchain sources from android.git.kernel.org and package them."
70+
echo "You will need to run this script before being able to rebuild the NDK toolchain"
71+
echo "binaries from scratch with build/tools/build-toolchain.sh"
72+
echo ""
73+
echo "options (defaults in brackets):"
74+
echo ""
75+
echo " --help print this message"
76+
echo " --branch=<name> specify release branch [$BRANCH]"
77+
echo " --release=<name> specify release name [$RELEASE]"
78+
echo " --git=<executable> use this version of the git tool [$GITCMD]"
79+
echo " --verbose increase verbosity"
80+
echo ""
81+
exit 0
82+
fi
83+
84+
TMPLOG=/tmp/android-ndk-download-toolchain-$$.log
85+
rm -rf $TMPLOG
86+
87+
if [ $VERBOSE = yes ] ; then
88+
run ()
89+
{
90+
echo "##### NEW COMMAND"
91+
echo $@
92+
$@ 2>&1 | tee $TMPLOG
93+
}
94+
log ()
95+
{
96+
echo "LOG: $@"
97+
}
98+
else
99+
echo "To follow download, please use in another terminal: tail -F $TMPLOG"
100+
run ()
101+
{
102+
echo "##### NEW COMMAND" >> $TMPLOG
103+
echo "$@" >> $TMPLOG
104+
$@ 1>$TMPLOG 2>&1
105+
}
106+
log ()
107+
{
108+
echo "$@" > /dev/null
109+
}
110+
fi
111+
112+
if [ -n "$OPTION_RELEASE" ] ; then
113+
RELEASE="$OPTION_RELEASE"
114+
log "Using release name $RELEASE"
115+
else
116+
log "Using default release name $RELEASE"
117+
fi
118+
119+
# Check that 'git' works
120+
if [ -n "$OPTION_GIT" ] ; then
121+
GITCMD="$OPTION_GIT"
122+
log "Using git tool command: '$GITCMD'"
123+
else
124+
log "Using default git tool command."
125+
fi
126+
$GITCMD --version > /dev/null 2>&1
127+
if [ $? != 0 ] ; then
128+
echo "The git tool doesn't seem to work. Please check $GITCMD"
129+
exit 1
130+
fi
131+
log "Git seems to work ok."
132+
133+
if [ -n "$OPTION_BRANCH" ] ; then
134+
BRANCH="$OPTION_BRANCH"
135+
log "Using branch named $BRANCH"
136+
else
137+
log "Using default branch name $BRANCH"
138+
fi
139+
140+
# Create temp directory where everything will be copied
141+
#
142+
PKGNAME=android-ndk-toolchain-$RELEASE
143+
TMPDIR=/tmp/$PKGNAME
144+
log "Creating temporary directory $TMPDIR"
145+
rm -rf $TMPDIR && mkdir $TMPDIR
146+
if [ $? != 0 ] ; then
147+
echo "Could not create temporary directory: $TMPDIR"
148+
fi
149+
150+
# prefix used for all clone operations
151+
GITPREFIX=git://android.git.kernel.org/toolchain
152+
153+
toolchain_clone ()
154+
{
155+
echo "downloading sources for toolchain/$1"
156+
log "cloning $GITPREFIX/$1.git"
157+
run git clone $GITPREFIX/$1.git $1
158+
if [ $? != 0 ] ; then
159+
echo "Could not clone $GITPREFIX/$1.git ?"
160+
exit 1
161+
fi
162+
log "checking out $BRANCH branch of $1.git"
163+
cd $1
164+
run git checkout -b $BRANCH origin/$BRANCH
165+
if [ $? != 0 ] ; then
166+
echo "Could not checkout $1 ?"
167+
exit 1
168+
fi
169+
# get rid of .git directory, we won't need it.
170+
cd ..
171+
log "getting rid of .git directory for $1."
172+
run rm -rf $1/.git
173+
}
174+
175+
176+
cd $TMPDIR
177+
toolchain_clone binutils
178+
toolchain_clone build
179+
toolchain_clone gcc
180+
toolchain_clone gdb
181+
toolchain_clone gmp
182+
#toolchain_clone gold # not sure about this one !
183+
toolchain_clone mpfr
184+
185+
# We only keep one version of gcc and binutils
186+
187+
# we clearly don't need this
188+
log "getting rid of obsolete gcc 4.3.1 sources"
189+
rm -rf $TMPDIR/gcc/gcc-4.3.1
190+
191+
# create the package
192+
PACKAGE=/tmp/$PKGNAME.tar.bz2
193+
echo "Creating package archive $PACKAGE"
194+
cd `dirname $TMPDIR`
195+
run tar cjvf $PACKAGE -C /tmp/$PKGNAME .
196+
if [ $? != 0 ] ; then
197+
echo "Could not package toolchain source archive ?. See $TMPLOG"
198+
exit 1
199+
fi
200+
201+
echo "Toolchain sources downloaded and packaged succesfully at $PACKAGE"
202+
rm -f $TMPLOG

0 commit comments

Comments
 (0)