# -*- python -*-
# ex: set syntax=python:

# 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.

# This is the buildmaster config file for the 'chromium' bot. It must
# be installed as 'master.cfg' in your buildmaster's base directory
# (although the filename can be changed with the --basedir option to
# 'mktap buildbot master').

# It has one job: define a dictionary named BuildmasterConfig. This
# dictionary has a variety of keys to control different aspects of the
# buildmaster. They are documented in docs/config.xhtml .

# This file follows this naming convention:
# Factories: f_cr_rel_[type]
# Builders:  b_chromium_rel_[os]_[type]
# BuildDir:  chromium-rel-[os]-[type]
#
# os = xp/vista/linux/mac
# type = perf

from buildbot.changes import svnpoller
from buildbot.scheduler import Scheduler
from buildbot.scheduler import Triggerable

from master import build_utils
from master import chromium_notifier
from master import master_config
from master import master_utils
from master import slaves_list
from master.factory import chromium_factory

import config
import master_site_config

ActiveMaster = master_site_config.ChromiumPerf

# Enable MAIL_NOTIFIER in production to send perf sheriff alerts.
MAIL_NOTIFIER = ActiveMaster.is_production_host

# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}

# 'slavePortnum' defines the TCP port to listen on. This must match the value
# configured into the buildslaves (with their --master option)
c['slavePortnum'] = ActiveMaster.slave_port

# Disable compression for the stdio files.
c['logCompressionLimit'] = False

# Load the list of slaves.
slaves = slaves_list.SlavesList('slaves.cfg', 'ChromiumPerf')

config.DatabaseSetup(c, require_dbconfig=ActiveMaster.is_production_host)

####### CHANGESOURCES

# the 'change_source' list tells the buildmaster how it should find out about
# source code changes. Any class which implements IChangeSource can be added
# to this list: there are several in buildbot/changes/*.py to choose from.
def ChromeTreeFileSplitter(path):
  """split_file for the 'src' project in the trunk."""

  # Exclude .DEPS.git from triggering builds on chrome.
  if path == 'src/.DEPS.git':
    return None

  # List of projects we are interested in. The project names must exactly
  # match paths in the Subversion repository, relative to the 'path' URL
  # argument. build_utils.SplitPath() will use them as branch names to
  # kick off the Schedulers for different projects.
  projects = ['src']
  return build_utils.SplitPath(projects, path)

# Polls config.Master.trunk_url for changes
chromium_rev = 'http://src.chromium.org/viewvc/chrome?view=rev&revision=%s'
trunk_poller = svnpoller.SVNPoller(svnurl=config.Master.trunk_url,
                                   split_file=ChromeTreeFileSplitter,
                                   pollinterval=10,
                                   revlinktmpl=chromium_rev)

c['change_source'] = [trunk_poller]


####### SCHEDULERS

## configure the Schedulers

# Scheduler to trigger slaves that depend on the release build.
s_chromium = Scheduler(name='chromium',
                       branch='src',
                       treeStableTimer=60,
                       builderNames=['Win Builder',
                                     'Mac Builder',
                                     'Mac 10.8 Builder',
                                     'Linux Builder',
                                     'Android Builder',
                                    ])

s_chromium_winrel_trigger = Triggerable('winrel',
                                        ['XP Perf (1)',
                                         'XP Perf (2)',
                                         'XP Interactive Perf',
                                         'XP Perf (jank) (1)',
                                         'XP Perf (jank) (2)',
                                         'Win7 Perf (1)',
                                         'Win7 Perf (2)',
                                         'Win7 Interactive Perf',
                                         'Win7 Perf (jank) (1)',
                                         'Win7 Perf (jank) (2)',
                                         'Win7 GPU (ATI) Perf',
                                         'Win7 GPU (Intel) Perf',
                                         'Win7 GPU (Nvidia) Perf',
                                        ])

# Scheduler to trigger slaves that depend on the mac release build.
s_chromium_macrel_trigger = Triggerable('macrel',
                                        ['Mac10.6 Perf(1)',
                                         'Mac10.6 Perf(2)',
                                         'Mac10.6 Perf(3)',
                                         #'Mac10.7 Perf(1)',
                                         #'Mac10.7 Perf(2)',
                                         #'Mac10.7 Perf(3)',
                                         'Mac10.7 GPU (Intel) Perf',
                                        ])

# Scheduler to trigger slaves that depend on the linux release build.
s_chromium_linux_rel_trigger = Triggerable('linuxrel',
                                           ['Linux Perf (1)',
                                            'Linux Perf (2)',
                                            'Linux Perf (3)',
                                            'Linux Perf (4)',
                                            'Linux Perf (lowmem)',
                                           ])

s_chromium_android_rel_trigger = Triggerable('android_rel',
                                             ['Android GN',
                                              'Android Nexus4',
                                              'Android Nexus10',
                                             ])
