#!/bin/bash

# This script builds Skia inside of a ChromeOS chroot. It is intended to be run
# either while inside the chroot or indirectly by running chromeos_make which
# enters the chroot and runs this script.

makeVars=""
deviceID=""

while (( "$#" )); do

  if [[ $(echo "$1" | grep "^-d$") != "" ]];
  then 
    deviceID="$2"
    shift
  else
    makeVars="$makeVars $1"
  fi

shift
done

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source $SCRIPT_DIR/chromeos_setup.sh

setup_device $deviceID
returnVal=$?
if [ $returnVal != 0 ]
then
  exit 1;
fi

python gyp_skia
make ${makeVars}
returnVal=$?
if [ $returnVal != 0 ]
then
  exit 1;
fi

echo > .cros_build_successful