| 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 # Clobber build? Overridden by bots with BUILDBOT_CLOBBER. | 13 # Clobber build? Overridden by bots with BUILDBOT_CLOBBER. |
| 14 NEED_CLOBBER="${NEED_CLOBBER:-0}" | 14 NEED_CLOBBER="${NEED_CLOBBER:-0}" |
| 15 | 15 |
| 16 | 16 |
| 17 # Parse named arguments passed into the annotator script | 17 # Parse named arguments passed into the annotator script |
| 18 # and assign them global variable names. | 18 # and assign them global variable names. |
| 19 function bb_parse_args { | 19 function bb_parse_args { |
| 20 while [[ $1 ]]; do | 20 while [[ $1 ]]; do |
| 21 case "$1" in | 21 case "$1" in |
| 22 --factory-properties=*) | 22 --factory-properties=*) |
| 23 FACTORY_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" | 23 FACTORY_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" |
| 24 BUILDTYPE=$(bb_get_json_prop "$FACTORY_PROPERTIES" target) |
| 24 ;; | 25 ;; |
| 25 --build-properties=*) | 26 --build-properties=*) |
| 26 BUILD_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" | 27 BUILD_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" |
| 27 ;; | 28 ;; |
| 28 *) | 29 *) |
| 29 echo "@@@STEP_WARNINGS@@@" | 30 echo "@@@STEP_WARNINGS@@@" |
| 30 echo "Warning, unparsed input argument: '$1'" | 31 echo "Warning, unparsed input argument: '$1'" |
| 31 ;; | 32 ;; |
| 32 esac | 33 esac |
| 33 shift | 34 shift |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 echo "Build cannot continue." | 78 echo "Build cannot continue." |
| 78 echo "@@@STEP_FAILURE@@@" | 79 echo "@@@STEP_FAILURE@@@" |
| 79 return 1 | 80 return 1 |
| 80 fi | 81 fi |
| 81 done | 82 done |
| 82 | 83 |
| 83 if [ ! "$BUILDBOT_CLOBBER" = "" ]; then | 84 if [ ! "$BUILDBOT_CLOBBER" = "" ]; then |
| 84 NEED_CLOBBER=1 | 85 NEED_CLOBBER=1 |
| 85 fi | 86 fi |
| 86 | 87 |
| 88 local BUILDTOOL=$(bb_get_json_prop "$FACTORY_PROPERTIES" buildtool) |
| 89 if [ $BUILDTOOL = "ninja" ]; then |
| 90 export GYP_GENERATORS=ninja |
| 91 fi |
| 92 |
| 87 . build/android/envsetup.sh | 93 . build/android/envsetup.sh |
| 88 | 94 |
| 89 if [ "$NEED_CLOBBER" -eq 1 ]; then | 95 if [ "$NEED_CLOBBER" -eq 1 ]; then |
| 90 echo "@@@BUILD_STEP Clobber@@@" | 96 echo "@@@BUILD_STEP Clobber@@@" |
| 91 rm -rf "${SRC_ROOT}"/out | 97 rm -rf "${SRC_ROOT}"/out |
| 92 if [ -e "${SRC_ROOT}"/out ] ; then | 98 if [ -e "${SRC_ROOT}"/out ] ; then |
| 93 echo "Clobber appeared to fail? ${SRC_ROOT}/out still exists." | 99 echo "Clobber appeared to fail? ${SRC_ROOT}/out still exists." |
| 94 echo "@@@STEP_WARNINGS@@@" | 100 echo "@@@STEP_WARNINGS@@@" |
| 95 fi | 101 fi |
| 96 fi | 102 fi |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 151 |
| 146 # Stop goma. | 152 # Stop goma. |
| 147 function bb_stop_goma_internal { | 153 function bb_stop_goma_internal { |
| 148 echo "Stopping goma" | 154 echo "Stopping goma" |
| 149 ${GOMA_DIR}/goma_ctl.sh stop | 155 ${GOMA_DIR}/goma_ctl.sh stop |
| 150 } | 156 } |
| 151 | 157 |
| 152 # $@: make args. | 158 # $@: make args. |
| 153 # Use goma if possible; degrades to non-Goma if needed. | 159 # Use goma if possible; degrades to non-Goma if needed. |
| 154 function bb_goma_make { | 160 function bb_goma_make { |
| 155 bb_setup_goma_internal | |
| 156 | |
| 157 if [ "${GOMA_DIR}" = "" ]; then | 161 if [ "${GOMA_DIR}" = "" ]; then |
| 158 make -j${JOBS} "$@" | 162 make -j${JOBS} "$@" |
| 159 return | 163 return |
| 160 fi | 164 fi |
| 161 | 165 |
| 162 BUILDTYPE=$(bb_get_json_prop "$FACTORY_PROPERTIES" target) | |
| 163 HOST_CC=$GOMA_DIR/gcc | 166 HOST_CC=$GOMA_DIR/gcc |
| 164 HOST_CXX=$GOMA_DIR/g++ | 167 HOST_CXX=$GOMA_DIR/g++ |
| 165 TARGET_CC=$(/bin/ls $ANDROID_TOOLCHAIN/*-gcc | head -n1) | 168 TARGET_CC=$(/bin/ls $ANDROID_TOOLCHAIN/*-gcc | head -n1) |
| 166 TARGET_CXX=$(/bin/ls $ANDROID_TOOLCHAIN/*-g++ | head -n1) | 169 TARGET_CXX=$(/bin/ls $ANDROID_TOOLCHAIN/*-g++ | head -n1) |
| 167 TARGET_CC="$GOMA_DIR/gomacc $TARGET_CC" | 170 TARGET_CC="$GOMA_DIR/gomacc $TARGET_CC" |
| 168 TARGET_CXX="$GOMA_DIR/gomacc $TARGET_CXX" | 171 TARGET_CXX="$GOMA_DIR/gomacc $TARGET_CXX" |
| 169 COMMON_JAVAC="$GOMA_DIR/gomacc /usr/bin/javac -J-Xmx512M \ | 172 COMMON_JAVAC="$GOMA_DIR/gomacc /usr/bin/javac -J-Xmx512M \ |
| 170 -target 1.5 -Xmaxerrs 9999999" | 173 -target 1.5 -Xmaxerrs 9999999" |
| 171 | 174 |
| 172 command make \ | 175 command make \ |
| 173 -j100 \ | 176 -j100 \ |
| 174 -l20 \ | 177 -l20 \ |
| 175 HOST_CC="$HOST_CC" \ | 178 HOST_CC="$HOST_CC" \ |
| 176 HOST_CXX="$HOST_CXX" \ | 179 HOST_CXX="$HOST_CXX" \ |
| 177 TARGET_CC="$TARGET_CC" \ | 180 TARGET_CC="$TARGET_CC" \ |
| 178 TARGET_CXX="$TARGET_CXX" \ | 181 TARGET_CXX="$TARGET_CXX" \ |
| 179 CC.host="$HOST_CC" \ | 182 CC.host="$HOST_CC" \ |
| 180 CXX.host="$HOST_CXX" \ | 183 CXX.host="$HOST_CXX" \ |
| 181 CC.target="$TARGET_CC" \ | 184 CC.target="$TARGET_CC" \ |
| 182 CXX.target="$TARGET_CXX" \ | 185 CXX.target="$TARGET_CXX" \ |
| 183 LINK.target="$TARGET_CXX" \ | 186 LINK.target="$TARGET_CXX" \ |
| 184 COMMON_JAVAC="$COMMON_JAVAC" \ | 187 COMMON_JAVAC="$COMMON_JAVAC" \ |
| 185 BUILDTYPE="$BUILDTYPE" \ | 188 BUILDTYPE="$BUILDTYPE" \ |
| 186 "$@" | 189 "$@" |
| 187 | 190 |
| 188 local make_exit_code=$? | 191 local make_exit_code=$? |
| 189 bb_stop_goma_internal | |
| 190 return $make_exit_code | 192 return $make_exit_code |
| 191 } | 193 } |
| 192 | 194 |
| 195 # Build using ninja. |
| 196 function bb_goma_ninja { |
| 197 echo "Using ninja to build." |
| 198 ninja -C out/$BUILDTYPE -j120 -l20 All |
| 199 } |
| 200 |
| 193 # Compile step | 201 # Compile step |
| 194 function bb_compile { | 202 function bb_compile { |
| 195 # This must be named 'compile', not 'Compile', for CQ interaction. | 203 # This must be named 'compile', not 'Compile', for CQ interaction. |
| 196 # Talk to maruel for details. | 204 # Talk to maruel for details. |
| 197 echo "@@@BUILD_STEP compile@@@" | 205 echo "@@@BUILD_STEP compile@@@" |
| 198 bb_goma_make | 206 |
| 207 bb_setup_goma_internal |
| 208 |
| 209 BUILDTOOL=$(bb_get_json_prop "$FACTORY_PROPERTIES" buildtool) |
| 210 if [ $BUILDTOOL = "ninja" ]; then |
| 211 bb_goma_ninja |
| 212 else |
| 213 bb_goma_make |
| 214 fi |
| 215 |
| 216 bb_stop_goma_internal |
| 199 } | 217 } |
| 200 | 218 |
| 201 # Experimental compile step; does not turn the tree red if it fails. | 219 # Experimental compile step; does not turn the tree red if it fails. |
| 202 function bb_compile_experimental { | 220 function bb_compile_experimental { |
| 203 # Linking DumpRenderTree appears to hang forever? | 221 # Linking DumpRenderTree appears to hang forever? |
| 204 EXPERIMENTAL_TARGETS="android_experimental" | 222 EXPERIMENTAL_TARGETS="android_experimental" |
| 205 for target in ${EXPERIMENTAL_TARGETS} ; do | 223 for target in ${EXPERIMENTAL_TARGETS} ; do |
| 206 echo "@@@BUILD_STEP Experimental Compile $target @@@" | 224 echo "@@@BUILD_STEP Experimental Compile $target @@@" |
| 207 set +e | 225 set +e |
| 208 bb_goma_make -k "${target}" | 226 bb_goma_make -k "${target}" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 fi | 338 fi |
| 321 return $license_exit_code | 339 return $license_exit_code |
| 322 ) | 340 ) |
| 323 } | 341 } |
| 324 | 342 |
| 325 # Retrieve a packed json property using python | 343 # Retrieve a packed json property using python |
| 326 function bb_get_json_prop { | 344 function bb_get_json_prop { |
| 327 local JSON="$1" | 345 local JSON="$1" |
| 328 local PROP="$2" | 346 local PROP="$2" |
| 329 | 347 |
| 330 python -c "import json; print json.loads('$JSON')['$PROP']" | 348 python -c "import json; print json.loads('$JSON').get('$PROP')" |
| 331 } | 349 } |
| OLD | NEW |