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