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 |
| 17 # Parse named arguments passed into the annotator script |
| 18 # and assign them global variable names. |
| 19 function bb_parse_args { |
| 20 while [[ $1 ]]; do |
| 21 case "$1" in |
| 22 --factory-properties=*) |
| 23 FACTORY_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" |
| 24 ;; |
| 25 --build-properties=*) |
| 26 BUILD_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" |
| 27 ;; |
| 28 *) |
| 29 echo "@@@STEP_WARNINGS@@@" |
| 30 echo "Warning, unparsed input argument: '$1'" |
| 31 ;; |
| 32 esac |
| 33 shift |
| 34 done |
| 35 } |
| 36 |
| 37 |
16 # Setup environment for Android build. | 38 # Setup environment for Android build. |
17 # Called from bb_baseline_setup. | 39 # Called from bb_baseline_setup. |
18 # Moved to top of file so it is easier to find. | 40 # Moved to top of file so it is easier to find. |
19 function bb_setup_environment { | 41 function bb_setup_environment { |
20 export ANDROID_SDK_ROOT=/usr/local/google/android-sdk-linux | 42 export ANDROID_SDK_ROOT=/usr/local/google/android-sdk-linux |
21 export ANDROID_NDK_ROOT=/usr/local/google/android-ndk-r7 | 43 export ANDROID_NDK_ROOT=/usr/local/google/android-ndk-r7 |
22 } | 44 } |
23 | 45 |
24 # Install the build deps by running | 46 # Install the build deps by running |
25 # build/install-build-deps-android-sdk.sh. This may update local tools. | 47 # build/install-build-deps-android-sdk.sh. This may update local tools. |
26 # $1: source root. | 48 # $1: source root. |
27 function bb_install_build_deps { | 49 function bb_install_build_deps { |
28 echo "@@@BUILD_STEP install build deps android@@@" | 50 echo "@@@BUILD_STEP install build deps android@@@" |
29 local script="$1/build/install-build-deps-android-sdk.sh" | 51 local script="$1/build/install-build-deps-android-sdk.sh" |
30 if [[ -f "$script" ]]; then | 52 if [[ -f "$script" ]]; then |
31 "$script" | 53 "$script" |
32 else | 54 else |
| 55 echo "@@@STEP_WARNINGS@@@" |
33 echo "Cannot find $script; why?" | 56 echo "Cannot find $script; why?" |
34 fi | 57 fi |
35 } | 58 } |
36 | 59 |
37 # Function to force-green a bot. | 60 # Function to force-green a bot. |
38 function bb_force_bot_green_and_exit { | 61 function bb_force_bot_green_and_exit { |
39 echo "@@@BUILD_STEP Bot forced green.@@@" | 62 echo "@@@BUILD_STEP Bot forced green.@@@" |
40 exit 0 | 63 exit 0 |
41 } | 64 } |
42 | 65 |
43 # Basic setup for all bots to run after a source tree checkout. | 66 # Basic setup for all bots to run after a source tree checkout. |
44 # $1: source root. | 67 # Args: |
| 68 # $1: source root. |
| 69 # $2 and beyond: key value pairs which are parsed by bb_parse_args. |
45 function bb_baseline_setup { | 70 function bb_baseline_setup { |
46 echo "@@@BUILD_STEP cd into source root@@@" | 71 echo "@@@BUILD_STEP cd into source root@@@" |
47 SRC_ROOT="$1" | 72 SRC_ROOT="$1" |
| 73 # Remove SRC_ROOT param |
| 74 shift |
| 75 |
| 76 bb_parse_args "$@" |
| 77 |
48 if [ ! -d "${SRC_ROOT}" ] ; then | 78 if [ ! -d "${SRC_ROOT}" ] ; then |
49 echo "Please specify a valid source root directory as an arg" | 79 echo "Please specify a valid source root directory as an arg" |
50 echo '@@@STEP_FAILURE@@@' | 80 echo '@@@STEP_FAILURE@@@' |
51 return 1 | 81 return 1 |
52 fi | 82 fi |
53 cd $SRC_ROOT | 83 cd $SRC_ROOT |
54 | 84 |
55 if [ ! -f build/android/envsetup.sh ] ; then | 85 if [ ! -f build/android/envsetup.sh ] ; then |
56 echo "No envsetup.sh" | 86 echo "No envsetup.sh" |
57 echo "@@@STEP_FAILURE@@@" | 87 echo "@@@STEP_FAILURE@@@" |
(...skipping 12 matching lines...) Expand all Loading... |
70 return 1 | 100 return 1 |
71 fi | 101 fi |
72 done | 102 done |
73 | 103 |
74 if [ ! "$BUILDBOT_CLOBBER" = "" ]; then | 104 if [ ! "$BUILDBOT_CLOBBER" = "" ]; then |
75 NEED_CLOBBER=1 | 105 NEED_CLOBBER=1 |
76 fi | 106 fi |
77 | 107 |
78 # Setting up a new bot? Must do this before envsetup.sh | 108 # Setting up a new bot? Must do this before envsetup.sh |
79 if [ ! -d "${ANDROID_NDK_ROOT}" ] ; then | 109 if [ ! -d "${ANDROID_NDK_ROOT}" ] ; then |
80 bb_install_build_deps $1 | 110 bb_install_build_deps $SRC_ROOT |
81 fi | 111 fi |
82 | 112 |
83 echo "@@@BUILD_STEP Configure with envsetup.sh@@@" | 113 echo "@@@BUILD_STEP Configure with envsetup.sh@@@" |
84 . build/android/envsetup.sh | 114 . build/android/envsetup.sh |
85 | 115 |
86 if [ "$NEED_CLOBBER" -eq 1 ]; then | 116 if [ "$NEED_CLOBBER" -eq 1 ]; then |
87 echo "@@@BUILD_STEP Clobber@@@" | 117 echo "@@@BUILD_STEP Clobber@@@" |
88 rm -rf "${SRC_ROOT}"/out | 118 rm -rf "${SRC_ROOT}"/out |
89 if [ -e "${SRC_ROOT}"/out ] ; then | 119 if [ -e "${SRC_ROOT}"/out ] ; then |
90 echo "Clobber appeared to fail? ${SRC_ROOT}/out still exists." | 120 echo "Clobber appeared to fail? ${SRC_ROOT}/out still exists." |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 function bb_run_tests { | 260 function bb_run_tests { |
231 echo "@@@BUILD_STEP Run Tests on actual hardware@@@" | 261 echo "@@@BUILD_STEP Run Tests on actual hardware@@@" |
232 build/android/run_tests.py --xvfb --verbose | 262 build/android/run_tests.py --xvfb --verbose |
233 } | 263 } |
234 | 264 |
235 # Run APK tests on an actual device. | 265 # Run APK tests on an actual device. |
236 function bb_run_apk_tests { | 266 function bb_run_apk_tests { |
237 echo "@@@BUILD_STEP Run APK Tests on actual hardware@@@" | 267 echo "@@@BUILD_STEP Run APK Tests on actual hardware@@@" |
238 build/android/run_tests.py --xvfb --verbose --apk=True | 268 build/android/run_tests.py --xvfb --verbose --apk=True |
239 } | 269 } |
| 270 |
| 271 # Zip and archive a build. |
| 272 function bb_zip_build { |
| 273 echo "@@@BUILD_STEP Zip build@@@" |
| 274 python ../../../../scripts/slave/zip_build.py \ |
| 275 --src-dir "$SRC_ROOT" \ |
| 276 --factory-properties "$FACTORY_PROPERTIES" \ |
| 277 --build-properties "$BUILD_PROPERTIES" |
| 278 } |
| 279 |
| 280 # Download and extract a build. |
| 281 function bb_extract_build { |
| 282 echo "@@@BUILD_STEP Download and extract build@@@" |
| 283 if [[ -z $FACTORY_PROPERTIES || -z $BUILD_PROPERTIES ]]; then |
| 284 return 1 |
| 285 fi |
| 286 |
| 287 python ../../../../scripts/slave/extract_build.py \ |
| 288 --build-dir "$SRC_ROOT" \ |
| 289 --build-output-dir "out" \ |
| 290 --target Release \ |
| 291 --factory-properties "$FACTORY_PROPERTIES" \ |
| 292 --build-properties "$BUILD_PROPERTIES" |
| 293 } |
OLD | NEW |