c['schedulers'] = [s_chromium,
                   s_chromium_winrel_trigger,
                   s_chromium_macrel_trigger,
                   s_chromium_linux_rel_trigger,
                   s_chromium_android_rel_trigger,
                  ]

####### BUILDERS

# buildbot/process/factory.py provides several BuildFactory classes you can
# start with, which implement build processes for common targets (GNU
# autoconf projects, CPAN perl modules, etc). The factory.BuildFactory is the
# base class, and is configured with a series of BuildSteps. When the build
# is run, the appropriate buildslave is told to execute each Step in turn.

# the first BuildStep is typically responsible for obtaining a copy of the
# sources. There are source-obtaining Steps in buildbot/process/step.py for
# CVS, SVN, and others.

builders = []

# ----------------------------------------------------------------------------
# FACTORIES

m_win = chromium_factory.ChromiumFactory('src/out', 'win32')
m_linux = chromium_factory.ChromiumFactory('src/out', 'linux2')
m_mac = chromium_factory.ChromiumFactory('src/xcodebuild', 'darwin')
m_android = chromium_factory.ChromiumFactory(
    'src/out', 'linux2', nohooks_on_update=True, target_os='android')

# Some shortcut to simplify the code below.
F_WIN = m_win.ChromiumFactory
F_LINUX = m_linux.ChromiumFactory
F_MAC = m_mac.ChromiumFactory
F_ANDROID = m_android.ChromiumAnnotationFactory

chromium_rel_archive = 'gs://chrome-perf/Win Builder/full-build-win32.zip'
chromium_rel_mac_archive = master_config.GetArchiveUrl('ChromiumPerf',
    'Mac Builder',
    'chromium-rel-mac-builder',
    'mac')
chromium_rel_linux_archive = master_config.GetArchiveUrl('ChromiumPerf',
    'Linux Builder',
    'chromium-rel-linux',
    'linux')

android_rel_archive = master_config.GetGSUtilUrl(
    'chromium-android', 'android_perf_rel')

chromium_perf_archive = master_config.GetGSUtilUrl('chrome-perf', 'Win Builder')

# The identifier of the factory is the build configuration. If two factories
# are using the same build configuration, they should have the same identifier.

# BuilderTesters using a custom build configuration.
f_cr_rel_builder = F_WIN(slave_type='Builder',
                         options=[
                             '--build-tool=ninja', 'chromium_builder_perf'],
                         factory_properties={
                            'trigger': 'winrel',
                            'gclient_env': {
                                'GYP_DEFINES': 'fastbuild=1',
                                'GYP_GENERATORS': 'ninja'},
                            'build_url': chromium_perf_archive,})

f_cr_rel_perf_xp_1 = F_WIN(slave_type='Tester',
                           build_url=chromium_rel_archive,
                           tests=['page_cycler_bloat',
                                  'page_cycler_moz',
                                  'page_cycler_morejs',
                                  'page_cycler_intl_ar_fa_he',
                                  'page_cycler_intl_es_fr_pt-BR',
                                  'page_cycler_intl_hi_ru',
                                  'page_cycler_intl_ja_zh',
                                  'page_cycler_intl_ko_th_vi',
                                  'page_cycler_dhtml',
                                  'page_cycler_indexeddb',
                                  'page_cycler_tough_layout_cases',
                                  'page_cycler_typical_25',
                                  'dom_perf',
                                  'idb_perf'],
                           factory_properties={
                               'show_perf_results': True,
                               'expectations': True,
                               'halt_on_missing_build': True,
                               'perf_id': 'chromium-rel-xp-dual',
                               'process_dumps': True,
                               'start_crash_handler': True,})

f_cr_rel_perf_xp_2 = F_WIN(slave_type='Tester',
                           build_url=chromium_rel_archive,
                           tests=['blink_perf', 'dromaeo', 'kraken', 'memory'],
                           factory_properties={
                               'show_perf_results': True,
                               'expectations': True,
                               'halt_on_missing_build': True,
                               'perf_id': 'chromium-rel-xp-dual',
                               'process_dumps': True,
                               'start_crash_handler': True,})

f_cr_rel_perf_xp_int = F_WIN(slave_type='Tester',
                             build_url=chromium_rel_archive,
                             tests=['sunspider', 'octane', 'startup',
                                    'startup_measurement', 'tab_switching',
                                    'frame_rate'],
                             factory_properties={
                                 'show_perf_results': True,
                                 'expectations': True,
                                 'halt_on_missing_build': True,
                                 'perf_id': 'chromium-rel-xp-dual',
                                 'process_dumps': True,
                                 'start_crash_handler': True,})

