| OLD | NEW | 
|---|
| 1 #!/bin/bash | 1 #!/bin/bash | 
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be | 
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. | 
| 5 # | 5 # | 
| 6 # Bash functions used by buildbot annotator scripts for the android | 6 # Bash functions used by buildbot annotator scripts for the android | 
| 7 # build of chromium.  Executing this script should not perform actions | 7 # build of chromium.  Executing this script should not perform actions | 
| 8 # other than setting variables and defining of functions. | 8 # other than setting variables and defining of functions. | 
| 9 | 9 | 
| 10 # Number of jobs on the compile line; e.g.  make -j"${JOBS}" | 10 # Number of jobs on the compile line; e.g.  make -j"${JOBS}" | 
| 11 JOBS="${JOBS:-4}" | 11 JOBS="${JOBS:-4}" | 
| 12 | 12 | 
| 13 # Parse named arguments passed into the annotator script | 13 # Parse named arguments passed into the annotator script | 
| 14 # and assign them global variable names. | 14 # and assign them global variable names. | 
| 15 function bb_parse_args { | 15 function bb_parse_args { | 
| 16   while [[ $1 ]]; do | 16   while [[ $1 ]]; do | 
| 17     case "$1" in | 17     case "$1" in | 
| 18       --factory-properties=*) | 18       --factory-properties=*) | 
| 19         FACTORY_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" | 19         FACTORY_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" | 
| 20         BUILDTYPE=$(bb_get_json_prop "$FACTORY_PROPERTIES" target) | 20         BUILDTYPE=$(bb_get_json_prop "$FACTORY_PROPERTIES" target) | 
|  | 21         BUILDTOOL=$(bb_get_json_prop "$FACTORY_PROPERTIES" buildtool) | 
| 21         ;; | 22         ;; | 
| 22       --build-properties=*) | 23       --build-properties=*) | 
| 23         BUILD_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" | 24         BUILD_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" | 
| 24         ;; | 25         ;; | 
| 25       *) | 26       *) | 
| 26         echo "@@@STEP_WARNINGS@@@" | 27         echo "@@@STEP_WARNINGS@@@" | 
| 27         echo "Warning, unparsed input argument: '$1'" | 28         echo "Warning, unparsed input argument: '$1'" | 
| 28         ;; | 29         ;; | 
| 29     esac | 30     esac | 
| 30     shift | 31     shift | 
| 31   done | 32   done | 
| 32 } | 33 } | 
| 33 | 34 | 
| 34 # Function to force-green a bot. | 35 # Function to force-green a bot. | 
| 35 function bb_force_bot_green_and_exit { | 36 function bb_force_bot_green_and_exit { | 
| 36   echo "@@@BUILD_STEP Bot forced green.@@@" | 37   echo "@@@BUILD_STEP Bot forced green.@@@" | 
| 37   exit 0 | 38   exit 0 | 
| 38 } | 39 } | 
| 39 | 40 | 
|  | 41 # Check for landmines which might clobber the build. Will create a new annotator | 
|  | 42 # step for the clobber if one is required. | 
|  | 43 # | 
|  | 44 # As a side effect, creates "$2/.landmines" | 
|  | 45 # | 
|  | 46 # Args: | 
|  | 47 #   $1: source root | 
|  | 48 #   $2: output root | 
|  | 49 # Retval: | 
|  | 50 #   0 if landmines are tripped for this build and we need clobber OR | 
|  | 51 #        clobber was requested via $BUILDBOT_CLOBBER | 
|  | 52 #   1 if landmines are dormant | 
|  | 53 function bb_check_clobber { | 
|  | 54   local src_root="$1" | 
|  | 55   local out_dir="$2" | 
|  | 56 | 
|  | 57   local ret=1 | 
|  | 58 | 
|  | 59   if [[ $BUILDBOT_CLOBBER ]] | 
|  | 60   then | 
|  | 61     echo "@@@BUILD_STEP Clobber@@@" | 
|  | 62     echo "Clobber explicitly requested" | 
|  | 63     ret=0 | 
|  | 64   else | 
|  | 65     local landmines_path="$out_dir/.landmines" | 
|  | 66     local landmines_script="$src_root/build/landmines.py" | 
|  | 67     [[ ! -x "$landmines_script" ]] || return 1 | 
|  | 68 | 
|  | 69     local new_landmines=$(mktemp) | 
|  | 70 | 
|  | 71     python "$landmines_script" >> "$new_landmines" <<EOF | 
|  | 72     { | 
|  | 73       "target": "$BUILDTYPE", | 
|  | 74       "distributor": "goma", | 
|  | 75       "platform": "android", | 
|  | 76       "builder": "$BUILDTOOL" | 
|  | 77     } | 
|  | 78 EOF | 
|  | 79 | 
|  | 80     if [[ ! -f "$landmines_path" ]] | 
|  | 81     then | 
|  | 82       mkdir -p "$(dirname "$landmines_path")" | 
|  | 83       mv "$new_landmines" "$landmines_path" | 
|  | 84     else | 
|  | 85       local diff_output=$(mktemp) | 
|  | 86       diff -U 0 --label "old_landmines $(stat -c "%z" "$landmines_path")" \ | 
|  | 87                 "$landmines_path"                                         \ | 
|  | 88                 --label "new_landmines $(stat -c "%z" "$new_landmines")"  \ | 
|  | 89                 "$new_landmines" > "$diff_output" | 
|  | 90       if [[ $? != 0 ]] | 
|  | 91       then | 
|  | 92         echo "@@@BUILD_STEP Clobber@@@" | 
|  | 93         echo "Landmines tripped! Clobbering the build! Reasons for clobber:" | 
|  | 94         cat "$diff_output" | 
|  | 95         ret=0 | 
|  | 96       fi | 
|  | 97       rm -f "$diff_output" | 
|  | 98     fi | 
|  | 99 | 
|  | 100     rm -f "$new_landmines" | 
|  | 101   fi | 
|  | 102 | 
|  | 103   return $ret | 
|  | 104 } | 
|  | 105 | 
| 40 # Basic setup for all bots to run after a source tree checkout. | 106 # Basic setup for all bots to run after a source tree checkout. | 
| 41 # Args: | 107 # Args: | 
| 42 #   $1: source root. | 108 #   $1: source root. | 
| 43 #   $2 and beyond: key value pairs which are parsed by bb_parse_args. | 109 #   $2 and beyond: key value pairs which are parsed by bb_parse_args. | 
| 44 function bb_baseline_setup { | 110 function bb_baseline_setup { | 
| 45   SRC_ROOT="$1" | 111   SRC_ROOT="$1" | 
| 46   # Remove SRC_ROOT param | 112   # Remove SRC_ROOT param | 
| 47   shift | 113   shift | 
| 48   cd $SRC_ROOT | 114   cd $SRC_ROOT | 
| 49 | 115 | 
| 50   if [[ $BUILDBOT_CLOBBER ]]; then | 116   echo "@@@BUILD_STEP Parse args@@@" | 
| 51     echo "@@@BUILD_STEP Clobber@@@" | 117   bb_parse_args "$@" | 
|  | 118 | 
|  | 119   if bb_check_clobber "$SRC_ROOT" "$SRC_ROOT/out/$BUILDTYPE" | 
|  | 120   then | 
| 52     # Sdk key expires, delete android folder. | 121     # Sdk key expires, delete android folder. | 
| 53     # crbug.com/145860 | 122     # crbug.com/145860 | 
| 54     rm -rf ~/.android | 123     rm -rf ~/.android | 
| 55     rm -rf "${SRC_ROOT}"/out | 124     rm -rf "${SRC_ROOT}"/out | 
| 56     if [ -e "${SRC_ROOT}"/out ] ; then | 125     if [ -e "${SRC_ROOT}"/out ] ; then | 
| 57       echo "Clobber appeared to fail?  ${SRC_ROOT}/out still exists." | 126       echo "Clobber appeared to fail?  ${SRC_ROOT}/out still exists." | 
| 58       echo "@@@STEP_WARNINGS@@@" | 127       echo "@@@STEP_WARNINGS@@@" | 
| 59     fi | 128     fi | 
| 60   fi | 129   fi | 
| 61 | 130 | 
| 62   echo "@@@BUILD_STEP Environment setup@@@" | 131   echo "@@@BUILD_STEP Environment setup@@@" | 
| 63   bb_parse_args "$@" |  | 
| 64 |  | 
| 65   local BUILDTOOL=$(bb_get_json_prop "$FACTORY_PROPERTIES" buildtool) |  | 
| 66   if [[ $BUILDTOOL = ninja ]]; then | 132   if [[ $BUILDTOOL = ninja ]]; then | 
| 67     export GYP_GENERATORS=ninja | 133     export GYP_GENERATORS=ninja | 
| 68   fi | 134   fi | 
| 69   export GOMA_DIR=/b/build/goma | 135   export GOMA_DIR=/b/build/goma | 
| 70   . build/android/envsetup.sh | 136   . build/android/envsetup.sh | 
| 71   adb kill-server | 137   adb kill-server | 
| 72 } | 138 } | 
| 73 | 139 | 
| 74 function bb_compile_setup { | 140 function bb_compile_setup { | 
| 75   local extra_gyp_defines="$(bb_get_json_prop "$FACTORY_PROPERTIES" \ | 141   local extra_gyp_defines="$(bb_get_json_prop "$FACTORY_PROPERTIES" \ | 
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 148   ninja -C out/$BUILDTYPE -j120 -l20 $TARGET | 214   ninja -C out/$BUILDTYPE -j120 -l20 $TARGET | 
| 149 } | 215 } | 
| 150 | 216 | 
| 151 # Compile step | 217 # Compile step | 
| 152 function bb_compile { | 218 function bb_compile { | 
| 153   bb_compile_setup | 219   bb_compile_setup | 
| 154   # This must be named 'compile', not 'Compile', for CQ interaction. | 220   # This must be named 'compile', not 'Compile', for CQ interaction. | 
| 155   # Talk to maruel for details. | 221   # Talk to maruel for details. | 
| 156   echo "@@@BUILD_STEP compile@@@" | 222   echo "@@@BUILD_STEP compile@@@" | 
| 157 | 223 | 
| 158   BUILDTOOL=$(bb_get_json_prop "$FACTORY_PROPERTIES" buildtool) |  | 
| 159   if [[ $BUILDTOOL = ninja ]]; then | 224   if [[ $BUILDTOOL = ninja ]]; then | 
| 160     bb_goma_ninja All | 225     bb_goma_ninja All | 
| 161   else | 226   else | 
| 162     bb_goma_make | 227     bb_goma_make | 
| 163   fi | 228   fi | 
| 164 | 229 | 
| 165   bb_stop_goma_internal | 230   bb_stop_goma_internal | 
| 166 } | 231 } | 
| 167 | 232 | 
| 168 # Experimental compile step; does not turn the tree red if it fails. | 233 # Experimental compile step; does not turn the tree red if it fails. | 
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 299   ) | 364   ) | 
| 300 } | 365 } | 
| 301 | 366 | 
| 302 # Retrieve a packed json property using python | 367 # Retrieve a packed json property using python | 
| 303 function bb_get_json_prop { | 368 function bb_get_json_prop { | 
| 304   local JSON="$1" | 369   local JSON="$1" | 
| 305   local PROP="$2" | 370   local PROP="$2" | 
| 306 | 371 | 
| 307   python -c "import json; print json.loads('$JSON').get('$PROP', '')" | 372   python -c "import json; print json.loads('$JSON').get('$PROP', '')" | 
| 308 } | 373 } | 
| OLD | NEW | 
|---|