summaryrefslogtreecommitdiffstats
path: root/build/android/buildbot_functions.sh
blob: 8b82ed50bec5c1bcfa5224f6fdebc6bbf58ff570 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Bash functions used by buildbot annotator scripts for the android
# build of chromium.  Executing this script should not perform actions
# other than setting variables and defining of functions.

# Number of jobs on the compile line; e.g.  make -j"${JOBS}"
JOBS="${JOBS:-4}"

# Clobber build?  Overridden by bots with BUILDBOT_CLOBBER.
NEED_CLOBBER="${NEED_CLOBBER:-0}"

# Function to force-green a bot.
function bb_force_bot_green_and_exit {
  echo "@@@BUILD_STEP Bot forced green.@@@"
  exit 0
}

# Basic setup for all bots to run after a source tree checkout.
# $1: source root.
function bb_baseline_setup {
  echo "@@@BUILD_STEP cd into source root@@@"
  SRC_ROOT="$1"
  if [ ! -d "${SRC_ROOT}" ] ; then
    echo "Please specify a valid source root directory as an arg"
    echo '@@@STEP_FAILURE@@@'
    return 1
  fi
  cd $SRC_ROOT

  if [ ! -f build/android/envsetup.sh ] ; then
    echo "No envsetup.sh"
    echo "@@@STEP_FAILURE@@@"
    return 1
  fi

  echo "@@@BUILD_STEP Basic setup@@@"
  export ANDROID_SDK_ROOT=/usr/local/google/android-sdk-linux
  export ANDROID_NDK_ROOT=/usr/local/google/android-ndk-r7
  for mandatory_directory in "${ANDROID_SDK_ROOT}" "${ANDROID_NDK_ROOT}" ; do
    if [[ ! -d "${mandatory_directory}" ]]; then
      echo "Directory ${mandatory_directory} does not exist."
      echo "Build cannot continue."
      echo "@@@STEP_FAILURE@@@"
      return 1
    fi
  done

  if [ ! "$BUILDBOT_CLOBBER" = "" ]; then
    NEED_CLOBBER=1
  fi

  echo "@@@BUILD_STEP Configure with envsetup.sh@@@"
  . build/android/envsetup.sh

  if [ "$NEED_CLOBBER" -eq 1 ]; then
    echo "@@@BUILD_STEP Clobber@@@"
    rm -rf "${SRC_ROOT}"/out
    if [ -e "${SRC_ROOT}"/out ] ; then
      echo "Clobber appeared to fail?  ${SRC_ROOT}/out still exists."
      echo "@@@STEP_WARNINGS@@@"
    fi
  fi

  echo "@@@BUILD_STEP android_gyp@@@"
  android_gyp
}


# Compile step
function bb_compile {
  echo "@@@BUILD_STEP Compile@@@"
  make -j${JOBS}
}

# Experimental compile step; does not turn the tree red if it fails.
function bb_compile_experimental {
  # Linking DumpRenderTree appears to hang forever?
  # EXPERIMENTAL_TARGETS="DumpRenderTree webkit_unit_tests"
  EXPERIMENTAL_TARGETS="webkit_unit_tests"
  for target in ${EXPERIMENTAL_TARGETS} ; do
    echo "@@@BUILD_STEP Experimental Compile $target @@@"
    set +e
    make -j4 "${target}"
    if [ $? -ne 0 ] ; then
      echo "@@@STEP_WARNINGS@@@"
    fi
    set -e
  done
}

# Run tests on an emulator.
function bb_run_tests_emulator {
  echo "@@@BUILD_STEP Run Tests on an Emulator@@@"
  build/android/run_tests.py -e --xvfb --verbose
}

# Run tests on an actual device.  (Better have one plugged in!)
function bb_run_tests {
  echo "@@@BUILD_STEP Run Tests on an Emulator@@@"
  build/android/run_tests.py --xvfb --verbose
}