media/webrtc/trunk/build/android/envsetup.sh

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #!/bin/bash
michael@0 2
michael@0 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
michael@0 4 # Use of this source code is governed by a BSD-style license that can be
michael@0 5 # found in the LICENSE file.
michael@0 6
michael@0 7 # Sets up environment for building Chromium on Android. It can either be
michael@0 8 # compiled with the Android tree or using the Android SDK/NDK. To build with
michael@0 9 # NDK/SDK: ". build/android/envsetup.sh --sdk". Environment variable
michael@0 10 # ANDROID_SDK_BUILD=1 will then be defined and used in the rest of the setup to
michael@0 11 # specifiy build type.
michael@0 12
michael@0 13 # When building WebView as part of Android we can't use the SDK. Other builds
michael@0 14 # default to using the SDK.
michael@0 15 # NOTE(yfriedman): This looks unnecessary but downstream the default value
michael@0 16 # should be 0 until all builds switch to SDK/NDK.
michael@0 17 if [[ "${CHROME_ANDROID_BUILD_WEBVIEW}" -eq 1 ]]; then
michael@0 18 export ANDROID_SDK_BUILD=0
michael@0 19 else
michael@0 20 export ANDROID_SDK_BUILD=1
michael@0 21 fi
michael@0 22 # Loop over args in case we add more arguments in the future.
michael@0 23 while [ "$1" != "" ]; do
michael@0 24 case $1 in
michael@0 25 -s | --sdk ) export ANDROID_SDK_BUILD=1 ; shift ;;
michael@0 26 * ) shift ; break ;;
michael@0 27 esac
michael@0 28 done
michael@0 29
michael@0 30 if [[ "${ANDROID_SDK_BUILD}" -eq 1 ]]; then
michael@0 31 echo "Using SDK build"
michael@0 32 fi
michael@0 33
michael@0 34 host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')
michael@0 35
michael@0 36 case "${host_os}" in
michael@0 37 "linux")
michael@0 38 toolchain_dir="linux-x86_64"
michael@0 39 ;;
michael@0 40 "mac")
michael@0 41 toolchain_dir="darwin-x86"
michael@0 42 ;;
michael@0 43 *)
michael@0 44 echo "Host platform ${host_os} is not supported" >& 2
michael@0 45 return 1
michael@0 46 esac
michael@0 47
michael@0 48 CURRENT_DIR="$(readlink -f "$(dirname $BASH_SOURCE)/../../")"
michael@0 49 if [[ -z "${CHROME_SRC}" ]]; then
michael@0 50 # If $CHROME_SRC was not set, assume current directory is CHROME_SRC.
michael@0 51 export CHROME_SRC="${CURRENT_DIR}"
michael@0 52 fi
michael@0 53
michael@0 54 if [[ "${CURRENT_DIR/"${CHROME_SRC}"/}" == "${CURRENT_DIR}" ]]; then
michael@0 55 # If current directory is not in $CHROME_SRC, it might be set for other
michael@0 56 # source tree. If $CHROME_SRC was set correctly and we are in the correct
michael@0 57 # directory, "${CURRENT_DIR/"${CHROME_SRC}"/}" will be "".
michael@0 58 # Otherwise, it will equal to "${CURRENT_DIR}"
michael@0 59 echo "Warning: Current directory is out of CHROME_SRC, it may not be \
michael@0 60 the one you want."
michael@0 61 echo "${CHROME_SRC}"
michael@0 62 fi
michael@0 63
michael@0 64 # Android sdk platform version to use
michael@0 65 export ANDROID_SDK_VERSION=16
michael@0 66
michael@0 67 # Source functions script. The file is in the same directory as this script.
michael@0 68 . "$(dirname $BASH_SOURCE)"/envsetup_functions.sh
michael@0 69
michael@0 70 if [[ "${ANDROID_SDK_BUILD}" -eq 1 ]]; then
michael@0 71 sdk_build_init
michael@0 72 # Sets up environment for building Chromium for Android with source. Expects
michael@0 73 # android environment setup and lunch.
michael@0 74 elif [[ -z "$ANDROID_BUILD_TOP" || \
michael@0 75 -z "$ANDROID_TOOLCHAIN" || \
michael@0 76 -z "$ANDROID_PRODUCT_OUT" ]]; then
michael@0 77 echo "Android build environment variables must be set."
michael@0 78 echo "Please cd to the root of your Android tree and do: "
michael@0 79 echo " . build/envsetup.sh"
michael@0 80 echo " lunch"
michael@0 81 echo "Then try this again."
michael@0 82 echo "Or did you mean NDK/SDK build. Run envsetup.sh with --sdk argument."
michael@0 83 return 1
michael@0 84 elif [[ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]]; then
michael@0 85 webview_build_init
michael@0 86 else
michael@0 87 non_sdk_build_init
michael@0 88 fi
michael@0 89
michael@0 90 # Workaround for valgrind build
michael@0 91 if [[ -n "$CHROME_ANDROID_VALGRIND_BUILD" ]]; then
michael@0 92 # arm_thumb=0 is a workaround for https://bugs.kde.org/show_bug.cgi?id=270709
michael@0 93 DEFINES+=" arm_thumb=0 release_extra_cflags='-fno-inline\
michael@0 94 -fno-omit-frame-pointer -fno-builtin' release_valgrind_build=1\
michael@0 95 release_optimize=1"
michael@0 96 fi
michael@0 97
michael@0 98 # Source a bunch of helper functions
michael@0 99 . ${CHROME_SRC}/build/android/adb_device_functions.sh
michael@0 100
michael@0 101 ANDROID_GOMA_WRAPPER=""
michael@0 102 if [[ -d $GOMA_DIR ]]; then
michael@0 103 ANDROID_GOMA_WRAPPER="$GOMA_DIR/gomacc"
michael@0 104 fi
michael@0 105 export ANDROID_GOMA_WRAPPER
michael@0 106
michael@0 107 # Declare Android are cross compile.
michael@0 108 export GYP_CROSSCOMPILE=1
michael@0 109
michael@0 110 export CXX_target="${ANDROID_GOMA_WRAPPER} \
michael@0 111 $(echo -n ${ANDROID_TOOLCHAIN}/*-g++)"
michael@0 112
michael@0 113 # Performs a gyp_chromium run to convert gyp->Makefile for android code.
michael@0 114 android_gyp() {
michael@0 115 echo "GYP_GENERATORS set to '$GYP_GENERATORS'"
michael@0 116 # http://crbug.com/143889.
michael@0 117 # In case we are doing a Clang build, we have to unset CC_target and
michael@0 118 # CXX_target. Otherwise GYP ends up generating a gcc build (although we set
michael@0 119 # 'clang' to 1). This behavior was introduced by
michael@0 120 # 54d2f6fe6d8a7b9d9786bd1f8540df6b4f46b83f in GYP.
michael@0 121 (
michael@0 122 # Fork to avoid side effects on the user's environment variables.
michael@0 123 if echo "$GYP_DEFINES" | grep -qE '(clang|asan)'; then
michael@0 124 if echo "$CXX_target" | grep -q g++; then
michael@0 125 unset CXX_target
michael@0 126 fi
michael@0 127 fi
michael@0 128 "${CHROME_SRC}/build/gyp_chromium" --depth="${CHROME_SRC}" --check "$@"
michael@0 129 )
michael@0 130 }
michael@0 131
michael@0 132 # FLOCK needs to be null on system that has no flock
michael@0 133 which flock > /dev/null || export FLOCK=

mercurial