f_cr_rel_perf_xp_jank_1 = F_WIN(slave_type='Tester',
                                build_url=chromium_rel_archive,
                                # startup tests should be re-enabled after they
                                # no longer crash this system.
                                tests=['page_cycler_bloat',
                                       'page_cycler_morejs',
                                       'page_cycler_moz',
                                       'page_cycler_intl_ar_fa_he',
                                       'page_cycler_intl_es_fr_pt-BR',
                                       'page_cycler_intl_hi_ru',
                                       'page_cycler_intl_ja_zh',
                                       'page_cycler_intl_ko_th_vi',
                                       'page_cycler_dhtml',
                                       'page_cycler_indexeddb',
                                       'page_cycler_tough_layout_cases',
                                       'page_cycler_typical_25',
                                       'dom_perf',
                                       'idb_perf'],
                                factory_properties={
                                  'show_perf_results': True,
                                  'expectations': True,
                                  'halt_on_missing_build': True,
                                  'perf_id': 'chromium-rel-xp-single',
                                  'process_dumps': True,
                                  'start_crash_handler': True,})

f_cr_rel_perf_xp_jank_2 = F_WIN(slave_type='Tester',
                                build_url=chromium_rel_archive,
                                # startup tests should be re-enabled after they
                                # no longer crash this system.
                                tests=['dromaeo', 'sunspider', 'octane'],
                                factory_properties={
                                  'show_perf_results': True,
                                  'expectations': True,
                                  'halt_on_missing_build': True,
                                  'perf_id': 'chromium-rel-xp-single',
                                  'process_dumps': True,
                                  'start_crash_handler': True,})

f_cr_rel_perf_win7_1 = F_WIN(slave_type='Tester',
                             build_url=chromium_rel_archive,
                             tests=['page_cycler_morejs',
                                    'page_cycler_moz',
                                    'page_cycler_intl_ar_fa_he',
                                    'page_cycler_intl_es_fr_pt-BR',
                                    'page_cycler_intl_hi_ru',
                                    'page_cycler_intl_ja_zh',
                                    'page_cycler_intl_ko_th_vi',
                                    'page_cycler_dhtml',
                                    'page_cycler_indexeddb',
                                    'page_cycler_tough_layout_cases',
                                    'page_cycler_typical_25',
                                    'dom_perf',
                                    'idb_perf'],
                             factory_properties={
                                 'show_perf_results': True,
                                 'expectations': True,
                                 'halt_on_missing_build': True,
                                 'perf_id': 'chromium-rel-win7-dual',
                                 'process_dumps': True,
                                 'start_crash_handler': True,})

f_cr_rel_perf_win7_2 = F_WIN(slave_type='Tester',
                             build_url=chromium_rel_archive,
                             tests=['blink_perf', 'dromaeo', 'kraken', 'memory',
                                    'sync', 'memory_measurement'],
                             factory_properties={
                                 'show_perf_results': True,
                                 'expectations': True,
                                 'halt_on_missing_build': True,
                                 'perf_id': 'chromium-rel-win7-dual',
                                 'process_dumps': True,
                                 'start_crash_handler': True,})

f_cr_rel_perf_win7_int = F_WIN(slave_type='Tester',
                               build_url=chromium_rel_archive,
                               tests=['memory', 'sunspider', 'octane',
                                      'startup', 'startup_measurement',
                                      'tab_switching', 'frame_rate'],
                               factory_properties={
                                   'show_perf_results': True,
                                   'expectations': True,
                                   'halt_on_missing_build': True,
                                   'perf_id': 'chromium-rel-win7-dual',
                                   'process_dumps': True,
                                   'start_crash_handler': True,})

f_cr_rel_perf_win7_jank_1 = F_WIN(slave_type='Tester',
                                  build_url=chromium_rel_archive,
                                  # dom_perf tests should be re-enabled after
                                  # they no longer crash this system.
                                  tests=['idb_perf',
                                         'page_cycler_bloat',
                                         'page_cycler_morejs',
                                         'page_cycler_moz',
                                         'page_cycler_intl_ar_fa_he',
                                         'page_cycler_intl_es_fr_pt-BR',
                                         'page_cycler_intl_hi_ru',
                                         'page_cycler_intl_ja_zh',
                                         'page_cycler_intl_ko_th_vi',
                                         'page_cycler_dhtml',
                                         'page_cycler_indexeddb',
                                         'page_cycler_typical_25',
                                         'startup',
                                         'startup_measurement'],
                                  factory_properties={
                                    'show_perf_results': True,
                                    'expectations': True,
                                    'halt_on_missing_build': True,
                                    'perf_id': 'chromium-rel-win7-single',
                                    'process_dumps': True,
                                    'start_crash_handler': True,})

f_cr_rel_perf_win7_jank_2 = F_WIN(slave_type='Tester',
                                  build_url=chromium_rel_archive,
                                  # dom_perf tests should be re-enabled after
                                  # they no longer crash this system.
                                  tests=['dromaeo', 'sunspider',
                                         'octane'],
                                  factory_properties={
                                    'show_perf_results': True,
                                    'expectations': True,
                                    'halt_on_missing_build': True,
                                    'perf_id': 'chromium-rel-win7-single',
                                    'process_dumps': True,
                                    'start_crash_handler': True,})

