aboutsummaryrefslogtreecommitdiff
path: root/build-scripts/build-android-toolchain-linaro
blob: 0d05216454d9883b7480636c931a66b7e4c375ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
###############################################################################
# Copyright (c) 2011 Linaro
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
###############################################################################

source "${BUILD_SCRIPT_ROOT}"/helpers

if [ -n "$REPO_SEED_URL" ]; then
    repo-sync-from-seed "${1}"
else
    repo-sync-from-mirror "${1}"
fi

calc_make_jobs

GCC_SRC_TYPE="unk"

WITH_SYSROOT=
if test -n "$SYSROOT_NDK_URL"; then
    wget -nv --no-check-certificate "$SYSROOT_NDK_URL"
    NDK_FILE=`get_url_basename "$SYSROOT_NDK_URL"`
    tar xf $NDK_FILE
    WITH_SYSROOT=--with-sysroot=`echo $PWD/android-ndk-*/platforms/android-9/arch-arm/`
fi

TOOLCHAIN_PREFIX=/tmp/android-toolchain-eabi
rm -rf $TOOLCHAIN_PREFIX

# We likely don't have gcc component from repo sync, but we need a dir
# to put stuff there now.
mkdir -p gcc

# Workaround for packaging issue with gcc-linaro-4.6-2011.07
# GCC_URL=http://launchpad.net/gcc-linaro/4.6/4.6-2011.07/+download/gcc-linaro-4.6-2011.07.tar.bz2
# FIX_GCC_URL=http://launchpad.net/gcc-linaro/4.6/4.6-2011.07/+download/gcc-linaro-4.6-2011.07-0.tar.bz2
# host/path part of FIX_GCC_URL is ignored, only filename is important (but it must be proper URL).
if [ -n "$FIX_GCC_URL" ]; then
    wget -nv --no-check-certificate "$GCC_URL"
    mv `get_url_basename "$GCC_URL"` gcc/`get_url_basename "$FIX_GCC_URL"`
    GCC_URL="$FIX_GCC_URL"
    GCC_SRC_TYPE="tarball"
fi

if [ -n "$GCC_URL" ]; then
        GCC_FILE=`get_url_basename "$GCC_URL"`
        GCC_VERSION=`get_tarball_version "$GCC_FILE"`
fi

if [ -n "$BZR_SEED_URL" ]; then
    time wget -nv --no-check-certificate "$BZR_SEED_URL"
    BZR_SEED_FILE=$(get_url_basename "$BZR_SEED_URL")
    time tar xaf $BZR_SEED_FILE
    cd $(basename $BZR_SEED_FILE .tar.xz)
    time bzr branch "$GCC_URL"
    "${BUILD_SCRIPT_ROOT}/stamp_branch.sh" 4.* 4.*
    GCC_URL=gcc-linaro-$GCC_VERSION-bzr
    mv 4.* ../gcc/$GCC_URL
    cd ..
    GCC_SRC_TYPE="dir"
fi

function fetch_gcc() {
    # Fetch gcc if needed
    if [ ! -f gcc/$GCC_FILE ]; then
        wget -nv --no-check-certificate "$GCC_URL"
        mv $GCC_FILE gcc/$GCC_FILE
    fi
    # Untar gcc
    tar --auto-compress -x -C gcc -f gcc/$GCC_FILE
    GCC_URL=`basename $GCC_FILE .tar.bz2`
    GCC_SRC_TYPE="dir"
}

# Check if need to apply patches
if [ -n "$GCC_PATCH_URL" ]; then
    if [ "$GCC_SRC_TYPE" != "dir" ]; then
        fetch_gcc
    fi

    patches="$GCC_PATCH_URL"
    ifs_save="$IFS"
    IFS=";"
    for p in $patches; do
        wget -nv --no-check-certificate "$p"
        p_file=`get_url_basename "$p"`
        patch -p0 -d gcc/$GCC_URL <$p_file
    done
    IFS="$ifs_save"
fi

mkdir -p objdir
cd objdir

time ../build/linaro-build.sh \
    --toolchain-src=$PWD/.. \
    --prefix=$TOOLCHAIN_PREFIX \
    --with-gcc=$GCC_URL

if [ -z "$TOOLCHAIN_TARBALL" ]; then
    TOOLCHAIN_TARBALL=android-toolchain-eabi-$GCC_VERSION-$BUILD_NUMBER-$BUILD_ID-linux-x86.tar.bz2
fi

mkdir -p ../out/
tar -cj -C `dirname $TOOLCHAIN_PREFIX` \
    -f ../out/$TOOLCHAIN_TARBALL \
    `basename $TOOLCHAIN_PREFIX`

# Dump version of built gcc(s)
for i in $TOOLCHAIN_PREFIX/bin/*-gcc; do
    $i -v
done

# Add BUILD-INFO.txt support
cp ${BUILD_SCRIPT_ROOT}/BUILD-INFO_toolchain.txt ../out/BUILD-INFO.txt