Home | History | Annotate | Download | only in buildbot
      1 # Copyright (C) 2012 The Android Open Source Project
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
      4 # you may not use this file except in compliance with the License.
      5 # You may obtain a copy of the License at
      6 #
      7 #      http://www.apache.org/licenses/LICENSE-2.0
      8 #
      9 # Unless required by applicable law or agreed to in writing, software
     10 # distributed under the License is distributed on an "AS IS" BASIS,
     11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     14 
     15 function bb_webview_set_lunch_type() {
     16   case "$1" in
     17     clank-webview)
     18       LUNCH_TYPE="nakasi-eng"
     19       ;;
     20     clank-webview-tot)
     21       LUNCH_TYPE="nakasi-eng"
     22       ;;
     23     *)
     24       LUNCH_TYPE=""
     25       echo "Unable to determine lunch type from: ${BUILDBOT_BUILDERNAME}"
     26       echo "@@@STEP_FAILURE@@@"
     27       exit 2
     28       ;;
     29   esac
     30   echo "Using lunch type: $LUNCH_TYPE"
     31 }
     32 
     33 function bb_webview_build_android() {
     34   echo "@@@BUILD_STEP Compile Android@@@"
     35 
     36   local MAKE_COMMAND="make"
     37   if [ "$USE_GOMA" -eq 1 ]; then
     38     echo "Building using GOMA"
     39     MAKE_COMMAND="${GOMA_DIR}/goma-android-make"
     40   fi
     41 
     42   MAKE_TARGET="webviewchromium"
     43 
     44   bb_run_step $MAKE_COMMAND $MAKE_PARAMS showcommands $MAKE_TARGET
     45 
     46   if [ "$USE_GOMA" -eq 1 ]; then
     47     bb_stop_goma_internal
     48   fi
     49 }
     50 
     51 function bb_webview_goma_setup() {
     52   # Set to 0 to disable goma in case of problems.
     53   USE_GOMA=1
     54   if [ -z "$GOMA_DIR" ]; then
     55     export GOMA_DIR=/b/build/goma
     56   fi
     57   if [ ! -d $GOMA_DIR ]; then
     58     USE_GOMA=0
     59   fi
     60 
     61   if [ "$USE_GOMA" -eq 1 ]; then
     62     MAKE_PARAMS="-j150 -l20"
     63   else
     64     MAKE_PARAMS="-j16"
     65   fi
     66 
     67   bb_setup_goma_internal
     68 }
     69 
     70 # Basic setup for all bots to run after a source tree checkout.
     71 # Args:
     72 #   $1: Android source root.
     73 function bb_webview_baseline_setup {
     74   SRC_ROOT="$1"
     75   cd $SRC_ROOT
     76 
     77   echo "@@@BUILD_STEP Environment setup@@@"
     78   . build/envsetup.sh
     79 
     80   bb_webview_set_lunch_type $BUILDBOT_BUILDERNAME
     81   lunch $LUNCH_TYPE
     82 
     83   if [[ $BUILDBOT_CLOBBER ]]; then
     84     echo "@@@BUILD_STEP Clobber@@@"
     85 
     86     rm -rf ${ANDROID_PRODUCT_OUT}
     87     rm -rf ${ANDROID_HOST_OUT}
     88   fi
     89 
     90   # Add the upstream build/android folder to the Python path.
     91   # This is required since we don't want to check out the clank scripts into a
     92   # subfolder of the upstream chromium_org checkout (that would make repo think
     93   # those are uncommited changes and cause potential issues).
     94   export PYTHONPATH="$PYTHONPATH:${BB_DIR}/../"
     95 
     96   # The CTS bot runs using repo only.
     97   export CHECKOUT="repo"
     98 
     99   bb_webview_goma_setup
    100 }
    101 
    102 function bb_webview_smart_sync {
    103   echo "@@@BUILD_STEP Smart Sync (sync -s) @@@"
    104   bb_run_step repo sync -s -j8 -df
    105 
    106   # We always want to roll with the latest code in this project, regardless of
    107   # what smartsync thinks.
    108   echo "@@@BUILD_STEP Sync frameworks/webview@@@"
    109   repo sync frameworks/webview
    110 }
    111 
    112 function bb_webview_remove_chromium_org {
    113   echo "@@@BUILD_STEP Removing chromium_org project@@@"
    114   # This generates a local manifest that will exclude any projects from the
    115   # external/chromium_org folder.
    116   bb_run_step python ${WEBVIEW_TOOLS_DIR}/generate_local_manifest.py \
    117     ${ANDROID_SRC_ROOT} external/chromium_org
    118   bb_webview_smart_sync
    119 }
    120 
    121 function bb_webview_sync_upstream_chromium {
    122   echo "@@@BUILD_STEP Sync upstream chromium@@@"
    123   local CHROMIUM_TOT_DIR=${ANDROID_SRC_ROOT}/external/chromium_tot
    124   local CHROMIUM_ORG_DIR=${ANDROID_SRC_ROOT}/external/chromium_org
    125   if [ ! -e ${CHROMIUM_TOT_DIR} ]; then
    126     echo "No chromium_tot checkout detected. Creating new one.."
    127     mkdir -p ${CHROMIUM_TOT_DIR}
    128     cd ${CHROMIUM_TOT_DIR}
    129 
    130     if [ ! -e ${CHROMIUM_ORG_DIR} ]; then
    131       echo "Symlinking chromium_org to chromium_tot/src"
    132       ln -s ${CHROMIUM_TOT_DIR}/src ${CHROMIUM_ORG_DIR}
    133     else
    134       echo "${CHROMIUM_ORG_DIR} should have been removed by local manifest."
    135       echo "@@@STEP_FAILURE@@@"
    136       exit 2
    137     fi
    138 
    139     # Prevent Android make recursing into this folder since we're
    140     # exposing the src folder via a symlink.
    141     touch ${CHROMIUM_TOT_DIR}/Android.mk
    142 
    143     echo "Cloning chromium_tot"
    144     git clone --template=${DEPOT_TOOLS_DIR}/git-templates \
    145       https://chromium.googlesource.com/chromium/src.git
    146     cd ${CHROMIUM_TOT_DIR}/src
    147     git config target.os android
    148   fi
    149 
    150   cd ${CHROMIUM_TOT_DIR}/src
    151   echo "Updating"
    152   git crup -j8
    153 
    154   echo "@@@BUILD_STEP Print checked out chromium revision@@@"
    155   git log -1
    156 
    157   cd ${ANDROID_SRC_ROOT}
    158 }
    159 
    160 function bb_webview_gyp {
    161   echo "@@@BUILD_STEP Run gyp_webview@@@"
    162   cd ${ANDROID_SRC_ROOT}/external/chromium_org
    163   bb_run_step "./android_webview/tools/gyp_webview"
    164   cd ${ANDROID_SRC_ROOT}
    165 }
    166