f_cr_rel_perf_win7_gpu_ati = F_WIN(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['spaceport', 'smoothness_measurement', 'robohornetpro',
           'jsgamebench', 'image_decoding_measurement', 'cc_perftests'],
    factory_properties={
        'show_perf_results': True,
        'expectations': True,
        'halt_on_missing_build': True,
        'perf_id': 'chromium-rel-win7-gpu-ati',
        'process_dumps': True,
        'start_crash_handler': True,})

f_cr_rel_perf_win7_gpu_intel = F_WIN(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['spaceport', 'smoothness_measurement', 'robohornetpro',
           'jsgamebench', 'image_decoding_measurement', 'cc_perftests'],
    factory_properties={
        'show_perf_results': True,
        'expectations': True,
        'halt_on_missing_build': True,
        'perf_id': 'chromium-rel-win7-gpu-intel',
        'process_dumps': True,
        'start_crash_handler': True,})

f_cr_rel_perf_win7_gpu_nvidia = F_WIN(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['spaceport', 'smoothness_measurement', 'robohornetpro',
           'jsgamebench', 'image_decoding_measurement', 'cc_perftests'],
    factory_properties={
        'show_perf_results': True,
        'expectations': True,
        'halt_on_missing_build': True,
        'perf_id': 'chromium-rel-win7-gpu-nvidia',
        'process_dumps': True,
        'start_crash_handler': True,})

f_cr_rel_linux_builder = F_LINUX(target='Release',
                                 slave_type='Builder',
                                 options=[
                                     '--build-tool=ninja', '--',
                                     'chromium_builder_perf'],
                                 factory_properties={
                                   'trigger': 'linuxrel',
                                   'gclient_env': {
                                       'GYP_GENERATORS': 'ninja'
                                   }})

f_cr_rel_linux_1 = F_LINUX(slave_type='Tester',
                           build_url=chromium_rel_linux_archive,
                           tests=['blink_perf',
                                  'image_decoding_measurement',
                                  'page_cycler_bloat',
                                  'page_cycler_moz',
                                  'page_cycler_morejs',
                                  'smoothness_measurement'],
                           factory_properties={
                               'show_perf_results': True,
                               'expectations': True,
                               'halt_on_missing_build': True,
                               'perf_id': 'linux-release'})

f_cr_rel_linux_2 = F_LINUX(slave_type='Tester',
                           build_url=chromium_rel_linux_archive,
                           tests=['dom_perf', 'idb_perf', 'memory',
                                  'sunspider', 'octane', 'dromaeo',
                                  'frame_rate', 'dom_checker', 'sync',
                                  'kraken', 'robohornetpro'],
                           factory_properties={
                               'show_perf_results': True,
                               'expectations': True,
                               'halt_on_missing_build': True,
                               'perf_id': 'linux-release'})

f_cr_rel_linux_3 = F_LINUX(slave_type='Tester',
                           build_url=chromium_rel_linux_archive,
                           tests=['page_cycler_2012Q2-netsim', 'startup',
                                  'startup_measurement'],
                           factory_properties={
                               'show_perf_results': True,
                               'expectations': True,
                               'halt_on_missing_build': True,
                               'perf_id': 'linux-release'})

f_cr_rel_linux_4 = F_LINUX(slave_type='Tester',
                           build_url=chromium_rel_linux_archive,
                           tests=['cc_perftests',
                                  'page_cycler_dhtml',
                                  'page_cycler_indexeddb',
                                  'page_cycler_intl_ar_fa_he',
                                  'page_cycler_intl_es_fr_pt-BR',
                                  'page_cycler_intl_hi_ru',
                                  'page_cycler_intl_ja_zh',
                                  'page_cycler_intl_ko_th_vi',
                                  'page_cycler_tough_layout_cases',
                                  'page_cycler_typical_25'
                                  ],
                           factory_properties={
                               'show_perf_results': True,
                               'expectations': True,
                               'halt_on_missing_build': True,
                               'perf_id': 'linux-release'})

f_cr_rel_linux_lowmem = F_LINUX(
    slave_type='Tester',
    build_url=chromium_rel_linux_archive,
    tests=['page_cycler_bloat', 'page_cycler_moz', 'page_cycler_morejs',
           'page_cycler_intl_ar_fa_he', 'page_cycler_intl_es_fr_pt-BR',
           'page_cycler_intl_hi_ru', 'page_cycler_intl_ja_zh',
           'page_cycler_intl_ko_th_vi', 'page_cycler_tough_layout_cases',
           'page_cycler_typical_25',
           'page_cycler_dhtml', 'page_cycler_indexeddb', 'startup',
           'startup_measurement', 'dom_perf', 'idb_perf', 'tab_switching',
           'memory', 'sunspider', 'octane', 'page_cycler_2012Q2-netsim',
           'frame_rate', 'sync'],
    factory_properties={
        'show_perf_results': True,
        'expectations': True,
        'halt_on_missing_build': True,
        'perf_id': 'linux-release-lowmem'})

