#!/bin/bash

# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This script runs gyp with the configuration required to build WebView in the
# Android build system. It is not necessary to source build/android/envsetup.sh
# before running this script.

set -e

PLATFORM=${1:-linux-arm}
echo "Generating makefiles for $PLATFORM"

export CHROME_ANDROID_BUILD_WEBVIEW=1
export CHROME_SRC="$(readlink -f "$(dirname "$0")/../..")"
export PYTHONDONTWRITEBYTECODE=1

if [ "$PLATFORM" == "linux-arm" -o "$PLATFORM" == "all" ]; then
  ( . $CHROME_SRC/build/android/envsetup.sh --target-arch=arm --host-os=linux \
    && android_gyp --suffix .linux-arm )
fi
if [ "$PLATFORM" == "linux-x86" -o "$PLATFORM" == "all" ]; then
  ( . $CHROME_SRC/build/android/envsetup.sh --target-arch=x86 --host-os=linux \
    && android_gyp --suffix .linux-x86 )
fi
if [ "$PLATFORM" == "linux-mips" -o "$PLATFORM" == "all" ]; then
  ( . $CHROME_SRC/build/android/envsetup.sh --target-arch=mips --host-os=linux \
    && android_gyp --suffix .linux-mips )
fi
if [ "$PLATFORM" == "darwin-arm" -o "$PLATFORM" == "all" ]; then
  ( . $CHROME_SRC/build/android/envsetup.sh --target-arch=arm --host-os=mac \
    && android_gyp --suffix .darwin-arm )
fi
if [ "$PLATFORM" == "darwin-x86" -o "$PLATFORM" == "all" ]; then
  ( . $CHROME_SRC/build/android/envsetup.sh --target-arch=x86 --host-os=mac \
    && android_gyp --suffix .darwin-x86 )
fi
if [ "$PLATFORM" == "darwin-mips" -o "$PLATFORM" == "all" ]; then
  ( . $CHROME_SRC/build/android/envsetup.sh --target-arch=mips --host-os=mac \
    && android_gyp --suffix .darwin-mips )
fi