1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/webrtc/trunk/build/android/envsetup.sh Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,133 @@ 1.4 +#!/bin/bash 1.5 + 1.6 +# Copyright (c) 2012 The Chromium Authors. All rights reserved. 1.7 +# Use of this source code is governed by a BSD-style license that can be 1.8 +# found in the LICENSE file. 1.9 + 1.10 +# Sets up environment for building Chromium on Android. It can either be 1.11 +# compiled with the Android tree or using the Android SDK/NDK. To build with 1.12 +# NDK/SDK: ". build/android/envsetup.sh --sdk". Environment variable 1.13 +# ANDROID_SDK_BUILD=1 will then be defined and used in the rest of the setup to 1.14 +# specifiy build type. 1.15 + 1.16 +# When building WebView as part of Android we can't use the SDK. Other builds 1.17 +# default to using the SDK. 1.18 +# NOTE(yfriedman): This looks unnecessary but downstream the default value 1.19 +# should be 0 until all builds switch to SDK/NDK. 1.20 +if [[ "${CHROME_ANDROID_BUILD_WEBVIEW}" -eq 1 ]]; then 1.21 + export ANDROID_SDK_BUILD=0 1.22 +else 1.23 + export ANDROID_SDK_BUILD=1 1.24 +fi 1.25 +# Loop over args in case we add more arguments in the future. 1.26 +while [ "$1" != "" ]; do 1.27 + case $1 in 1.28 + -s | --sdk ) export ANDROID_SDK_BUILD=1 ; shift ;; 1.29 + * ) shift ; break ;; 1.30 + esac 1.31 +done 1.32 + 1.33 +if [[ "${ANDROID_SDK_BUILD}" -eq 1 ]]; then 1.34 + echo "Using SDK build" 1.35 +fi 1.36 + 1.37 +host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/') 1.38 + 1.39 +case "${host_os}" in 1.40 + "linux") 1.41 + toolchain_dir="linux-x86_64" 1.42 + ;; 1.43 + "mac") 1.44 + toolchain_dir="darwin-x86" 1.45 + ;; 1.46 + *) 1.47 + echo "Host platform ${host_os} is not supported" >& 2 1.48 + return 1 1.49 +esac 1.50 + 1.51 +CURRENT_DIR="$(readlink -f "$(dirname $BASH_SOURCE)/../../")" 1.52 +if [[ -z "${CHROME_SRC}" ]]; then 1.53 + # If $CHROME_SRC was not set, assume current directory is CHROME_SRC. 1.54 + export CHROME_SRC="${CURRENT_DIR}" 1.55 +fi 1.56 + 1.57 +if [[ "${CURRENT_DIR/"${CHROME_SRC}"/}" == "${CURRENT_DIR}" ]]; then 1.58 + # If current directory is not in $CHROME_SRC, it might be set for other 1.59 + # source tree. If $CHROME_SRC was set correctly and we are in the correct 1.60 + # directory, "${CURRENT_DIR/"${CHROME_SRC}"/}" will be "". 1.61 + # Otherwise, it will equal to "${CURRENT_DIR}" 1.62 + echo "Warning: Current directory is out of CHROME_SRC, it may not be \ 1.63 +the one you want." 1.64 + echo "${CHROME_SRC}" 1.65 +fi 1.66 + 1.67 +# Android sdk platform version to use 1.68 +export ANDROID_SDK_VERSION=16 1.69 + 1.70 +# Source functions script. The file is in the same directory as this script. 1.71 +. "$(dirname $BASH_SOURCE)"/envsetup_functions.sh 1.72 + 1.73 +if [[ "${ANDROID_SDK_BUILD}" -eq 1 ]]; then 1.74 + sdk_build_init 1.75 +# Sets up environment for building Chromium for Android with source. Expects 1.76 +# android environment setup and lunch. 1.77 +elif [[ -z "$ANDROID_BUILD_TOP" || \ 1.78 + -z "$ANDROID_TOOLCHAIN" || \ 1.79 + -z "$ANDROID_PRODUCT_OUT" ]]; then 1.80 + echo "Android build environment variables must be set." 1.81 + echo "Please cd to the root of your Android tree and do: " 1.82 + echo " . build/envsetup.sh" 1.83 + echo " lunch" 1.84 + echo "Then try this again." 1.85 + echo "Or did you mean NDK/SDK build. Run envsetup.sh with --sdk argument." 1.86 + return 1 1.87 +elif [[ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]]; then 1.88 + webview_build_init 1.89 +else 1.90 + non_sdk_build_init 1.91 +fi 1.92 + 1.93 +# Workaround for valgrind build 1.94 +if [[ -n "$CHROME_ANDROID_VALGRIND_BUILD" ]]; then 1.95 +# arm_thumb=0 is a workaround for https://bugs.kde.org/show_bug.cgi?id=270709 1.96 + DEFINES+=" arm_thumb=0 release_extra_cflags='-fno-inline\ 1.97 + -fno-omit-frame-pointer -fno-builtin' release_valgrind_build=1\ 1.98 + release_optimize=1" 1.99 +fi 1.100 + 1.101 +# Source a bunch of helper functions 1.102 +. ${CHROME_SRC}/build/android/adb_device_functions.sh 1.103 + 1.104 +ANDROID_GOMA_WRAPPER="" 1.105 +if [[ -d $GOMA_DIR ]]; then 1.106 + ANDROID_GOMA_WRAPPER="$GOMA_DIR/gomacc" 1.107 +fi 1.108 +export ANDROID_GOMA_WRAPPER 1.109 + 1.110 +# Declare Android are cross compile. 1.111 +export GYP_CROSSCOMPILE=1 1.112 + 1.113 +export CXX_target="${ANDROID_GOMA_WRAPPER} \ 1.114 + $(echo -n ${ANDROID_TOOLCHAIN}/*-g++)" 1.115 + 1.116 +# Performs a gyp_chromium run to convert gyp->Makefile for android code. 1.117 +android_gyp() { 1.118 + echo "GYP_GENERATORS set to '$GYP_GENERATORS'" 1.119 + # http://crbug.com/143889. 1.120 + # In case we are doing a Clang build, we have to unset CC_target and 1.121 + # CXX_target. Otherwise GYP ends up generating a gcc build (although we set 1.122 + # 'clang' to 1). This behavior was introduced by 1.123 + # 54d2f6fe6d8a7b9d9786bd1f8540df6b4f46b83f in GYP. 1.124 + ( 1.125 + # Fork to avoid side effects on the user's environment variables. 1.126 + if echo "$GYP_DEFINES" | grep -qE '(clang|asan)'; then 1.127 + if echo "$CXX_target" | grep -q g++; then 1.128 + unset CXX_target 1.129 + fi 1.130 + fi 1.131 + "${CHROME_SRC}/build/gyp_chromium" --depth="${CHROME_SRC}" --check "$@" 1.132 + ) 1.133 +} 1.134 + 1.135 +# FLOCK needs to be null on system that has no flock 1.136 +which flock > /dev/null || export FLOCK=