# BuilderTesters using a custom build configuration.

f_cr_rel_mac_builder = F_MAC(
    slave_type='Builder',
    options=['--compiler=goma-clang', '--', '-target', 'chromium_builder_perf'],
    factory_properties={
        'trigger': 'macrel',
    })

f_cr_rel_mac_builder_108 = F_MAC(
    slave_type='Builder',
    options=['--compiler=goma-clang', '--', '-target', 'chromium_builder_perf'],
    )

# Helper since the 10.6, 10.7 differences are just for ids.
def RelMacPerfTester(perf_id, tests):
  return F_MAC(slave_type='Tester',
               build_url=chromium_rel_mac_archive,
               tests=tests,
               factory_properties={'show_perf_results': True,
                                   'expectations': True,
                                   'halt_on_missing_build': True,
                                   'perf_id': perf_id})

# TODO: XP/Vista Perf also runs: 'reliability', 'dom_checker'
# Tests are split across machines to get all the perf data as quickly as
# possible.
f_cr_rel_mac6_perf_1 = RelMacPerfTester('chromium-rel-mac6',
                                        ['page_cycler_bloat',
                                         'page_cycler_moz',
                                         'page_cycler_morejs',
                                         'page_cycler_intl_ar_fa_he',
                                         'page_cycler_intl_es_fr_pt-BR',
                                         'page_cycler_intl_hi_ru',
                                         'page_cycler_intl_ja_zh',
                                         'page_cycler_intl_ko_th_vi',
                                         'page_cycler_tough_layout_cases',
                                         'page_cycler_typical_25',
                                         'page_cycler_dhtml',
                                         'page_cycler_indexeddb'])

f_cr_rel_mac6_perf_2 = RelMacPerfTester('chromium-rel-mac6',
                                        ['blink_perf', 'startup',
                                         'startup_measurement', 'tab_switching',
                                         'memory', 'octane', 'sunspider',
                                         'dom_perf', 'idb_perf', 'dom_checker',
                                         'kraken'])

f_cr_rel_mac6_perf_3 = RelMacPerfTester('chromium-rel-mac6',
                                        ['dromaeo', 'sync', 'mach_ports',
                                         'page_cycler_2012Q2-netsim'])

# Same setup as 10.6, just using 10.7 naming.
f_cr_rel_mac7_perf_1 = RelMacPerfTester('chromium-rel-mac7',
                                        ['page_cycler_bloat',
                                         'page_cycler_moz',
                                         'page_cycler_morejs',
                                         'page_cycler_intl_ar_fa_he',
                                         'page_cycler_intl_es_fr_pt-BR',
                                         'page_cycler_intl_hi_ru',
                                         'page_cycler_intl_ja_zh',
                                         'page_cycler_intl_ko_th_vi',
                                         'page_cycler_typical_25',
                                         'page_cycler_dhtml',
                                         'page_cycler_indexeddb',
                                         'page_cycler_2012Q2-netsim'])

f_cr_rel_mac7_perf_2 = RelMacPerfTester('chromium-rel-mac7',
                                        ['startup', 'startup_measurement',
                                         'tab_switching', 'memory', 'octane',
                                         'sunspider', 'dom_perf', 'idb_perf',
                                         'dom_checker'])

f_cr_rel_mac7_perf_3 = RelMacPerfTester('chromium-rel-mac7',
                                        ['dromaeo', 'sync', 'mach_ports'])


# Same setup as 10.6, just using 10.7 naming.
f_cr_rel_mac7_perf_gpu_intel = RelMacPerfTester('chromium-rel-mac7-gpu-intel',
                                                ['image_decoding_measurement',
                                                 'spaceport',
                                                 'smoothness_measurement',
                                                 'robohornetpro',
                                                 'jsgamebench',
                                                 'cc_perftests'])
# Android

f_cr_rel_android_builder = F_ANDROID(
    target='Release',
    slave_type='AnnotatedBuilder',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'perf-builder-rel',
      'build_url': android_rel_archive,
      'trigger': 'android_rel',
    })


