1#!/bin/bash
2
3# Copyright (c) 2012 The Chromium Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# This script runs gyp with the configuration required to build WebView in the
8# Android build system. It is not necessary to source build/android/envsetup.sh
9# before running this script.
10
11set -e
12
13PLATFORM=${1:-linux-arm}
14echo "Generating makefiles for $PLATFORM"
15
16export PYTHONDONTWRITEBYTECODE=1
17
18CHROME_SRC="$(readlink -f "$(dirname "$0")/../..")"
19GYP="${CHROME_SRC}/build/gyp_chromium"
20
21# Use the latest API in the AOSP prebuilts directory (change with AOSP roll).
22android_sdk_version=18
23
24# For the WebView build we always use the SDK in the Android tree.
25export ANDROID_SDK_ROOT=${ANDROID_BUILD_TOP}/prebuilts/sdk/\
26${android_sdk_version}
27
28DEFINES="OS=android"
29DEFINES+=" android_webview_build=1"
30
31# We need to supply SDK paths relative to the top of the Android tree to make
32# sure the generated Android makefiles are portable, as they will be checked
33# into the Android tree.
34android_sdk=$(python -c \
35    "import os.path; print os.path.relpath('${ANDROID_SDK_ROOT}', \
36    '${ANDROID_BUILD_TOP}')")
37DEFINES+=" android_src=\$(PWD)"
38DEFINES+=" android_ndk_root=ndk_root_unused_in_webview_build"
39DEFINES+=" android_sdk=\$(PWD)/${android_sdk}"
40DEFINES+=" android_sdk_root=\$(PWD)/${android_sdk}"
41DEFINES+=" android_sdk_version=sdk_version_unused_in_webview_build"
42DEFINES+=" android_toolchain=${ANDROID_TOOLCHAIN}"
43
44# TODO: Get rid of this block, crbug.com/334021
45if [[ -n "$CHROME_ANDROID_WEBVIEW_OFFICIAL_BUILD" ]]; then
46  DEFINES+=" logging_like_official_build=1"
47  DEFINES+=" tracing_like_official_build=1"
48fi
49
50export GYP_DEFINES="${GYP_DEFINES} ${DEFINES}"
51
52FLAGS="-f android -Gdefault_target=libwebviewchromium -Glimit_to_target_all=1 "\
53"--depth=${CHROME_SRC} ${CHROME_SRC}/android_webview/android_webview.gyp"
54
55for host_os in linux mac; do
56  host_platform=$(echo $host_os | sed -e 's/mac/darwin/')
57  android_sdk_tools=$(python -c \
58      "import os.path, sys; \
59      print os.path.relpath( \
60      '${ANDROID_SDK_ROOT}/../tools/${host_platform}', \
61      '${ANDROID_BUILD_TOP}')")
62  EFLAGS=\
63"${FLAGS} -Dhost_os=${host_os} -Dandroid_sdk_tools=\$(PWD)/${android_sdk_tools}"
64
65  if [ "$PLATFORM" == "${host_platform}-arm" -o "$PLATFORM" == "all" ]; then
66    ${GYP} --suffix .${host_platform}-arm ${EFLAGS} -Dtarget_arch=arm
67  fi
68  if [ "$PLATFORM" == "${host_platform}-arm64" -o "$PLATFORM" == "all" ]; then
69    ${GYP} --suffix .${host_platform}-arm64 ${EFLAGS} -Dtarget_arch=arm64
70  fi
71  if [ "$PLATFORM" == "${host_platform}-x86" -o "$PLATFORM" == "all" ]; then
72    ${GYP} --suffix .${host_platform}-x86 ${EFLAGS} -Dtarget_arch=ia32
73  fi
74  if [ "$PLATFORM" == "${host_platform}-x86_64" -o "$PLATFORM" == "all" ]; then
75    ${GYP} --suffix .${host_platform}-x86_64 ${EFLAGS} -Dtarget_arch=x64
76  fi
77  if [ "$PLATFORM" == "${host_platform}-mips" -o "$PLATFORM" == "all" ]; then
78    ${GYP} --suffix .${host_platform}-mips ${EFLAGS} -Dtarget_arch=mipsel
79  fi
80  if [ "$PLATFORM" == "${host_platform}-mips64" -o "$PLATFORM" == "all" ]; then
81    ${GYP} --suffix .${host_platform}-mips64 ${EFLAGS} -Dtarget_arch=mips64el
82  fi
83done
84