blob: cdde0ced23fba0564ca3d4838cd3fb175aa0dc64 [file] [log] [blame]
[email protected]ec5dcded2011-09-26 21:40:381#!/bin/bash
2
[email protected]94506282012-01-06 13:10:073# Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]ec5dcded2011-09-26 21:40:384# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
[email protected]0115f042012-07-27 20:36:537# Sets up environment for building Chromium on Android. It can either be
8# compiled with the Android tree or using the Android SDK/NDK. To build with
[email protected]9f7b7642012-10-23 00:29:149# NDK/SDK: ". build/android/envsetup.sh". Environment variable
[email protected]0115f042012-07-27 20:36:5310# ANDROID_SDK_BUILD=1 will then be defined and used in the rest of the setup to
11# specifiy build type.
[email protected]ec5dcded2011-09-26 21:40:3812
[email protected]ed5f0192012-11-08 18:11:0213# Source functions script. The file is in the same directory as this script.
14. "$(dirname $BASH_SOURCE)"/envsetup_functions.sh
15
16export ANDROID_SDK_BUILD=1 # Default to SDK build.
17
18process_options "$@"
19
[email protected]0d7291e2012-10-04 19:16:0820# When building WebView as part of Android we can't use the SDK. Other builds
21# default to using the SDK.
[email protected]0d7291e2012-10-04 19:16:0822if [[ "${CHROME_ANDROID_BUILD_WEBVIEW}" -eq 1 ]]; then
23 export ANDROID_SDK_BUILD=0
[email protected]0d7291e2012-10-04 19:16:0824fi
[email protected]4e2e2e2a2011-10-25 16:12:2425
[email protected]0115f042012-07-27 20:36:5326if [[ "${ANDROID_SDK_BUILD}" -eq 1 ]]; then
27 echo "Using SDK build"
[email protected]ec5dcded2011-09-26 21:40:3828fi
29
[email protected]8f773622012-11-15 20:34:2930# Get host architecture, and abort if it is 32-bit, unless --try-32
31# is also used.
32host_arch=$(uname -m)
33case "${host_arch}" in
34 x86_64) # pass
35 ;;
36 i?86)
37 if [[ -z "${try_32bit_host_build}" ]]; then
38 echo "ERROR: Android build requires a 64-bit host build machine."
39 echo "If you really want to try it on this machine, use the \
40--try-32bit-host flag."
41 echo "Be warned that this may fail horribly at link time, due \
42very large binaries."
43 return 1
44 else
45 echo "WARNING: 32-bit host build enabled. Here be dragons!"
46 host_arch=x86
47 fi
48 ;;
49 *)
50 echo "ERROR: Unsupported host architecture (${host_arch})."
51 echo "Try running this script on a Linux/x86_64 machine instead."
52 return 1
53esac
54
[email protected]ec5dcded2011-09-26 21:40:3855host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')
56
57case "${host_os}" in
58 "linux")
[email protected]8f773622012-11-15 20:34:2959 toolchain_dir="linux-${host_arch}"
[email protected]ec5dcded2011-09-26 21:40:3860 ;;
61 "mac")
[email protected]8f773622012-11-15 20:34:2962 toolchain_dir="darwin-${host_arch}"
[email protected]ec5dcded2011-09-26 21:40:3863 ;;
64 *)
65 echo "Host platform ${host_os} is not supported" >& 2
66 return 1
67esac
68
[email protected]0115f042012-07-27 20:36:5369CURRENT_DIR="$(readlink -f "$(dirname $BASH_SOURCE)/../../")"
[email protected]e3da78222012-09-11 18:03:5270if [[ -z "${CHROME_SRC}" ]]; then
[email protected]4f0dd342012-02-14 00:41:5571 # If $CHROME_SRC was not set, assume current directory is CHROME_SRC.
[email protected]1c898c962012-07-11 10:23:5272 export CHROME_SRC="${CURRENT_DIR}"
[email protected]f7247252012-05-30 07:44:2173fi
74
[email protected]e3da78222012-09-11 18:03:5275if [[ "${CURRENT_DIR/"${CHROME_SRC}"/}" == "${CURRENT_DIR}" ]]; then
[email protected]f7247252012-05-30 07:44:2176 # If current directory is not in $CHROME_SRC, it might be set for other
77 # source tree. If $CHROME_SRC was set correctly and we are in the correct
[email protected]1c898c962012-07-11 10:23:5278 # directory, "${CURRENT_DIR/"${CHROME_SRC}"/}" will be "".
79 # Otherwise, it will equal to "${CURRENT_DIR}"
[email protected]f7247252012-05-30 07:44:2180 echo "Warning: Current directory is out of CHROME_SRC, it may not be \
81the one you want."
82 echo "${CHROME_SRC}"
[email protected]ec5dcded2011-09-26 21:40:3883fi
84
[email protected]456b2962012-08-08 04:47:0285# Android sdk platform version to use
86export ANDROID_SDK_VERSION=16
87
[email protected]e3da78222012-09-11 18:03:5288if [[ "${ANDROID_SDK_BUILD}" -eq 1 ]]; then
[email protected]cbb64592012-10-31 17:25:2089 if [[ -z "${TARGET_ARCH}" ]]; then
90 return 1
91 fi
[email protected]0115f042012-07-27 20:36:5392 sdk_build_init
93# Sets up environment for building Chromium for Android with source. Expects
94# android environment setup and lunch.
[email protected]e3da78222012-09-11 18:03:5295elif [[ -z "$ANDROID_BUILD_TOP" || \
96 -z "$ANDROID_TOOLCHAIN" || \
97 -z "$ANDROID_PRODUCT_OUT" ]]; then
[email protected]0115f042012-07-27 20:36:5398 echo "Android build environment variables must be set."
99 echo "Please cd to the root of your Android tree and do: "
100 echo " . build/envsetup.sh"
101 echo " lunch"
102 echo "Then try this again."
[email protected]9f7b7642012-10-23 00:29:14103 echo "Or did you mean NDK/SDK build. Run envsetup.sh without any arguments."
[email protected]ec5dcded2011-09-26 21:40:38104 return 1
[email protected]0d7291e2012-10-04 19:16:08105elif [[ -n "$CHROME_ANDROID_BUILD_WEBVIEW" ]]; then
106 webview_build_init
[email protected]ec5dcded2011-09-26 21:40:38107fi
108
[email protected]0115f042012-07-27 20:36:53109# Workaround for valgrind build
[email protected]e3da78222012-09-11 18:03:52110if [[ -n "$CHROME_ANDROID_VALGRIND_BUILD" ]]; then
[email protected]0115f042012-07-27 20:36:53111# arm_thumb=0 is a workaround for https://bugs.kde.org/show_bug.cgi?id=270709
112 DEFINES+=" arm_thumb=0 release_extra_cflags='-fno-inline\
113 -fno-omit-frame-pointer -fno-builtin' release_valgrind_build=1\
114 release_optimize=1"
115fi
116
117# Source a bunch of helper functions
118. ${CHROME_SRC}/build/android/adb_device_functions.sh
[email protected]73919ea2012-04-26 00:48:41119
[email protected]c564ba12012-06-04 23:39:58120ANDROID_GOMA_WRAPPER=""
121if [[ -d $GOMA_DIR ]]; then
122 ANDROID_GOMA_WRAPPER="$GOMA_DIR/gomacc"
123fi
124export ANDROID_GOMA_WRAPPER
125
[email protected]e1b37ddd2012-09-24 19:24:36126# Declare Android are cross compile.
127export GYP_CROSSCOMPILE=1
128
[email protected]ec5dcded2011-09-26 21:40:38129# Performs a gyp_chromium run to convert gyp->Makefile for android code.
130android_gyp() {
[email protected]d0245a12012-10-18 22:08:06131 # This is just a simple wrapper of gyp_chromium, please don't add anything
132 # in this function.
[email protected]829a8982012-06-14 08:03:50133 echo "GYP_GENERATORS set to '$GYP_GENERATORS'"
[email protected]8d9927c42012-09-24 18:31:58134 (
[email protected]8d9927c42012-09-24 18:31:58135 "${CHROME_SRC}/build/gyp_chromium" --depth="${CHROME_SRC}" --check "$@"
136 )
[email protected]ec5dcded2011-09-26 21:40:38137}
138
[email protected]0115f042012-07-27 20:36:53139# FLOCK needs to be null on system that has no flock
140which flock > /dev/null || export FLOCK=