def AndroidPerf(device_id, tests=None):
  tests = tests or [
    'blink_perf',
    'cc_perftests',
    'dromaeo',
    'image_decoding_measurement',
    'jsgamebench',
    'kraken',
    'octane',
    'page_cycler_bloat',
    'page_cycler_dhtml',
    'page_cycler_indexeddb',
    'page_cycler_intl_ar_fa_he',
    'page_cycler_intl_es_fr_pt-BR',
    'page_cycler_intl_hi_ru',
    'page_cycler_intl_ja_zh',
    'page_cycler_intl_ko_th_vi',
    'page_cycler_morejs',
    'page_cycler_moz',
    'page_cycler_tough_layout_cases',
    'page_cycler_typical_25',
    'pica',
    'smoothness_measurement',
    'spaceport',
    'sunspider']

  return F_ANDROID(
    target='Release',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    tests=tests,
    factory_properties={
      'android_bot_id': 'perf-tests-rel-%s' % device_id,
      'build_url': android_rel_archive,
      'perf_id': 'android-%s' % device_id,
      'show_perf_results': True,
      'test_platform': 'android',
    })

f_cr_rel_android_gn = AndroidPerf('gn')
f_cr_rel_android_nexus4 = AndroidPerf('nexus4')
f_cr_rel_android_nexus10 = AndroidPerf('nexus10')

# ----------------------------------------------------------------------------
# BUILDER DEFINITIONS

# The 'builders' list defines the Builders. Each one is configured with a
# dictionary, using the following keys:
#  name (required): the name used to describe this bilder
#  builddir (required): which subdirectory to run the builder in
#  factory (required): a BuildFactory to define how the build is run
#  periodicBuildTime (optional): if set, force a build every N seconds
#  category (optional): it is not used in the normal 'buildbot' meaning. It is
#                       used by gatekeeper to determine which steps it should
#                       look for to close the tree.
#

b_chromium_rel_win_builder = {'name': 'Win Builder',
  'builddir': 'chromium-rel-builder',
  'factory': f_cr_rel_builder,
  'category': '1windows|builders_compile|builders_windows',
  'auto_reboot': False,
}

b_chromium_rel_xp_perf_1 = {'name': 'XP Perf (1)',
  'builddir': 'chromium-rel-xp-perf-1',
  'factory': f_cr_rel_perf_xp_1,
  'category': '1windows|builder_testers',
}

b_chromium_rel_xp_perf_2 = {'name': 'XP Perf (2)',
  'builddir': 'chromium-rel-xp-perf-2',
  'factory': f_cr_rel_perf_xp_2,
  'category': '1windows|builder_testers',
}

b_chromium_rel_xp_interactive_perf = {'name': 'XP Interactive Perf',
  'builddir': 'chromium-rel-xp-int-perf',
  'factory': f_cr_rel_perf_xp_int,
  'category': '1windows|builder_testers',
  # Work around http://crbug.com/69940 by force-enabling auto_reboot.
  'auto_reboot': True,
}

b_chromium_rel_xp_perf_jank_1 = {'name': 'XP Perf (jank) (1)',
  'builddir': 'chromium-rel-xp-perf-single-1',
  'factory': f_cr_rel_perf_xp_jank_1,
  'category': '1windows|builder_testers',
}

b_chromium_rel_xp_perf_jank_2 = {'name': 'XP Perf (jank) (2)',
  'builddir': 'chromium-rel-xp-perf-single-2',
  'factory': f_cr_rel_perf_xp_jank_2,
  'category': '1windows|builder_testers',
}

b_chromium_rel_win7_perf_1 = {'name': 'Win7 Perf (1)',
  'builddir': 'chromium-rel-win7-perf-1',
  'factory': f_cr_rel_perf_win7_1,
  'category': '1windows|builder_testers',
}

b_chromium_rel_win7_perf_2 = {'name': 'Win7 Perf (2)',
  'builddir': 'chromium-rel-win7-perf-2',
  'factory': f_cr_rel_perf_win7_2,
  'category': '1windows|builder_testers',
}

b_chromium_rel_win7_perf_int = {'name': 'Win7 Interactive Perf',
  'builddir': 'chromium-rel-win7-perf-int',
  'factory': f_cr_rel_perf_win7_int,
  'category': '1windows|builder_testers',
}

b_chromium_rel_win7_perf_jank_1 = {'name': 'Win7 Perf (jank) (1)',
  'builddir': 'chromium-rel-win7-perf-single-1',
  'factory': f_cr_rel_perf_win7_jank_1,
  'category': '1windows|builder_testers',
}

b_chromium_rel_win7_perf_jank_2 = {'name': 'Win7 Perf (jank) (2)',
  'builddir': 'chromium-rel-win7-perf-single-2',
  'factory': f_cr_rel_perf_win7_jank_2,
  'category': '1windows|builder_testers',
}

b_chromium_rel_win7_perf_gpu_ati = {'name': 'Win7 GPU (ATI) Perf',
  'builddir': 'chromium-rel-win7-perf-gpu-ati',
  'factory': f_cr_rel_perf_win7_gpu_ati,
  'category': '1windows|builder_testers',
}

b_chromium_rel_win7_perf_gpu_intel = {'name': 'Win7 GPU (Intel) Perf',
  'builddir': 'chromium-rel-win7-perf-gpu-intel',
  'factory': f_cr_rel_perf_win7_gpu_intel,
  'category': '1windows|builder_testers',
}

