Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: platform_tools/android/bin/utils/setup_toolchain.sh

Issue 692953002: Add support for clang to the android build scripts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « platform_tools/android/bin/android_setup.sh ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # 2 #
3 # setup_toolchain.sh: Sets toolchain environment variables used by other scripts . 3 # setup_toolchain.sh: Sets toolchain environment variables used by other scripts .
4 4
5 # Fail-fast if anything in the script fails. 5 # Fail-fast if anything in the script fails.
6 set -e 6 set -e
7 7
8 # check that the preconditions for this script are met 8 # check that the preconditions for this script are met
9 if [ $(type -t verbose) != 'function' ]; then 9 if [ $(type -t verbose) != 'function' ]; then
10 echo "ERROR: The verbose function is expected to be defined" 10 echo "ERROR: The verbose function is expected to be defined"
(...skipping 28 matching lines...) Expand all
39 TOOLCHAIN_DIR=${SCRIPT_DIR}/../toolchains 39 TOOLCHAIN_DIR=${SCRIPT_DIR}/../toolchains
40 if [ $(uname) == "Darwin" ]; then 40 if [ $(uname) == "Darwin" ]; then
41 verbose "Using Mac toolchain." 41 verbose "Using Mac toolchain."
42 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-darwin_v$API_LEVEL 42 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-darwin_v$API_LEVEL
43 else 43 else
44 verbose "Using Linux toolchain." 44 verbose "Using Linux toolchain."
45 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-linux_v$API_LEVEL 45 TOOLCHAIN_TYPE=ndk-r$NDK_REV-$ANDROID_ARCH-linux_v$API_LEVEL
46 fi 46 fi
47 exportVar ANDROID_TOOLCHAIN "${TOOLCHAIN_DIR}/${TOOLCHAIN_TYPE}/bin" 47 exportVar ANDROID_TOOLCHAIN "${TOOLCHAIN_DIR}/${TOOLCHAIN_TYPE}/bin"
48 48
49 # Hack for NDK_REV == 10c to ensure that clang is present as it was
50 # added to the tarball after it was initially distributed.
51 if [ ! -x ${ANDROID_TOOLCHAIN}/clang ]; then
52 rm -rf ${TOOLCHAIN_DIR}/${TOOLCHAIN_TYPE}
53 fi
54
49 # if the toolchain doesn't exist on your machine then we need to fetch it 55 # if the toolchain doesn't exist on your machine then we need to fetch it
50 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then 56 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then
51 mkdir -p $TOOLCHAIN_DIR 57 mkdir -p $TOOLCHAIN_DIR
52 # enter the toolchain directory then download, unpack, and remove the tarbal l 58 # enter the toolchain directory then download, unpack, and remove the tarbal l
53 pushd $TOOLCHAIN_DIR 59 pushd $TOOLCHAIN_DIR
54 TARBALL=ndk-r$NDK_REV-v$API_LEVEL.tgz 60 TARBALL=ndk-r$NDK_REV-v$API_LEVEL.tgz
55 61
56 ${SCRIPT_DIR}/download_toolchains.py \ 62 ${SCRIPT_DIR}/download_toolchains.py \
57 http://chromium-skia-gm.commondatastorage.googleapis.com/android-toolcha ins/$TARBALL \ 63 http://chromium-skia-gm.commondatastorage.googleapis.com/android-toolcha ins/$TARBALL \
58 $TOOLCHAIN_DIR/$TARBALL 64 $TOOLCHAIN_DIR/$TARBALL
59 tar -xzf $TARBALL $TOOLCHAIN_TYPE 65 tar -xzf $TARBALL $TOOLCHAIN_TYPE
60 rm $TARBALL 66 rm $TARBALL
61 popd 67 popd
62 fi 68 fi
63 69
64 verbose "Targeting NDK API $API_LEVEL for use on Android 4.0 (NDK Revision $ND K_REV) and above" 70 verbose "Targeting NDK API $API_LEVEL (NDK Revision $NDK_REV)"
65 } 71 }
66 72
67 #check to see if the toolchain has been defined and if not setup the default too lchain 73 #check to see if the toolchain has been defined and if not setup the default too lchain
68 if [ -z "$ANDROID_TOOLCHAIN" ]; then 74 if [ -z "$ANDROID_TOOLCHAIN" ]; then
69 default_toolchain 75 default_toolchain
70 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then 76 if [ ! -d "$ANDROID_TOOLCHAIN" ]; then
71 echo "ERROR: unable to download/setup the required toolchain (${ANDROID_TOOL CHAIN})" 77 echo "ERROR: unable to download/setup the required toolchain (${ANDROID_TOOL CHAIN})"
72 return 1; 78 return 1;
73 fi 79 fi
74 fi 80 fi
75 81
76 GCC=$(command ls $ANDROID_TOOLCHAIN/*-gcc | head -n1) 82 GCC=$(command ls $ANDROID_TOOLCHAIN/*-gcc | head -n1)
77 if [ -z "$GCC" ]; then 83 if [ -z "$GCC" ]; then
78 echo "ERROR: Could not find Android cross-compiler in: $ANDROID_TOOLCHAIN" 84 echo "ERROR: Could not find Android cross-compiler in: $ANDROID_TOOLCHAIN"
79 return 1 85 return 1
80 fi 86 fi
81 87
82 # Remove the '-gcc' at the end to get the full toolchain prefix 88 # Remove the '-gcc' at the end to get the full toolchain prefix
83 ANDROID_TOOLCHAIN_PREFIX=${GCC%%-gcc} 89 ANDROID_TOOLCHAIN_PREFIX=${GCC%%-gcc}
84 90
85 CCACHE=${ANDROID_MAKE_CCACHE-$(which ccache || true)} 91 CCACHE=${ANDROID_MAKE_CCACHE-$(which ccache || true)}
86 92
87 exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" 93 if [ -z $USE_CLANG ]; then
88 exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++" 94 exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
89 exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc" 95 exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++"
96 exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
97 else
98 # temporarily disable ccache as it is generating errors
tomhudson 2014/10/30 19:17:31 Unrelated change?
djsollen 2014/10/30 19:21:22 no it seems to be generating errors when we combin
99 CCACHE=""
100 exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang"
101 exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++"
102 exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang"
103 fi
90 104
91 exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar" 105 exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar"
92 exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib" 106 exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib"
93 exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy" 107 exportVar OBJCOPY "$ANDROID_TOOLCHAIN_PREFIX-objcopy"
94 exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip" 108 exportVar STRIP "$ANDROID_TOOLCHAIN_PREFIX-strip"
95 109
96 # Create symlinks for nm & readelf and add them to the path so that the ninja 110 # Create symlinks for nm & readelf and add them to the path so that the ninja
97 # build uses them instead of attempting to use the one on the system. 111 # build uses them instead of attempting to use the one on the system.
98 # This is required to build using ninja on a Mac. 112 # This is required to build using ninja on a Mac.
99 ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm 113 if [ $(uname) == "Darwin" ]; then
100 ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf 114 ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm
101 ln -sf $ANDROID_TOOLCHAIN_PREFIX-as $ANDROID_TOOLCHAIN/as 115 ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf
116 ln -sf $ANDROID_TOOLCHAIN_PREFIX-as $ANDROID_TOOLCHAIN/as
117 fi
118
102 exportVar PATH $ANDROID_TOOLCHAIN:$PATH 119 exportVar PATH $ANDROID_TOOLCHAIN:$PATH
OLDNEW
« no previous file with comments | « platform_tools/android/bin/android_setup.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698