Home | History | Annotate | Download | only in bin
      1 #!/bin/bash
      2 
      3 # This script builds Skia for ChromeOS by mounting the Skia checkout inside a
      4 # chroot contained within an existing ChromeOS checkout, entering the chroot,
      5 # and running the build_skia_in_chroot script.
      6 
      7 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
      8 
      9 if [ $(uname) != "Linux" ]; then
     10     echo "ERROR: Can only build for ChromeOS on Linux."
     11     exit 1
     12 fi
     13 
     14 
     15 makeVars=""
     16 deviceID=""
     17 
     18 while (( "$#" )); do
     19 
     20   if [[ $(echo "$1" | grep "^-d$") != "" ]];
     21   then 
     22     deviceID="$2"
     23     shift
     24   else
     25     makeVars="$makeVars $1"
     26   fi
     27 
     28 shift
     29 done
     30 
     31 if [[ -z "${deviceID}" ]]; then
     32   echo "You must provide a deviceID with -d."
     33   exit 1
     34 fi
     35 
     36 CHROMEOS_CHROOT="${SCRIPT_DIR}/../toolchain"
     37 
     38 # Get the required SDK version.
     39 # TODO(borenet): Should we instead get the latest from GS?
     40 #SDK_VERSION=$(gsutil cat gs://chromeos-image-archive/${deviceID}-release/LATEST-master)
     41 #SDK_VERSION=${SDK_VERSION:4}
     42 SDK_VERSION="4279.0.0"
     43 mkdir -p "${CHROMEOS_CHROOT}/src/chromeos"
     44 echo -n ${SDK_VERSION} > "${CHROMEOS_CHROOT}/src/chromeos/CHROMEOS_LKGM"
     45 
     46 # Download the toolchain tarball if needed.
     47 # TODO(borenet): Let chrome-sdk take care of this once it works with external
     48 # boards.
     49 if ! [[ -d "${CHROMEOS_CHROOT}/.cros_cache" ]]; then
     50   TARBALL="cros_toolchain.tgz"
     51   gsutil cp gs://chromium-skia-gm/chromeos-toolchains/${TARBALL} ${CHROMEOS_CHROOT}
     52   if [ "$?" != "0" ]
     53   then
     54     exit 1;
     55   fi
     56   pushd "${CHROMEOS_CHROOT}" > /dev/null
     57   tar -zxvf ${TARBALL}
     58   popd > /dev/null
     59   rm ${CHROMEOS_CHROOT}/${TARBALL}
     60 fi
     61 
     62 # Put a fake .gclient file in the toolchain directory so that the cros tool
     63 # thinks we're in a Chrome checkout.
     64 echo "Delete me!" > "${CHROMEOS_CHROOT}/.gclient"
     65 
     66 # Where the Skia code will pretend to live inside the chroot.
     67 SKIA_TOP_DIR="${SCRIPT_DIR}/../../.."
     68 
     69 pushd ${CHROMEOS_CHROOT}
     70 cros chrome-sdk --nogoma --board ${deviceID} --debug -- /bin/sh -c "cd ${SKIA_TOP_DIR}; platform_tools/chromeos/bin/build_skia_in_chroot ${makeVars}"
     71 popd > /dev/null
     72 
     73 # Clean up
     74 rm ${CHROMEOS_CHROOT}/.gclient
     75 
     76 if [ -f .cros_build_successful ]; then
     77   rm -rf .cros_build_successful
     78   exit 0
     79 fi
     80 
     81 exit 1