b_chromium_rel_win7_perf_gpu_nvidia = {'name': 'Win7 GPU (Nvidia) Perf',
  'builddir': 'chromium-rel-win7-perf-gpu-nvidia',
  'factory': f_cr_rel_perf_win7_gpu_nvidia,
  'category': '1windows|builder_testers',
}

b_chromium_rel_linux_builder = {'name': 'Linux Builder',
  'builddir': 'chromium-rel-linux',
  'factory': f_cr_rel_linux_builder,
  'category': '4linux|builders_compile|builder_testers',
  'auto_reboot': False,
}

b_chromium_rel_linux_1 = {'name': 'Linux Perf (1)',
  'builddir': 'chromium-rel-linux-1',
  'factory': f_cr_rel_linux_1,
  'category': '4linux|builders_compile|builder_testers',
}

b_chromium_rel_linux_2 = {'name': 'Linux Perf (2)',
  'builddir': 'chromium-rel-linux-2',
  'factory': f_cr_rel_linux_2,
  'category': '4linux|builders_compile|builder_testers',
}

b_chromium_rel_linux_3 = {'name': 'Linux Perf (3)',
  'builddir': 'chromium-rel-linux-3',
  'factory': f_cr_rel_linux_3,
  'category': '4linux|builders_compile|builder_testers',
}

b_chromium_rel_linux_4 = {'name': 'Linux Perf (4)',
  'builddir': 'chromium-rel-linux-4',
  'factory': f_cr_rel_linux_4,
  'category': '4linux|builders_compile|builder_testers',
}

b_chromium_rel_linux_lowmem = {'name': 'Linux Perf (lowmem)',
  'builddir': 'chromium-rel-linux-lowmem',
  'factory': f_cr_rel_linux_lowmem,
  'category': '4linux|builders_compile|builder_testers',
}

b_chromium_rel_mac_builder = {'name': 'Mac Builder',
  'builddir': 'chromium-rel-mac-builder',
  'factory': f_cr_rel_mac_builder,
  'category': '3mac|builders_compile',
  'auto_reboot': False,
}

b_chromium_rel_mac8_builder = {'name': 'Mac 10.8 Builder',
  'builddir': 'chromium-rel-mac8-builder',
  'factory': f_cr_rel_mac_builder_108,
  'category': '3mac|builders_compile',
  'auto_reboot': False,
}

b_chromium_rel_mac6_perf_1 = {'name': 'Mac10.6 Perf(1)',
  'builddir': 'chromium-rel-mac6-perf',
  'factory': f_cr_rel_mac6_perf_1,
  'category': '3mac|builder_testers',
}

b_chromium_rel_mac6_perf_2 = {'name': 'Mac10.6 Perf(2)',
  'builddir': 'chromium-rel-mac6-perf-2',
  'factory': f_cr_rel_mac6_perf_2,
  'category': '3mac|builder_testers',
}

b_chromium_rel_mac6_perf_3 = {'name': 'Mac10.6 Perf(3)',
  'builddir': 'chromium-rel-mac6-perf-3',
  'factory': f_cr_rel_mac6_perf_3,
  'category': '3mac|builder_testers',
}

b_chromium_rel_mac7_perf_1 = {'name': 'Mac10.7 Perf(1)',
  'builddir': 'chromium-rel-mac7-perf',
  'factory': f_cr_rel_mac7_perf_1,
  'category': '3mac|builder_testers',
}

b_chromium_rel_mac7_perf_2 = {'name': 'Mac10.7 Perf(2)',
  'builddir': 'chromium-rel-mac7-perf-2',
  'factory': f_cr_rel_mac7_perf_2,
  'category': '3mac|builder_testers',
}

b_chromium_rel_mac7_perf_3 = {'name': 'Mac10.7 Perf(3)',
  'builddir': 'chromium-rel-mac7-perf-3',
  'factory': f_cr_rel_mac7_perf_3,
  'category': '3mac|builder_testers',
}

b_chromium_rel_mac7_perf_gpu_intel = {'name': 'Mac10.7 GPU (Intel) Perf',
  'builddir': 'chromium-rel-mac7-perf-gpu-intel',
  'factory': f_cr_rel_mac7_perf_gpu_intel,
  'category': '3mac|builder_testers',
}

b_chromium_rel_android_builder = {'name': 'Android Builder',
  'factory': f_cr_rel_android_builder,
  'category': '4android|builder_testers',
}

b_chromium_rel_android_gn = {'name': 'Android GN',
  'factory': f_cr_rel_android_gn,
  'category': '4android|builder_testers',
}

b_chromium_rel_android_nexus4 = {'name': 'Android Nexus4',
  'factory': f_cr_rel_android_nexus4,
  'category': '4android|builder_testers',
}

b_chromium_rel_android_nexus10 = {'name': 'Android Nexus10',
  'factory': f_cr_rel_android_nexus10,
  'category': '4android|builder_testers',
}

c['builders'] = [
  b_chromium_rel_win_builder,
  b_chromium_rel_xp_perf_1,
  b_chromium_rel_xp_perf_2,
  b_chromium_rel_xp_interactive_perf,
  b_chromium_rel_xp_perf_jank_1,
  b_chromium_rel_xp_perf_jank_2,
  b_chromium_rel_win7_perf_1,
  b_chromium_rel_win7_perf_2,
  b_chromium_rel_win7_perf_int,
  b_chromium_rel_win7_perf_jank_1,
  b_chromium_rel_win7_perf_jank_2,
  b_chromium_rel_win7_perf_gpu_ati,
  b_chromium_rel_win7_perf_gpu_intel,
  b_chromium_rel_win7_perf_gpu_nvidia,
  b_chromium_rel_mac_builder,
  b_chromium_rel_mac8_builder,
  b_chromium_rel_mac6_perf_1,
  b_chromium_rel_mac6_perf_2,
  b_chromium_rel_mac6_perf_3,
#  b_chromium_rel_mac7_perf_1,
#  b_chromium_rel_mac7_perf_2,
#  b_chromium_rel_mac7_perf_3,
  b_chromium_rel_mac7_perf_gpu_intel,
  b_chromium_rel_linux_builder,
  b_chromium_rel_linux_1,
  b_chromium_rel_linux_2,
  b_chromium_rel_linux_3,
  b_chromium_rel_linux_4,
  b_chromium_rel_linux_lowmem,
  b_chromium_rel_android_builder,
  b_chromium_rel_android_gn,
  b_chromium_rel_android_nexus4,
  b_chromium_rel_android_nexus10,
]


####### BUILDSLAVES

# Associate the slaves to the manual builders. The configuration is in
# slaves.cfg.
for builder in c['builders']:
  builder['slavenames'] = slaves.GetSlavesName(builder=builder['name'])

# The 'slaves' list defines the set of allowable buildslaves. List all the
# slaves registered to a builder. Remove dupes.
c['slaves'] = master_utils.AutoSetupSlaves(c['builders'],
                                           config.Master.GetBotPassword())
master_utils.VerifySetup(c, slaves)


####### STATUS TARGETS

# Adds common status and tools to this master.
master_utils.AutoSetupMaster(c, ActiveMaster,
    public_html='../master.chromium/public_html',
    templates=['../master.chromium/templates'],
    enable_http_status_push=ActiveMaster.is_production_host)

# Add more.

if MAIL_NOTIFIER:
  categories_steps = {
    '': ['update'],
    'builder_testers': [
      # Perf tests
      'dom_perf',
      'idb_perf',
      'memory_test',
      'new_tab_ui_cold_test',
      'new_tab_ui_warm_test',
      'page_cycler_bloat',
      'page_cycler_dhtml',
      'page_cycler_intl_ar_fa_he',
      'page_cycler_intl_es_fr_pt-BR',
      'page_cycler_intl_hi_ru',
      'page_cycler_intl_ja_zh',
      'page_cycler_intl_ko_th_vi',
      'page_cycler_morejs',
      'page_cycler_moz',
      'page_cycler_tough_layout_cases',
      'page_cycler_typical_25',
      'page_cycler_2012Q2-netsim',
      'startup_test',
      'tab_switching_test',
      'frame_rate_test',
      'sync',
     ],
    'builders_windows': [],
    'builders_compile': []
  }
  exclusions = { }
  forgiving_steps = [ ]
  c['status'].append(chromium_notifier.ChromiumNotifier(
      fromaddr=ActiveMaster.from_address,
      categories_steps=categories_steps,
      exclusions=exclusions,
      relayhost=config.Master.smtp,
      status_header='Perf alert on "%(builder)s":\n%(steps)s',
      subject='%(projectName)s %(builder)s %(result)s',
      extraRecipients=[],
      lookup=master_utils.FilterDomain(),
      sheriffs=['sheriff_perf'],
      public_html='../master.chromium/public_html',
      forgiving_steps=forgiving_steps,
      use_getname=True))

####### PROJECT IDENTITY

# the 'projectName' string will be used to describe the project that this
# buildbot is working on. For example, it is used as the title of the
# waterfall HTML page. The 'projectURL' string will be used to provide a link
# from buildbot HTML pages to your project's home page.

c['projectName'] = ActiveMaster.project_name
c['projectURL'] = config.Master.project_url

# the 'buildbotURL' string should point to the location where the buildbot's
# internal web server (usually the html.Waterfall page) is visible. This
# typically uses the port number set in the Waterfall 'status' entry, but
# with an externally-visible host name which the buildbot cannot figure out
# without some help.

c['buildbotURL'] = 'http://build.chromium.org/p/chromium.perf/'
