# vim: ft=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.

from buildbot.changes import svnpoller
from buildbot.scheduler import Dependent
from buildbot.scheduler import Nightly
from buildbot.scheduler import Periodic
from buildbot.scheduler import Scheduler
from buildbot.scheduler import Triggerable
from buildbot.status.mail import MailNotifier

# These modules come from scripts/master, which must be in the PYTHONPATH.
from master import build_utils
from master import chromium_notifier
from master import failures_notifier
from master import master_config
from master import master_utils
from master import slaves_list

from master.factory import annotator_factory
from master.factory import chromeos_factory
from master.factory import chromium_factory

# These modules come from scripts/common, which must be in the PYTHONPATH.
import config
import master_site_config

import master_gitzip_cfg
import master_win_asan_cfg

ActiveMaster = master_site_config.ChromiumFYI

CODESEARCH_NOTIFIER = True
DRMEMORY_NOTIFIER = True
STATUS_PUSH = False

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

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)

# Rev link urls.
chromium_rev = 'http://src.chromium.org/viewvc/chrome?view=rev&revision=%s'

# Polls config.Master.trunk_url for changes
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

# Main scheduler for all changes in trunk.
s_chromium = Scheduler(
    name='chromium',
    branch='src',
    treeStableTimer=60,
    builderNames=['Chromium Linux Reliability (valgrind)',
                  'Chromium Linux Browser Builder (valgrind)',
                  'Chromium Linux Browser (valgrind) (1)',
                  'Chromium Linux Browser (valgrind) (2)',
                  'Chromium Linux Browser (valgrind) (3)',
                  'Chromium Linux Browser (valgrind) (4)',
                  'Chromium Builder',
                  'Chromium Linux Perf',
                  'Chromium Windows Perf',
                  'Chromium Mac Perf',
                  'Chromium Cros32 Perf',
                  'Chromium Cros64 Perf',
                  'Chromium Windows Instant Extended',
                  'Chromium Linux Buildrunner',
                  'Chromium Windows Buildrunner',
                  'Chromium Mac Buildrunner',
                  'Chromium Mac 10.8 Buildrunner',
                  'Chromium Builder (dbg)',
                  'Chromium Win Multiple',
                  'Chromium Win VS2012 (dbg)',
                  'Chromium Win VS2012',
                  'Chromium Win VS2012 Goma (dbg)',
                  'Chromium Win VS2012 Goma',
                  'Chromium Win Ninja Goma',
                  'Chromium Win Ninja Goma (shared)',
                  'Chromium Win x64 Clobber',
                  'Chromium Win7 Ninja Goma',
                  'Chromium Win7 Ninja Goma (shared)',
                  'Linux Tests (tsan RV)',
                  'Chromium Linux TSan v2',
                  'Chromium Linux LSan (and ASan)',
                  'Chromium Mac 10.6 (tsan)',
                  'Windows Tests (DrMemory XP)',
                  'Windows Unit (DrMemory full) (1)',
                  'Windows Unit (DrMemory full) (2)',
                  'Windows Browser (DrMemory full) (1)',
                  'Windows Browser (DrMemory full) (2)',
                  'Windows Browser (DrMemory full) (3)',
                  'Windows Browser (DrMemory full) (4)',
                  'Windows Builder (DrMemory)',
                  'Windows Tests (TSan Win 7)',
                  'Chromium Vista Memory',
                  'Chromium Linux Memory',
                  'Chromium Mac Memory',
                  'Chromium Linux Redux',
                  'Linux ARM Cross-Compile',
                  'Android Builder (dbg)',
                  'Android x86 Builder (dbg)',
                  'Android User Builder Tests',
                  'Android Asan Builder Tests (dbg)',
                  'Android Builder Tests (JB Nexus7)(shared)',
                  'Android AOSP Builder (dbg)',
                  'Chromium iOS Simulator (dbg)',
                  'Chromium iOS Device',
                  'More NaCl Tests (mac)',
                  'More NaCl Tests (linux)',
                  'Chromium Linux Goma Canary',
                  'Chromium Linux Precise Goma LinkTest',
                  'Chromium Linux32 Goma Canary',
                  'Chromium Mac 10.6 Goma Canary',
                  'Chromium Mac 10.7 Goma Canary',
                  'Chromium Mac 10.6 Ninja Goma Canary',
                  'Chromium Mac 10.7 Ninja Goma Canary',
                  'Chromium Mac 10.8 x64 (experimental)',
                  'Windows 8 App Certification',
                  'ChromiumOS Linux Tests',
                  ])

# Triggerable scheduler for Windows Release.
s_chromium_win_rel = Triggerable(
    name='win_rel',
    builderNames=['Chrome Frame Perf',
                  'Chrome Frame Tests (ie6)(peruser)',
                  'Chrome Frame Tests (ie7)(peruser)',
                  'Chrome Frame Tests (ie8)(peruser)',
                  'More NaCl Tests (win32)',
                  'More NaCl Tests (win64)',
                  'Win8 Tests (1)',
                  'Win8 Tests (2)',
                  'Windows Tests (Memory benchmark)'])

# Triggerable scheduler for Windows Debug.
s_chromium_win_dbg = Triggerable(
    name='win_dbg',
    builderNames=['Vista Tests (dbg)(1)',
                  'Vista Tests (dbg)(2)',
                  'Chrome Frame Tests (ie8)(dbg)'])

# Triggerable scheduler for Android Builder
s_chromium_android_dbg = Triggerable(
    name='android_dbg',
    builderNames=['Android Tests (JB GalaxyNexus)(dbg)',
                  'Android Tests (ICS GalaxyNexus)(dbg)',
                  'Android Tests (JB Nexus7)(dbg)',
                  'Android ChromeDriver Tests (dbg)'])

s_chromium_linux_browser_valgrind_trigger = Triggerable(
    'chromium_linux_browser_valgrind',
    ['Chromium Linux Browser (valgrind) (1)',
     'Chromium Linux Browser (valgrind) (2)',
     'Chromium Linux Browser (valgrind) (3)',
     'Chromium Linux Browser (valgrind) (4)',
    ])

s_chromium_windows_drmemory_trigger = Triggerable(
    name='chromium_windows_drmemory',
    builderNames=[
     'Windows Unit (DrMemory full) (1)',
     'Windows Unit (DrMemory full) (2)',
     'Windows Browser (DrMemory full) (1)',
     'Windows Browser (DrMemory full) (2)',
     'Windows Browser (DrMemory full) (3)',
     'Windows Browser (DrMemory full) (4)',
    ])

# Triggerable scheduler for Codesearch.
s_chromium_codesearch = Triggerable(
    name='chromium_codesearch',
    builderNames=[
      'Chromium Linux Codesearch',
      'ChromiumOS Codesearch',
    ])


# Triggerable scheduler for Linux ARM
s_chromium_linux_arm = Triggerable(
    name='chromium_linux_arm',
    builderNames=[
        'Linux ARM Tests (Panda)'
    ])

# Triggerable scheduler for 10.8 x64 tests
s_chromium_mac_108_x64_experimental = Triggerable(
    name='chromium_mac_108_x64_experimental',
    builderNames=[
        'Chromium Mac 10.8 x64 tester (experimental)'
    ])

# Triggerable scheduler for Windows Coverage
s_chromium_win_coverage = Triggerable(
    name='chromium_win_coverage',
    builderNames=[
        'Win Coverage Tests (1)',
        'Win Coverage Tests (2)',
        'Win Coverage Tests (3)',
        'Win Coverage Tests (4)',
        'Win Coverage Tests (5)',
    ])

# 4-hourly scheduler.
#
# The Codesearch Scheduler bot will trigger the s_chromium_codesearch scheduler,
# so all codesearch bots will start on the same revision.
s_chromium_4hourly = Nightly(name='chromium_4hourly',
                             builderNames=[
                               'Chromium Codesearch Scheduler',
                             ],
                             branch='src',
                             hour=range(0, 24, 4),
                             minute=0)

# 4 times daily build of metro_driver and delegate_execute for Win8.
s_chromium_6hourly = Nightly(name='chromium_6hourly',
                             builderNames=['Win8 (delegate_execute)',
                                           'Win8 (metro_driver)'],
                             branch='src',
                             hour=range(0, 24, 6),
                             minute=0)

# Once an hour scheduler to provide a periodic poll of lkgr.  The
# coverage builds "run" once an hour but nop themselves if lkgr hasn't
# changed.
s_chromium_hourly = Periodic(name="hourly",
                             builderNames=['Linux Coverage (dbg)',
                                           'Win Coverage Processor'],
                             periodicBuildTimer=60*60)  # in seconds


c['schedulers'] = [s_chromium,
                   s_chromium_hourly,
                   s_chromium_4hourly,
                   s_chromium_6hourly,
                   s_chromium_android_dbg,
                   s_chromium_codesearch,
                   s_chromium_win_rel,
                   s_chromium_win_dbg,
                   s_chromium_linux_browser_valgrind_trigger,
                   s_chromium_windows_drmemory_trigger,
                   s_chromium_linux_arm,
                   s_chromium_mac_108_x64_experimental,
                   s_chromium_win_coverage,
                  ]

# Tests that are single-machine shard-safe.
sharded_tests = [
  'aura_unittests',
  'base_unittests',
  'browser_tests',
  'cacheinvalidation_unittests',
  'cc_unittests',
  'chromedriver2_tests',
  'chromedriver2_unittests',
  'components_unittests',
  'content_browsertests',
  'content_unittests',
  'crypto_unittests',
  'device_unittests',
  'gpu_unittests',
  'jingle_unittests',
  'media_unittests',
  'net_unittests',
  'ppapi_unittests',
  'printing_unittests',
  'remoting_unittests',
  'sync_integration_tests',
  'sync_unit_tests',
  'ui_unittests',
  'unit_tests',
  'views_unittests',
  'webkit_compositor_bindings_unittests',
]

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

F = chromium_factory.ChromiumFactory
def win(): return F('src/chrome', 'win32')
def win_build(): return F('src/build', 'win32')
def win_out(): return F('src/out', 'win32')
def win_metro(): return F('src/metro_driver', 'win32')
def win_delegate(): return F('src/delegate_execute', 'win32')
def mac(): return F('src/xcodebuild', 'darwin')
def linux(**kwargs): return F('src/out', 'linux2', **kwargs)
def ios(): return F('src/xcodebuild', 'darwin')

def codesearch():
  return F('src/build', 'linux2', pull_internal=False, full_checkout=True,
           additional_svn_urls=[config.Master.trunk_url_tools])

def codesearch_scheduler():
  return F('src/build', 'linux2', pull_internal=False)

def chromeos():
  return F('src/build', 'linux2')

def linux_android(custom_deps_list=None):
  return F('src/build', 'linux2', nohooks_on_update=True, target_os='android',
           custom_deps_list=custom_deps_list)

chromium_rel_archive = master_config.GetArchiveUrl(
    'ChromiumFYI',
    'Chromium Builder',
    'chromium-rel-builder',
    'win32')

chromium_dbg_archive = master_config.GetArchiveUrl(
    'ChromiumFYI',
    'Chromium Builder (dbg)',
    'chromium-dbg-builder',
    'win32')

chromium_linux_browser_valgrind_archive = master_config.GetArchiveUrl(
    'ChromiumFYI',
    'Chromium Linux Browser Builder (valgrind)',
    'chromium-rel-linux-browser-valgrind-builder',
    'linux')

chromium_windows_drmemory_archive = master_config.GetArchiveUrl(
    'ChromiumFYI',
    'Windows Builder (DrMemory)',
    'drm-cr',
    'win32')

chromium_linux_arm_archive = master_config.GetGSBuildCacheUrl(
    ActiveMaster.project_name, 'Linux ARM Cross-Compile')

chromium_dbg_win_drmemory_archive_ext = ('http://vm832-m1/b/build/slave/'
                                         'chromium-dbg-win-drmemory-builder/'
                                         'chrome_staging/full-build-win32.zip')

chromium_rel_archive_ext = ('http://master.chromium.org:8802/b/build/slave'
                            '/chromium-rel-builder/chrome_staging/'
                            'full-build-win32.zip')

chromium_android_fyi_dbg_archive = master_config.GetGSUtilUrl(
    'chromium-android', 'android_fyi_dbg')

chromium_mac_108_x64_experimental_archive = master_config.GetGSUtilUrl(
    'chromium-qa', 'Chromium Mac 10.8 x64 (experimental)')

# The identifier of the factory is the build configuration. If two factories
# are using the same build configuration, they should have the same identifier.
f_chromium_rel_builder = win_build().ChromiumFactory(
    slave_type='Builder',
    project='all.sln;chromium_builder_tests',
    factory_properties={'trigger': 'win_rel',
                        'gclient_env': {'GYP_DEFINES': 'fastbuild=1'}})

f_chromium_dbg_builder = win_build().ChromiumFactory(
    slave_type='Builder',
    target='Debug',
    project='all.sln;chromium_builder_tests',
    factory_properties={'trigger': 'win_dbg',
                        'gclient_env': {'GYP_DEFINES': 'fastbuild=1'}})

f_linux_perf = linux().ChromiumFactory(target='Release',
    slave_type='Builder',
    options=['--compiler=goma', '--', 'chromium_builder_perf'],
    factory_properties={
      'show_perf_results': True,
      'expectations': True,
      'halt_on_missing_build': True,
      'perf_id': 'linux-release-fyi'},
    tests=['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_bloat',
      'page_cycler_dhtml',
      'page_cycler_indexeddb',
      'smoothness_measurement',
      'jsgamebench',
      'kraken',
      'robohornetpro',
      'memory_measurement',
      'telemetry_unittests'])

f_win_perf = win_build().ChromiumFactory(slave_type='Builder',
    project='all.sln;chromium_builder_perf',
    factory_properties={
      'show_perf_results': True,
      'expectations': True,
      'halt_on_missing_build': True,
      'perf_id': 'chromium-rel-win7-dual-fyi',
      'process_dumps': True,
      'start_crash_handler': True,},
    tests=['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_bloat',
      'page_cycler_dhtml',
      'page_cycler_indexeddb',
      'smoothness_measurement',
      'jsgamebench',
      'kraken',
      'robohornetpro',
      'memory_measurement',
      'telemetry_unittests'])

f_mac_perf = mac().ChromiumFactory(slave_type='Builder',
    options=['--compiler=goma-clang', '--', '-target', 'chromium_builder_perf'],
    factory_properties={
      'archive_build': False,
      'show_perf_results': True,
      'expectations': True,
      'halt_on_missing_build': True,
      'perf_id': 'chromium-rel-mac7-fyi', },
    tests=['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_bloat',
      'page_cycler_dhtml',
      'page_cycler_indexeddb',
      'smoothness_measurement',
      'jsgamebench',
      'kraken',
      'robohornetpro',
      'memory_measurement',
      'telemetry_unittests'])

f_cros32_perf = chromeos_factory.CbuildbotFactory(
  buildroot='/b/cbuild.cros32_perf',
  pass_revision=True,
  params='x86-generic-telemetry').get_factory()

f_cros64_perf = chromeos_factory.CbuildbotFactory(
  buildroot='/b/cbuild.cros64_perf',
  pass_revision=True,
  params='amd64-generic-telemetry').get_factory()

f_win_instantextended = win_build().ChromiumFactory(
           project='all.sln;chromium_builder_tests',
           tests=[
               'instant_extended_manual_tests',
               'buildrunner_tests',
           ],
           slave_type='BuilderTester',
           factory_properties={
               'gclient_env': {
                   'GYP_DEFINES': 'fastbuild=1',
               },
               'process_dumps': True,
               'start_crash_handler': True,
               'generate_gtest_json': True,
           })

f_linux_buildrunner = linux().ChromiumFactory(
           tests=['base_unittests_br',
                  'browser_tests_br',
                  'cacheinvalidation_br',
                  'content_browsertests_br',
                  'crypto_br',
                  'dbus_br',
                  'googleurl_br',
                  'gpu_br',
                  'jingle_br',
                  'media_br',
                  'net_br',
                  'ppapi_unittests_br',
                  'printing_br',
                  'remoting_br',
                  'unit_br',
                  'buildrunner_tests',
           ],
           options=['--compiler=goma'],
           slave_type='Builder',
           factory_properties={
               'archive_build': False,
               'generate_gtest_json': True,
               'gclient_env': {
                   'GYP_DEFINES': 'target_arch=x64 '
                   'tests_run=noop,component=shared_library'}
           })

f_win_buildrunner = win_build().ChromiumFactory(
           project='all.sln;chromium_builder_tests',
           tests=['base_unittests_br',
                  'browser_tests_br',
                  'cacheinvalidation_br',
                  'content_browsertests_br',
                  'courgette_br',
                  'crypto_br',
                  'googleurl_br',
                  'gpu_br',
                  'installer_br',
                  'jingle_br',
                  'media_br',
                  'ppapi_unittests_br',
                  'printing_br',
                  'remoting_br',
                  'sandbox_br',
                  'buildrunner_tests',
           ],
           slave_type='Builder',
           factory_properties={'gclient_env': {'GYP_DEFINES': 'fastbuild=1',
                                               'GYP_MSVS_VERSION': '2008'},
                               'process_dumps': True,
                               'start_crash_handler': True,
                               'generate_gtest_json': True,
                               'archive_build': False,
           })

f_mac_buildrunner = mac().ChromiumFactory(
           tests=['base_unittests_br',
                  'browser_tests_br',
                  'cacheinvalidation_br',
                  'content_browsertests_br',
                  'crypto_br',
                  'googleurl_br',
                  'gpu_br',
                  'jingle_br',
                  'media_br',
                  'message_center_unittests_br',
                  'ppapi_unittests_br',
                  'printing_br',
                  'remoting_br',
                  'buildrunner_tests',
           ],
           options=['--compiler=goma-clang', '--', '-target',
                    'chromium_builder_tests'],
           factory_properties={
               'archive_build': False,
               'generate_gtest_json': True
           })


def without(these, notthese):
  return [x for x in these if x not in notthese]

tests_win_1 = ['base_unittests',
               'cacheinvalidation_unittests',
               'components_unittests',
               'courgette_unittests',
               'crypto_unittests',
               'device_unittests',
               'googleurl',
               'gpu',
               'installer',
               'jingle',
               'media',
               'net',
               'ppapi_unittests',
               'printing',
               'remoting',
               'sandbox',
               'unit',]
tests_win_2 = ['browser_tests',
               'content_browsertests']

f_chromium_rel_multiple_builder_tests = win_build().ChromiumFactory(
    slave_type='BuilderTester',
    options=['--build-tool=ninja', '--', 'chromium_builder_tests'],
    factory_properties={
        'gclient_env': {
            'GYP_DEFINES': ('component=static_library '
                            'fastbuild=1 '
                            'chrome_multiple_dll=1'),
            'GYP_GENERATORS': 'ninja',
        }})

f_chromium_rel_delegate = win_delegate().ChromiumFactory(slave_type='Builder')
f_chromium_rel_metro = win_metro().ChromiumFactory(slave_type='Builder')

f_chromium_dbg_tests_1 = win_build().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_dbg_archive,
    tests=tests_win_1,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_dbg_tests_2 = win_build().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_dbg_archive,
    tests=tests_win_2,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_rel_tests_1 = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=tests_win_1,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_rel_tests_2 = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=tests_win_2,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_cr_rel_perf_frame = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive_ext,
    tests=['chrome_frame_perftests'],
    factory_properties={'show_perf_results': True,
                        'expectations': True,
                        'perf_id': 'chromium-rel-frame',
                        'process_dumps': True,
                        'start_crash_handler': True,})

f_cr_rel_frame = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['chrome_frame'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True,})

f_cr_dbg_frame = win_build().ChromiumFactory(
    target='Debug',
    slave_type='Tester',
    build_url=chromium_dbg_archive,
    tests=['chrome_frame'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True,})

f_chromium_linux_redux = linux().ChromiumFactory(
    tests=[
      'base_unittests',
      'cacheinvalidation_unittests',
      'crypto_unittests',
      'device_unittests',
      'jingle',
      'net',
      'unit',
      'check_deps2git',
    ],
    options=['base_unittests',
             'cacheinvalidation_unittests',
             'content_unittests',
             'crypto_unittests',
             'device_unittests',
             'ipc_tests',
             'jingle_unittests',
             'media_unittests',
             'net_unittests',
             'ppapi_unittests',
             'printing_unittests',
             'remoting_unittests',
             'sql_unittests',
             'sync_unit_tests',
             'ui_unittests',
             'unit_tests',
             'url_unittests',
             ],
    factory_properties={
        'gclient_env': {
            'GYP_DEFINES': ('linux_fpic=1 '
                            'enable_touch_events=1 '
                            'disable_nacl=1 '
                            'linux_use_tcmalloc=0 '
                            'linux_breakpad=0 '
                            'remoting=0 '
                            'configuration_policy=0 '
                            'safe_browsing=0 '
                            'use_openssl=1')}})

# Windows Tests (DrMemory XP)
f_chromium_dbg_win_drmemory = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_dbg_win_drmemory_archive_ext,
    tests=[
      'drmemory_light_googleurl',
      'drmemory_light_printing',
      'drmemory_light_media',
      'drmemory_light_sql',
      'drmemory_light_crypto',
      'drmemory_light_remoting',
      'drmemory_light_ipc_tests',
      'drmemory_light_base_unittests',
      'drmemory_light_net',
      # run tests in shards to decrease the number of reports per shard.
      'drmemory_light_unit_1_of_3',
      'drmemory_light_unit_2_of_3',
      'drmemory_light_unit_3_of_3',
    ],
    factory_properties={'needs_drmemory': True}
)

# Windows Unit (DrMemory full) (1)
f_chromium_dbg_win_drmemory_full_1 = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_windows_drmemory_archive,
    tests=[
      'drmemory_full_googleurl',
      'drmemory_full_printing',
      'drmemory_full_media',
      'drmemory_full_sql',
      'drmemory_full_crypto',
      'drmemory_full_remoting',
      'drmemory_full_ipc_tests',
      'drmemory_full_base_unittests',
      'drmemory_full_net',
    ],
    factory_properties={'needs_drmemory': True},
)

# Windows Unit (DrMemory full) (2)
f_chromium_dbg_win_drmemory_full_2 = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_windows_drmemory_archive,
    tests=[
      # Full mode has a high memory overhead currently, so shard the tests
      # more.
      'drmemory_full_unit_1_of_6',
      'drmemory_full_unit_2_of_6',
      'drmemory_full_unit_3_of_6',
      'drmemory_full_unit_4_of_6',
      'drmemory_full_unit_5_of_6',
      'drmemory_full_unit_6_of_6',
    ],
    factory_properties={'needs_drmemory': True},
)


f_chromium_rel_win_morenacl = win().ChromiumFactory(
    target='Release',
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['nacl_integration'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_rel_mac_morenacl = mac().ChromiumFactory(
    target='Release',
    tests=['nacl_integration'],
    options=['--compiler=goma-clang'])

f_chromium_rel_linux_morenacl = linux().ChromiumFactory(
    target='Release',
    tests=['nacl_integration'])


f_cr_dbg_mac_106_tsan = mac().ChromiumFactory(
    target='Debug',
    tests=['tsan_base_unittests',
           'tsan_content',
           'tsan_crypto',
           'tsan_googleurl',
           'tsan_net',
           'tsan_ipc_tests',
           'tsan_media',
           'tsan_printing',
           'tsan_remoting',
           'tsan_sql',
           'tsan_sync',
           'tsan_ui_unittests',
           ],
    options=['--', '-project', '../build/all.xcodeproj',
             '-target', 'chromium_builder_dbg_tsan_mac'],
    factory_properties={
        'needs_valgrind': True,
        # Running out of address space on 10.5... try to buy some time.
        'gclient_env': {
            'GYP_DEFINES': 'build_for_tool=memcheck target_arch=ia32'}})

f_chromium_rel_linux_tsan_v2 = linux().ChromiumFactory(
    target='Release',
    slave_type='BuilderTester',
    options=[
      '--compiler=goma-clang',
      '--build-tool=ninja',
      '--llvm-tsan',
      'base_unittests',
      'browser_tests',
      'cacheinvalidation_unittests',
      'content_browsertests',
      'content_unittests',
      'crypto_unittests',
      'device_unittests',
      'gpu_unittests',
      'ipc_tests',
      'jingle_unittests',
      'media_unittests',
      'net_unittests',
      'ppapi_unittests',
      'printing_unittests',
      'remoting_unittests',
      'sandbox_linux_unittests',
      'sql_unittests',
      'sync_unit_tests',
      'ui_unittests',
      'unit_tests',
      'url_unittests',
    ],
    factory_properties={
        'tsan': True,
        'sharded_tests': sharded_tests,
        'gclient_env': {
            'GYP_DEFINES': ('tsan=1 '
                            'linux_use_tcmalloc=0 '
                            'release_extra_cflags="-gline-tables-only" '
                            'disable_nacl=1 '),
            'GYP_GENERATORS': 'ninja', }},
    tests=[
      'base_unittests',
      'browser_tests',
      'cacheinvalidation_unittests',
      'content_browsertests',
      'content_unittests',
      'crypto_unittests',
      'device_unittests',
      'googleurl',
      'gpu',
      'jingle',
      'net',
      'media',
      'ppapi_unittests',
      'printing',
      'remoting',
      'sandbox_linux_unittests',
      'unit_tests',
    ],
)

f_chromium_rel_linux_lsan_asan = linux().ChromiumFactory(
    target='Release',
    slave_type='BuilderTester',
    options=[
      '--compiler=goma-clang',
      '--build-tool=ninja',
      'base_unittests',
      'cacheinvalidation_unittests',
      'cc_unittests',
      'content_unittests',
      'crypto_unittests',
      'device_unittests',
      'gpu_unittests',
      'ipc_tests',
      'jingle_unittests',
      'media_unittests',
      'net_unittests',
      'ppapi_unittests',
      'printing_unittests',
      'remoting_unittests',
      'sandbox_linux_unittests',
      'sql_unittests',
      'sync_unit_tests',
      'ui_unittests',
      'unit_tests',
      'url_unittests',
    ],
    factory_properties={
        'lsan': True,
        'asan': True,
        'gclient_env': {
            'GYP_DEFINES': ('asan=1 '
                            'lsan=1 '
                            'linux_use_tcmalloc=0 '
                            'release_extra_cflags="-gline-tables-only" '),
            'GYP_GENERATORS': 'ninja', }},
    tests=[
      'base_unittests',
      'cacheinvalidation_unittests',
      'crypto_unittests',
      'device_unittests',
      'gpu',
      'jingle',
      'net',
      'sandbox_linux_unittests',
      'googleurl',
      'media',
      'ppapi_unittests',
      'printing',
      'remoting',
      'unit',
      'cc_unittests',
    ],
)

# GYP_DEFINES for running coverage.  Why we do each:
# coverage=1: turn it on!  (e.g. add -ftest-coverage on Linux, enable
#   the 'coverage' target, etc)
# fastbuild=1, enable_svg=0: try and make it smaller so we don't choke on link.
# (Sadly those two don't make us small enough to link with the 10.5 SDK.)
GYP_DEFINES_FOR_COVERAGE_WIN = ('coverage=1 '
                                'enable_svg=0')
# fastbuild=1 prevents PDB generation on Windows and it's necessary for
# code coverage, so we only add it for the other plaforms.
GYP_DEFINES_FOR_COVERAGE_POSIX = '%s fastbuild=1' % GYP_DEFINES_FOR_COVERAGE_WIN

f_coverage_dbg_linux = linux().ChromiumFactory(
    target='Debug',
    clobber=False,
    tests=['check_lkgr', 'run_coverage_bundles', 'process_coverage'],
    options=['--build-dir=src/chrome',
             '--', 'coverage_build'],
    factory_properties={
        'tests': ['browser_tests', 'unit_tests'],
        'lkgr': True,
        'gclient_env': {
            'GYP_DEFINES': GYP_DEFINES_FOR_COVERAGE_POSIX,
            'GYP_GENERATORS': 'make'},
        'show_perf_results': True,
        'perf_id': 'chromium-dbg-linux'})

f_chromium_rel_vista_memory = win().ChromiumFactory(
    tests=['memory'],
    options=['--', '/project', 'performance_ui_tests'],
    factory_properties={'show_perf_results': True,
                        'perf_id': 'chromium-rel-vista-memory'})

f_chromium_rel_linux_memory = linux().ChromiumFactory(
    tests=['memory'],
    options=['--', 'performance_ui_tests'],
    factory_properties={'show_perf_results': True,
                        'perf_id': 'chromium-rel-linux-memory',
                        'gclient_env': {'GYP_GENERATORS': 'make'}})

f_chromium_rel_mac_memory = mac().ChromiumFactory(
    tests=['memory'],
    options=['--', '-project', '../chrome/chrome.xcodeproj',
             '-target', 'performance_ui_tests'],
    factory_properties={'show_perf_results': True,
                        'perf_id': 'chromium-rel-mac-memory'})

f_chromium_rel_linux_tsan_rv = linux().ChromiumFactory(
    target='Release',
    tests=['tsan_rv_device_unittests',
           'tsan_rv_googleurl',
           'tsan_rv_printing',
           'tsan_rv_media',
           'tsan_rv_sql',
           'tsan_rv_ipc_tests',
           'tsan_rv_remoting',
           'tsan_rv_base_unittests',
           'tsan_rv_crypto',
           'tsan_rv_sync',
           'tsan_rv_net',
           'tsan_rv_ui_unittests',
           'tsan_rv_unit_1_of_2',
           'tsan_rv_unit_2_of_2',
           ],
    options=['content_unittests',
             'base_unittests',
             'crypto_unittests',
             'device_unittests',
             'ipc_tests',
             'media_unittests',
             'net_unittests',
             'ppapi_unittests',
             'printing_unittests',
             'remoting_unittests',
             'sql_unittests',
             'sync_unit_tests',
             'ui_unittests',
             'unit_tests',
             'url_unittests',
             ],
    factory_properties={
        'needs_valgrind': True,
        'gclient_env': {'GYP_DEFINES': 'build_for_tool=tsan'}})

f_chromium_dbg_win_tsan = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_dbg_win_drmemory_archive_ext,
    tests=[
      'tsan_googleurl',
      'tsan_printing',
      'tsan_remoting',
      'tsan_sql',
      'tsan_media',
      'tsan_ipc_tests',
      'tsan_base_unittests',
      'tsan_crypto',
      'tsan_net',
    ],
    factory_properties={
      'needs_tsan_win': True,
      'gclient_env': {
        'GYP_DEFINES' : 'build_for_tool=tsan'
      },
    },
)

f_chromium_rel_linux_valgrind_reliability = linux().ChromiumFactory(
    target='Release',
    tests=[
      'valgrind_interactive_ui_tests_1_of_10',
      'tsan_interactive_ui_tests_1_of_10',
    ],
    options=[
      'interactive_ui_tests',
    ],
    factory_properties={
        'needs_valgrind': True,
        'gclient_env': {
            'GYP_DEFINES': 'build_for_tool=tsan',
            'GYP_GENERATORS': 'make'}})

f_chromium_rel_linux_browser_valgrind_builder = linux().ChromiumFactory(
    target='Release',
    slave_type='Builder',
    options=['--compiler=goma',
             'browser_tests',
             'content_browsertests',
             ],
    factory_properties={
        'gclient_env': { 'GYP_DEFINES' : 'build_for_tool=memcheck' },
        'trigger': 'chromium_linux_browser_valgrind'})

f_chromium_windows_drmemory_builder = win_out().ChromiumFactory(
    target='Debug',
    slave_type='Builder',
    options=['--build-tool=ninja', '--', 'chromium_builder_dbg_drmemory_win'],
    factory_properties={
        'gclient_env': { 'GYP_DEFINES' : ('build_for_tool=drmemory '
                                          'component=shared_library'),
                         'GYP_GENERATORS': 'ninja'},
        'package_pdb_files': True,
        'trigger': 'chromium_windows_drmemory'})

f_chromium_win_ninja_goma = win_out().ChromiumFactory(
    slave_type='BuilderTester',
    project='all.sln;chromium_builder_tests',
    options=['--build-tool=ninja', '--compiler=goma'],
    tests=tests_win_1 + ['diagnose_goma'],
    factory_properties={
      'goma_canary': True,
      'slave_internal_url': config.Master.slave_internal_url,
      'gclient_env': {
        # Ninja/Goma needs to have this set at gyp time.
        'GYP_DEFINES': 'fastbuild=1 chromium_win_pch=0 disable_nacl=1',
    }})

f_chromium_win_ninja_goma_shared = win_out().ChromiumFactory(
    slave_type='BuilderTester',
    project='all.sln;chromium_builder_tests',
    options=['--build-tool=ninja', '--compiler=goma'],
    tests=tests_win_1 + ['diagnose_goma'],
    factory_properties={
        'goma_canary': True,
        'slave_internal_url': config.Master.slave_internal_url,
        'gclient_env': {
          # Ninja/Goma needs to have this set at gyp time.
          'GYP_DEFINES': ('component=shared_library '
                          'fastbuild=1 chromium_win_pch=0 disable_nacl=1'),
    }})

win_x64_tests = [
  'base_unittests',
  'cacheinvalidation_unittests',
  'cc_unittests',
  'chromedriver2_unittests',
  'components_unittests',
  'content_browsertests',
  'courgette_unittests',
  'crypto_unittests',
  'googleurl',
  'gpu',
  'installer',
  'interactive_ui_tests',
  'jingle',
  'media',
  'nacl_integration',
  'net',
  'ppapi_unittests',
  'printing',
  'remoting',
  'sandbox',
  'unit',
  'webkit_compositor_bindings_unittests',

  # These are long, so do them last
  'browser_tests',
  'sync_integration',
]

f_chromium_win_x64 = win_out().ChromiumFactory(
    slave_type='BuilderTester',
    clobber=True,
    target='Release_x64',
    tests=win_x64_tests,
    options=['--build-tool=ninja', '--', 'chromium_builder_tests'],
    factory_properties={
      'gclient_env': {
        'GYP_DEFINES': 'target_arch=x64',
        'GYP_MSVS_VERSION': '2012',
    }})

f_chromium_win_ninja_shared_2012_dbg = win_out().ChromiumFactory(
    slave_type='BuilderTester',
    options=['--build-tool=ninja', 'chromium_builder_tests'],
    tests=tests_win_1,
    target='Debug',
    factory_properties={
        'gclient_env': {
          'GYP_DEFINES': 'component=shared_library fastbuild=1',
          'GYP_MSVS_VERSION': '2012',
    }})

f_chromium_win_ninja_shared_2012 = win_out().ChromiumFactory(
    slave_type='BuilderTester',
    options=['--build-tool=ninja', 'chromium_builder_tests'],
    tests=tests_win_1,
    target='Release',
    factory_properties={
        'gclient_env': {
          'GYP_DEFINES': 'component=shared_library fastbuild=1',
          'GYP_MSVS_VERSION': '2012',
    }})

f_chromium_win_ninja_goma_shared_2012_dbg = win_out().ChromiumFactory(
    slave_type='BuilderTester',
    options=[
        '--build-tool=ninja', '--compiler=goma', '--',
        'chromium_builder_tests'
    ],
    tests=tests_win_1,
    target='Debug',
    factory_properties={
        'gclient_env': {
          'GYP_DEFINES': (
              'component=shared_library win_z7=1 chromium_win_pch=0'
          ),
          'GYP_MSVS_VERSION': '2012',
    }})

f_chromium_win_ninja_goma_shared_2012 = win_out().ChromiumFactory(
    slave_type='BuilderTester',
    options=[
        '--build-tool=ninja', '--compiler=goma', '--',
        'chromium_builder_tests'
    ],
    tests=tests_win_1,
    target='Release',
    factory_properties={
        'gclient_env': {
          'GYP_DEFINES': (
              'component=shared_library fastbuild=1 chromium_win_pch=0'
          ),
          'GYP_MSVS_VERSION': '2012',
    }})

f_chromium_codesearch_scheduler = codesearch_scheduler().ChromiumFactory(
    target='Debug',
    slave_type='Trigger',
    factory_properties={'trigger': 'chromium_codesearch'},
    )

f_chromium_codesearch_linux = codesearch().ChromiumCodesearchFactory(
    target='Debug',
    clobber=True,
    slave_type='Indexer',
    options=['--compiler=jsonclang'],
    factory_properties={
      'gclient_env': {
        'GYP_DEFINES': 'clang=1 fastbuild=1',
        # TODO(bauerb): Switch to ninja when we're able to set it up for
        # jsonclang in the gyp/compile steps (http://crbug.com/241870).
        'GYP_GENERATORS': 'make',
      },
      'package_filename': 'chromium-src',
    })

linux_aura_options=[
  'aura_builder',
  'base_unittests',
  'browser_tests',
  'cacheinvalidation_unittests',
  'compositor_unittests',
  'content_browsertests',
  'content_unittests',
  'crypto_unittests',
  'gpu_unittests',
  'interactive_ui_tests',
  'ipc_tests',
  'jingle_unittests',
  'media_unittests',
  'net_unittests',
  'ppapi_unittests',
  'printing_unittests',
  'remoting_unittests',
  'sql_unittests',
  'ui_unittests',
  'url_unittests',
]

f_chromium_codesearch_chromiumos = codesearch().ChromiumCodesearchFactory(
    target='Debug',
    clobber=True,
    slave_type='Indexer',
    options=['--compiler=jsonclang'] + linux_aura_options,
    factory_properties={
      'gclient_env': {
        'GYP_DEFINES':'clang=1 fastbuild=1 chromeos=1',
        # TODO(bauerb): Switch to ninja when we're able to set it up for
        # jsonclang in the gyp/compile steps (http://crbug.com/241870).
        'GYP_GENERATORS': 'make',
      },
      'package_filename': 'chromiumos-src',
    })


f_chromium_dbg_android_builder = \
  linux_android().ChromiumAnnotationFactory(
    target='Debug',
    slave_type='AnnotatedBuilder',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'fyi-builder-dbg',
      'build_url': chromium_android_fyi_dbg_archive,
      'trigger': 'android_dbg',
    })


f_chromium_dbg_android_x86_builder = \
  linux_android().ChromiumAnnotationFactory(
    target='Debug',
    slave_type='AnnotatedBuilder',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'fyi-x86-builder-dbg',
    })


f_chromium_rel_android_builder_tests = \
  linux_android().ChromiumAnnotationFactory(
    target='Release',
    slave_type='AnnotatedBuilder',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'fyi-user-builder-unit-tests-rel',
    })


f_chromium_dbg_android_shared = \
  linux_android().ChromiumAnnotationFactory(
    target='Debug',
    slave_type='AnnotatedBuilder',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'fyi-component-builder-tests-dbg',
    })


def f_chromium_dbg_android_tests(bot_id_suffix):
  return linux_android().ChromiumAnnotationFactory(
    target='Debug',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'fyi-tests-dbg-%s' % bot_id_suffix,
      'build_url': chromium_android_fyi_dbg_archive,
    })


f_chromium_dbg_android_chromedriver_tests = \
  linux_android(
      custom_deps_list=[F.CUSTOM_DEPS_WEBDRIVER_JAVA_TESTS]
      ).ChromiumAnnotationFactory(
    target='Debug',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'chromedriver-fyi-tests-dbg',
      'build_url': chromium_android_fyi_dbg_archive,
    })


f_chromium_dbg_android_asan_builder_tests = \
  linux_android().ChromiumAnnotationFactory(
    target='Debug',
    annotation_script='src/build/android/buildbot/bb_run_bot.py',
    factory_properties={
      'android_bot_id': 'asan-builder-tests-dbg',
    })

f_chromium_dbg_android_aosp_builder = \
  annotator_factory.AnnotatorFactory().BaseFactory(
    recipe='android_webview_aosp')


f_chromium_dbg_ios_simulator = ios().ChromiumFactory(
    target='Debug',
    tests=['base_unittests',
           'content_unittests',
           'crypto_unittests',
           'googleurl',
           'media',
           'net',
           'ui_unittests',
           'unit_sql',
           'unit_sync',
           'unit_tests',],
    options = [
        '--', '-project', '../build/all.xcodeproj', '-sdk',
        'iphonesimulator6.1', '-target', 'All'],
    factory_properties={
        'app_name': 'Chromium.app',
        'test_platform': 'ios-simulator',
        'gclient_deps': 'ios',
        'gclient_env': {
            'GYP_DEFINES':
                'component=static_library OS=ios chromium_ios_signing=0',
            'GYP_GENERATOR_FLAGS': 'xcode_project_version=3.2',
        },
    })

f_chromium_rel_ios_device = ios().ChromiumFactory(
    # TODO(lliabraa): Need to upstream support for running tests on devices
    # before we can actually run any tests.
    tests=[],
    options = [
        '--', '-project', '../build/all.xcodeproj', '-sdk',
        'iphoneos6.1', '-target' , 'All'],
    factory_properties={
        'app_name': 'Chromium.app',
        'gclient_deps': 'ios',
        'gclient_env': {
            'GYP_DEFINES':
                'component=static_library OS=ios chromium_ios_signing=0',
            'GYP_GENERATOR_FLAGS': 'xcode_project_version=3.2',
        },
    })

f_chromium_linux_goma_canary = linux().ChromiumFactory(
    slave_type='BuilderTester',
    target='Release',
    options=['--compiler=goma'],
    factory_properties={
      'goma_canary': True,
      'slave_internal_url': config.Master.slave_internal_url,
    },
    tests=['diagnose_goma'])

f_chromium_linux_goma_linktest = linux().ChromiumFactory(
    slave_type='BuilderTester',
    target='Release',
    options=['--compiler=goma'],
    factory_properties={
      'goma_canary': True,
      'slave_internal_url': config.Master.slave_internal_url,
      'compile_env': {
        'GOMA_ENABLE_REMOTE_LINK': 'true',
        'GOMA_STORE_LOCAL_RUN_OUTPUT': 'true',
        # TODO(ukai): enable this not to use flock for link processes.
        # 'LINK': 'g++',
      },
    },
    tests=['diagnose_goma'])

f_chromium_mac_goma_canary = mac().ChromiumFactory(
    slave_type='BuilderTester',
    target='Release',
    options=[
      '--compiler=goma-clang',
    ],
    factory_properties={
      'goma_canary': True,
      'slave_internal_url': config.Master.slave_internal_url,
    },
    tests=['diagnose_goma'])

f_chromium_mac_ninja_goma_canary = mac().ChromiumFactory(
    slave_type='BuilderTester',
    target='Release',
    options=[
      '--build-tool=ninja',
      '--compiler=goma-clang',
    ],
    factory_properties={
      'goma_canary': True,
      'slave_internal_url': config.Master.slave_internal_url,
    },
    tests=['diagnose_goma'])

f_chromium_mac_108_x64_experimental = mac().ChromiumFactory(
    slave_type='Builder',
    target='Release',
    options=[
        # TODO(iannucci): Make this use goma.
        '--compiler=clang',
        '--', '-target', 'All', '-target', 'chromium_builder_tests'
    ],
    factory_properties={
        'archive_build': True,
        'build_url': chromium_mac_108_x64_experimental_archive,
        'gclient_env': {
            'GYP_DEFINES': 'host_arch=x64 target_arch=x64'
        },
        'gs_acl': 'public-read',
        'gs_bucket': 'gs://chromium-qa',
        'trigger': 'chromium_mac_108_x64_experimental',
    })

f_chromium_mac_108_x64_tester_experimental = mac().ChromiumFactory(
    build_url=chromium_mac_108_x64_experimental_archive,
    slave_type='Tester',
    target='Release',
    tests=[
      'base_unittests',
      'browser_tests',
      'cacheinvalidation_unittests',
      'cc_unittests',
      'chromedriver2_unittests',
      'components_unittests',
      'content_browsertests',
      'content_unittests',
      'crypto_unittests',
      'gpu_unittests',
      'interactive_ui_tests',
      'ipc_tests',
      'jingle_unittests',
      'media_unittests',
      'message_center_unittests',
      'net_unittests',
      'ppapi_unittests',
      'printing_unittests',
      'remoting_unittests',
      'sql_unittests',
      'sync_unit_tests',
      'ui_unittests',
      'unit_tests',
      'url_unittests',
      'webkit_compositor_bindings_unittests',
    ])

f_windows_8_app_certification = win().ChromiumFactory(
    tests=[],
    options=[],
    factory_properties={})

f_chromium_rel_win_memory_measurement = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['memory_measurement', 'reload_benchmark'],
    factory_properties={
        'show_perf_results': True,
        'expectations': True,
        'perf_id': 'chromium-rel-win7-dual-fyi',
        'process_dumps': True,
        'start_crash_handler': True,})


f_linux_arm_cross_compile = linux().ChromiumFactory(
    slave_type='Builder',
    target='Release',
    options=[
        '--build-tool=ninja', '--', 'chromium_builder_tests',
        # This is necessary for the archive_build step to work.
        'remoting_webapp',
    ],
    factory_properties={
        'archive_build': True,
        'build_url': chromium_linux_arm_archive,
        'trigger': 'chromium_linux_arm',
        'gs_bucket': 'gs://chromium-browser-snapshots',
        'gs_acl': 'public-read',
        'gclient_env': {
            'AR': 'arm-linux-gnueabi-ar',
            'AS': 'arm-linux-gnueabi-as',
            'CC': 'arm-linux-gnueabi-gcc',
            'CC_host': 'gcc',
            'CXX': 'arm-linux-gnueabi-g++',
            'CXX_host': 'g++',
            'GYP_DEFINES': 'target_arch=arm',
            'RANLIB': 'arm-linux-gnueabi-ranlib',
        },
    })

f_linux_arm_tests_panda = linux(nohooks_on_update=True).ChromiumFactory(
    slave_type='Tester',
    target='Release',
    build_url=chromium_linux_arm_archive,
    tests=[
      'base_unittests',
      'browser_tests',
      'cacheinvalidation_unittests',
      'cc_unittests',
      'chromedriver2_unittests',
      'components_unittests',
      'content_browsertests',
      'content_unittests',
      'crypto_unittests',
      'dbus',
      'device_unittests',
      'googleurl',
      'gpu',
      'interactive_ui_tests',
      'ipc_tests',
      'jingle',
      'media',
      'net',
      'ppapi_unittests',
      'printing',
      'remoting',
      'sandbox_linux_unittests',
      'ui_unittests',
      'unit_sql',
      'unit_sync',
      'unit_unit',
      'webkit_compositor_bindings_unittests',
    ])

f_chromiumos_linux_tests = linux().ChromiumFactory(
    slave_type='BuilderTester',
    target='Debug',
    tests=['sync_integration'],
    factory_properties={
      'test_results_server': 'test-results.appspot.com',
      'generate_gtest_json': True,
    })

# ----------------------------------------------------------------------------
# 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
#  slavename (required): which slave to use, must appear in c['slaves']
#  builddir (optional): 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_lin_perf = {'name': 'Chromium Linux Perf',
  'builddir': 'Chromium_Linux_Perf',
  'factory': f_linux_perf,
  'auto_reboot': False,
}

b_chromium_win_perf = {'name': 'Chromium Windows Perf',
  'builddir': 'Chromium_Windows_Perf',
  'factory': f_win_perf,
  'auto_reboot': False,
}

b_chromium_mac_perf = {'name': 'Chromium Mac Perf',
  'builddir': 'Chromium_Mac_Perf',
  'factory': f_mac_perf,
  'auto_reboot': False,
}

b_chromium_cros32_perf = {'name': 'Chromium Cros32 Perf',
  'builddir': 'Chromium_Cros32 Perf',
  'factory': f_cros32_perf,
  'auto_reboot': False,
}

b_chromium_cros64_perf = {'name': 'Chromium Cros64 Perf',
  'builddir': 'Chromium_Cros64 Perf',
  'factory': f_cros64_perf,
  'auto_reboot': False,
}

b_chromium_win_instantextended = {'name': 'Chromium Windows Instant Extended',
  'builddir': 'Chromium_Windows_Instant_Extended',
  'factory': f_win_instantextended,
  'auto_reboot': False,
}

b_chromium_lin_buildrunner = {'name': 'Chromium Linux Buildrunner',
  'builddir': 'Chromium_Linux_Buildrunner',
  'factory': f_linux_buildrunner,
  'auto_reboot': False,
}

b_chromium_win_buildrunner = {'name': 'Chromium Windows Buildrunner',
  'builddir': 'Chromium_Windows_Buildrunner',
  'factory': f_win_buildrunner,
  'auto_reboot': False,
}

b_chromium_mac_buildrunner = {'name': 'Chromium Mac Buildrunner',
  'builddir': 'Chromium_Mac_Buildrunner',
  'factory': f_mac_buildrunner,
  'slavebuilddir': 'mac_buildrunner_slave',
  'auto_reboot': False,
}

b_chromium_mac_10_8_buildrunner = {'name': 'Chromium Mac 10.8 Buildrunner',
  'builddir': 'Chromium_Mac_10_8_Buildrunner',
  'factory': f_mac_buildrunner,
  'auto_reboot': False,
}

b_chromium_rel_builder = {'name': 'Chromium Builder',
  'builddir': 'chromium-rel-builder',
  'factory': f_chromium_rel_builder,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_dbg_builder = {'name': 'Chromium Builder (dbg)',
  'builddir': 'chromium-dbg-builder',
  'factory': f_chromium_dbg_builder,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_rel_multiple_builder_tests = {
  'name': 'Chromium Win Multiple',
  'builddir': 'chromium-rel-multiple-builder',
  'factory': f_chromium_rel_multiple_builder_tests,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_delegate_builder = {'name': 'Win8 (delegate_execute)',
  'factory': f_chromium_rel_delegate,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_metro_builder = {'name': 'Win8 (metro_driver)',
  'factory': f_chromium_rel_metro,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_rel_perf_frame = {'name': 'Chrome Frame Perf',
  'builddir': 'chromium-rel-perf-frame',
  'factory': f_cr_rel_perf_frame,
  'category': 'windows',
}

b_chromium_dbg_vista_tests_1 = {
  'name': 'Vista Tests (dbg)(1)',
  'factory': f_chromium_dbg_tests_1,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_dbg_vista_tests_2 = {
  'name': 'Vista Tests (dbg)(2)',
  'factory': f_chromium_dbg_tests_2,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_rel_win8_tests_1 = {
  'name': 'Win8 Tests (1)',
  'factory': f_chromium_rel_tests_1,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_rel_win8_tests_2 = {
  'name': 'Win8 Tests (2)',
  'factory': f_chromium_rel_tests_2,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_linux_redux = {
  'name': 'Chromium Linux Redux',
  'factory': f_chromium_linux_redux,
  'category': 'linux',
  'auto_reboot': False,
}

b_chromium_dbg_ie8_frame = {
  'name': 'Chrome Frame Tests (ie8)(dbg)',
  'factory': f_cr_dbg_frame,
  'category': 'windows',
}

b_chromium_rel_ie6_peruser_frame = {
  'name': 'Chrome Frame Tests (ie6)(peruser)',
  'factory': f_cr_rel_frame,
  'category': 'windows',
}

b_chromium_rel_ie7_peruser_frame = {
  'name': 'Chrome Frame Tests (ie7)(peruser)',
  'factory': f_cr_rel_frame,
  'category': 'windows',
}

b_chromium_rel_ie8_peruser_frame = {
  'name': 'Chrome Frame Tests (ie8)(peruser)',
  'factory': f_cr_rel_frame,
  'category': 'windows',
}

b_chromium_rel_linux_tsan_v2 = {
  'name': 'Chromium Linux TSan v2',
  'builddir': 'chromium-rel-linux-tsan-v2',
  'factory': f_chromium_rel_linux_tsan_v2,
  'category': 'tsan',
  'auto_reboot': False,
}

b_chromium_rel_linux_lsan_asan = {
  'name': 'Chromium Linux LSan (and ASan)',
  'builddir': 'chromium-rel-linux-lsan-asan',
  'factory': f_chromium_rel_linux_lsan_asan,
  'category': 'lsan',
  'auto_reboot': False,
}

b_chromium_dbg_mac_106_tsan = {
  'name': 'Chromium Mac 10.6 (tsan)',
  'builddir': 'chromium-dbg-mac-106-tsan',
  'factory': f_cr_dbg_mac_106_tsan,
  'category': 'tsan',
  'auto_reboot': False,
}

b_chromium_dbg_win_drmemory_xp = {
  'name': 'Windows Tests (DrMemory XP)',
  'builddir': 'chromium-dbg-win-drmemory-xp',
  'factory': f_chromium_dbg_win_drmemory,
  'category': 'drmemory|memory_tester',
  'auto_reboot': False,
}

b_chromium_dbg_win_drmemory_full_1 = {
  'name': 'Windows Unit (DrMemory full) (1)',
  'builddir': 'chromium-dbg-win-drmemory-full-1',
  'factory': f_chromium_dbg_win_drmemory_full_1,
  'category': 'drmemory',
  'auto_reboot': False,
}

b_chromium_dbg_win_drmemory_full_2 = {
  'name': 'Windows Unit (DrMemory full) (2)',
  'builddir': 'chromium-dbg-win-drmemory-full-2',
  'factory': f_chromium_dbg_win_drmemory_full_2,
  'category': 'drmemory',
  'auto_reboot': False,
}

b_chromium_rel_win32_morenacl = {
  'name': 'More NaCl Tests (win32)',
  'builddir': 'chromium-rel-win32-morenacl',
  'factory': f_chromium_rel_win_morenacl,
  'category': 'morenacl',
  'auto_reboot': False,
}

b_chromium_rel_win64_morenacl = {
  'name': 'More NaCl Tests (win64)',
  'builddir': 'chromium-rel-win64-morenacl',
  'factory': f_chromium_rel_win_morenacl,
  'category': 'morenacl',
  'auto_reboot': False,
}

b_chromium_rel_mac_morenacl = {
  'name': 'More NaCl Tests (mac)',
  'builddir': 'chromium-rel-mac-morenacl',
  'factory': f_chromium_rel_mac_morenacl,
  'category': 'morenacl',
  'auto_reboot': False,
}

b_chromium_rel_linux_morenacl = {
  'name': 'More NaCl Tests (linux)',
  'builddir': 'chromium-rel-linux-morenacl',
  'factory': f_chromium_rel_linux_morenacl,
  'category': 'morenacl',
  'auto_reboot': False,
}

b_chromium_rel_linux_tsan_rv = {
  'name': 'Linux Tests (tsan RV)',
  'builddir': 'chromium-rel-linux-tsan-rv',
  'factory': f_chromium_rel_linux_tsan_rv,
  'category': 'tsan',
  'auto_reboot': False,
}

b_chromium_dbg_win_tsan = {
  'name': 'Windows Tests (TSan Win 7)',
  'builddir': 'chromium-dbg-win-tsan',
  'factory': f_chromium_dbg_win_tsan,
  'category': 'tsan',
  'auto_reboot': False,
}

b_coverage_dbg_linux = {
  'name': 'Linux Coverage (dbg)',
  'builddir': 'coverage-dbg-linux',
  'factory': f_coverage_dbg_linux,
  'category': 'coverage',
}

b_chromium_rel_vista_memory = {
  'name': 'Chromium Vista Memory',
  'builddir': 'chromium-rel-vista-memory',
  'factory': f_chromium_rel_vista_memory,
  'category': 'memory tests',
  'auto_reboot': False,
}

b_chromium_rel_linux_memory = {
  'name': 'Chromium Linux Memory',
  'builddir': 'chromium-rel-linux-memory',
  'factory': f_chromium_rel_linux_memory,
  'category': 'memory tests',
  'auto_reboot': False,
}

b_chromium_rel_mac_memory = {
  'name': 'Chromium Mac Memory',
  'builddir': 'chromium-rel-mac-memory',
  'factory': f_chromium_rel_mac_memory,
  'category': 'memory tests',
  'auto_reboot': False,
}

b_chromium_rel_linux_valgrind_reliability = {
  'name': 'Chromium Linux Reliability (valgrind)',
  'builddir': 'chromium-rel-linux-valgrind-reliability',
  'factory': f_chromium_rel_linux_valgrind_reliability,
  'category': 'valgrind',
  'auto_reboot': False,
}

b_chromium_win_ninja_goma = {
  'name': 'Chromium Win Ninja Goma',
  'factory': f_chromium_win_ninja_goma,
  'category': 'ninja',
  'auto_reboot': False,
}

b_chromium_win_ninja_goma_shared = {
  'name': 'Chromium Win Ninja Goma (shared)',
  'factory': f_chromium_win_ninja_goma_shared,
  'category': 'ninja',
  'auto_reboot': False,
}

b_chromium_win7_ninja_goma = {
  'name': 'Chromium Win7 Ninja Goma',
  'factory': f_chromium_win_ninja_goma,
  'category': 'ninja',
  'auto_reboot': False,
}

b_chromium_win7_ninja_goma_shared = {
  'name': 'Chromium Win7 Ninja Goma (shared)',
  'factory': f_chromium_win_ninja_goma_shared,
  'category': 'ninja',
  'auto_reboot': False,
}

b_chromium_win_x64 = {
  'name': 'Chromium Win x64 Clobber',
  'factory': f_chromium_win_x64,
  'category': 'windows',
  'auto_reboot': False,
}

b_chromium_win7_ninja_shared_vs2012_dbg = {
  'name': 'Chromium Win VS2012 (dbg)',
  'factory': f_chromium_win_ninja_shared_2012_dbg,
  'category': 'ninja',
  'auto_reboot': False,
}

b_chromium_win7_ninja_shared_vs2012 = {
  'name': 'Chromium Win VS2012',
  'factory': f_chromium_win_ninja_shared_2012,
  'category': 'ninja',
  'auto_reboot': False,
}

b_chromium_win_ninja_goma_shared_2012_dbg = {
  'name': 'Chromium Win VS2012 Goma (dbg)',
  'factory': f_chromium_win_ninja_goma_shared_2012_dbg,
  'category': 'ninja',
  'auto_reboot': False,
}

b_chromium_win_ninja_goma_shared_2012 = {
  'name': 'Chromium Win VS2012 Goma',
  'factory': f_chromium_win_ninja_goma_shared_2012,
  'category': 'ninja',
  'auto_reboot': False,
}

b_chromium_codesearch_scheduler = {
  'name': 'Chromium Codesearch Scheduler',
  'factory': f_chromium_codesearch_scheduler,
  'category': 'codesearch',
  'auto_reboot': False,
}

b_chromium_linux_codesearch = {
  'name': 'Chromium Linux Codesearch',
  'factory': f_chromium_codesearch_linux,
  'category': 'codesearch',
  'auto_reboot': False,
}

b_chromiumos_codesearch = {
  'name': 'ChromiumOS Codesearch',
  'factory': f_chromium_codesearch_chromiumos,
  'category': 'codesearch',
  'auto_reboot': False,
}

b_chromium_dbg_android_builder = {
  'name': 'Android Builder (dbg)',
  'factory': f_chromium_dbg_android_builder,
  'category': 'android',
}

b_chromium_dbg_android_x86_builder = {
  'name': 'Android x86 Builder (dbg)',
  'factory': f_chromium_dbg_android_x86_builder,
  'category': 'android',
}

b_chromium_rel_android_user_builder_tests = {
  'name': 'Android User Builder Tests',
  'factory': f_chromium_rel_android_builder_tests,
  'category': 'android',
}

b_chromium_dbg_android_tests_jb_gn = {
  'name': 'Android Tests (JB GalaxyNexus)(dbg)',
  'factory': f_chromium_dbg_android_tests('jb-gn'),
  'category': 'android',
}

b_chromium_dbg_android_tests_ics_gn = {
  'name': 'Android Tests (ICS GalaxyNexus)(dbg)',
  'factory': f_chromium_dbg_android_tests('ics-gn'),
  'category': 'android',
}

b_chromium_dbg_android_tests_jb_nexus7 = {
  'name': 'Android Tests (JB Nexus7)(dbg)',
  'factory': f_chromium_dbg_android_tests('jb-n7'),
  'category': 'android',
}

b_chromium_dbg_android_chromedriver_tests = {
  'name': 'Android ChromeDriver Tests (dbg)',
  'factory': f_chromium_dbg_android_chromedriver_tests,
  'category': 'android',
}

b_chromium_dbg_android_asan_builder_tests = {
  'name': 'Android Asan Builder Tests (dbg)',
  'factory': f_chromium_dbg_android_asan_builder_tests,
  'category': 'android',
}

b_chromium_dbg_android_shared_jb_nexus7 = {
  'name': 'Android Builder Tests (JB Nexus7)(shared)',
  'factory': f_chromium_dbg_android_shared,
  'category': 'android'
}

b_chromium_dbg_android_aosp_builder = {
  'name': 'Android AOSP Builder (dbg)',
  'factory': f_chromium_dbg_android_aosp_builder,
  'category': 'android',
}

b_chromium_dbg_ios_simulator = {
  'name': 'Chromium iOS Simulator (dbg)',
  'factory': f_chromium_dbg_ios_simulator,
  'category': 'ios',
  'auto_reboot': False,
}

b_chromium_rel_ios_device = {
  'name': 'Chromium iOS Device',
  'factory': f_chromium_rel_ios_device,
  'category': 'ios',
  'auto_reboot': False,
}

b_chromium_rel_linux_browser_valgrind_builder = {
  'name': 'Chromium Linux Browser Builder (valgrind)',
  'builddir': 'chromium-rel-linux-browser-valgrind-builder',
  'factory': f_chromium_rel_linux_browser_valgrind_builder,
  'category': 'valgrind',
  'auto_reboot': False,
}

b_chromium_windows_drmemory_builder = {
  'name': 'Windows Builder (DrMemory)',
  'builddir': 'drm-cr',
  'factory': f_chromium_windows_drmemory_builder,
  'category': 'drmemory',
  'auto_reboot': False,
}

b_chromium_linux_goma_canary = {
  'name': 'Chromium Linux Goma Canary',
  'factory': f_chromium_linux_goma_canary,
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_linux_precise_goma_linktest = {
  'name': 'Chromium Linux Precise Goma LinkTest',
  'factory': f_chromium_linux_goma_linktest,
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_linux32_goma_canary = {
  'name': 'Chromium Linux32 Goma Canary',
  'factory': f_chromium_linux_goma_canary,
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_mac_106_goma_canary = {
  'name': 'Chromium Mac 10.6 Goma Canary',
  'factory': f_chromium_mac_goma_canary,
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_mac_107_goma_canary = {
  'name': 'Chromium Mac 10.7 Goma Canary',
  'factory': f_chromium_mac_goma_canary,
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_mac_106_ninja_goma_canary = {
  'name': 'Chromium Mac 10.6 Ninja Goma Canary',
  'factory': f_chromium_mac_ninja_goma_canary,
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_mac_107_ninja_goma_canary = {
  'name': 'Chromium Mac 10.7 Ninja Goma Canary',
  'factory': f_chromium_mac_ninja_goma_canary,
  'category': 'goma',
  'auto_reboot': False,
}

b_chromium_mac_108_x64_experimental = {
  'name': 'Chromium Mac 10.8 x64 (experimental)',
  'factory': f_chromium_mac_108_x64_experimental,
  # 10.8 has a bug with not initializing correctly on reboot.
  'auto_reboot': False,
}

b_chromium_mac_108_x64_tester_experimental = {
  'name': 'Chromium Mac 10.8 x64 tester (experimental)',
  'factory': f_chromium_mac_108_x64_tester_experimental,
  # 10.8 has a bug with not initializing correctly on reboot.
  'auto_reboot': False,
}

b_windows_8_app_certification = {
  'name': 'Windows 8 App Certification',
  'factory': f_windows_8_app_certification,
  'category': 'windows',
}

b_chromium_rel_win_memory_measurement = {
  'name': 'Windows Tests (Memory benchmark)',
  'factory': f_chromium_rel_win_memory_measurement,
  'auto_reboot': False,
}

b_linux_arm_cross_compile = {
  'name': 'Linux ARM Cross-Compile',
  'factory': f_linux_arm_cross_compile,
  'category': 'linux',
  'auto_reboot': False,
}

b_linux_arm_tests_panda = {
  'name': 'Linux ARM Tests (Panda)',
  'factory': f_linux_arm_tests_panda,
  'category': 'linux',
  'auto_reboot': False,
}

b_chromiumos_linux_tests = {
  'name': 'ChromiumOS Linux Tests',
  'factory': f_chromiumos_linux_tests,
  'category': 'linux',
  'auto_reboot': False,
}


def linux_browser_valgrind_tester(shard, total):
  if shard < 1 or shard > total:
    raise
  ret = {'category': 'valgrind'}
  ret['name'] = 'Chromium Linux Browser (valgrind) (%d)' % shard
  ret['builddir'] = 'chromium-rel-linux-browser-valgrind-browser-%d' % shard
  ret['factory'] = linux().ChromiumFactory(
      target='Release',
      slave_type='Tester',
      build_url=chromium_linux_browser_valgrind_archive,
      tests=['valgrind_browser_tests_%d_of_%d' % (shard * 2 - 1, total * 2),
             'valgrind_browser_tests_%d_of_%d' % (shard * 2, total * 2),
             'valgrind_content_browsertests_%d_of_%d' % (shard, total)],
      options=['browser_tests'],
      factory_properties={ 'needs_valgrind' : True,
                           'retry_failed' : False,
                           'sharded_tests': sharded_tests})
  return ret

def windows_browser_drmemory_full_tester(shard, total):
  if shard < 1 or shard > total:
    raise
  ret = {'category': 'drmemory'}
  ret['name'] = 'Windows Browser (DrMemory full) (%d)' % shard
  ret['builddir'] = 'windows-browser-drm-full-%d' % shard
  ret['factory'] = win_out().ChromiumFactory(
      target='Debug',
      slave_type='Tester',
      build_url=chromium_windows_drmemory_archive,
      tests=['drmemory_full_browser_tests_%d_of_%d' % (shard, total)],
      options=['browser_tests'],
      factory_properties={ 'needs_drmemory' : True,
                           'retry_failed' : False })
  return ret

def windows_coverage(slave_type, total_shards, shard_index=None):
  processor_host = 'vm942-m1.golo.chromium.org'
  processor_www_dir = '\\\\' + processor_host + '\\www'
  upload_dir = '/home/chrome-bot/www/'
  coverage_tests = ['browser_tests', 'unit_tests']
  sharded_tests = ['browser_tests']
  dynamorio_build_url = 'http://build.chromium.org/p/client.dynamorio/builds'
  ret = {}
  if slave_type == 'Tester':
    ret['name'] = 'Win Coverage Tests (%d)' % shard_index
    ret['auto_reboot'] = True
    ret['factory'] = win_build().ChromiumFactory(
        clobber=True,
        target='Debug',
        slave_type='BuilderTester',
        project='all.sln;chromium_builder_tests',
        tests=['extract_dynamorio_build', 'coverage_tests'],
        factory_properties={'retry_failed' : False,
                            'halt_on_missing_build': True,
                            'tests': coverage_tests,
                            'sharded_tests': sharded_tests,
                            'browser_total_shards': total_shards,
                            'browser_shard_index': shard_index,
                            'host': processor_host,
                            'www-dir': processor_www_dir,
                            'test_platform': 'win',
                            'dynamorio_build_url': dynamorio_build_url,
                            'gclient_env': {
                                'GYP_DEFINES':
                                    'fastbuild=0 component=shared_library'}})
  elif slave_type == 'Processor':
    ret['name'] = 'Win Coverage Processor'
    ret['auto_reboot'] = True
    ret['factory'] = linux().ChromiumFactory(
        clobber=True,
        target='Debug',
        tests=['check_lkgr', 'trigger_coverage_tests', 'process_coverage'],
        slave_type='CoverageProcessor',
        factory_properties={'coverage_trigger': 'chromium_win_coverage',
                            'lkgr': True,
                            'test_platform': 'win',
                            'tests': coverage_tests,
                            'sharded_tests': sharded_tests,
                            'browser_total_shards': total_shards,
                            'show_perf_results': True,
                            'perf_id': 'chromium-dbg-win',
                            'upload-dir': upload_dir})
  return ret

c['builders'] = [
  # Windows release
  b_chromium_rel_builder,
  b_chromium_rel_perf_frame,
  b_chromium_rel_ie6_peruser_frame,
  b_chromium_rel_ie7_peruser_frame,
  b_chromium_rel_ie8_peruser_frame,
  b_chromium_dbg_ie8_frame,
  b_chromium_delegate_builder,
  b_chromium_metro_builder,
  b_chromium_rel_win8_tests_1,
  b_chromium_rel_win8_tests_2,
  b_chromium_win_ninja_goma,
  b_chromium_win_ninja_goma_shared,
  b_chromium_win7_ninja_goma,
  b_chromium_win7_ninja_goma_shared,
  b_chromium_win7_ninja_shared_vs2012_dbg,
  b_chromium_win7_ninja_shared_vs2012,
  b_chromium_win_ninja_goma_shared_2012_dbg,
  b_chromium_win_ninja_goma_shared_2012,
  b_windows_8_app_certification,
  b_chromium_win_x64,

  # Windows debug
  b_chromium_dbg_builder,
  b_chromium_dbg_vista_tests_1,
  b_chromium_dbg_vista_tests_2,

  # Windows multiple dll
  b_chromium_rel_multiple_builder_tests,

  # Mac BuilderTesters
  b_chromium_mac_106_goma_canary,
  b_chromium_mac_107_goma_canary,
  b_chromium_mac_106_ninja_goma_canary,
  b_chromium_mac_107_ninja_goma_canary,
  b_chromium_mac_108_x64_experimental,
  b_chromium_mac_108_x64_tester_experimental,

  # Perf Testers
  b_chromium_win_perf,
  b_chromium_lin_perf,
  b_chromium_mac_perf,
  b_chromium_cros32_perf,
  b_chromium_cros64_perf,

  # Instant Extended Testers
  b_chromium_win_instantextended,

  # Buildrunner Testers
  b_chromium_lin_buildrunner,
  b_chromium_win_buildrunner,
  b_chromium_mac_buildrunner,
  b_chromium_mac_10_8_buildrunner,

  # Linux BuilderTesters
  b_chromium_linux_redux,
  b_chromium_rel_linux_valgrind_reliability,
  b_chromium_linux_goma_canary,
  b_chromium_linux_precise_goma_linktest,
  b_chromium_linux32_goma_canary,
  b_chromiumos_linux_tests,

  # Linux ARM Cross Compile
  b_linux_arm_cross_compile,
  b_linux_arm_tests_panda,

  # Android
  b_chromium_dbg_android_builder,
  b_chromium_dbg_android_x86_builder,
  b_chromium_dbg_android_tests_jb_gn,
  b_chromium_dbg_android_tests_ics_gn,
  b_chromium_dbg_android_tests_jb_nexus7,
  b_chromium_rel_android_user_builder_tests,
  b_chromium_dbg_android_chromedriver_tests,
  b_chromium_dbg_android_asan_builder_tests,
  b_chromium_dbg_android_shared_jb_nexus7,

  # Android AOSP
  b_chromium_dbg_android_aosp_builder,

  # iOS
  b_chromium_dbg_ios_simulator,
  b_chromium_rel_ios_device,

  # TSAN
  b_chromium_dbg_win_tsan,
  b_chromium_dbg_mac_106_tsan,
  b_chromium_rel_linux_tsan_rv,
  b_chromium_rel_linux_tsan_v2,

  # LSan
  b_chromium_rel_linux_lsan_asan,

  # DrMemory
  b_chromium_dbg_win_drmemory_xp,
  b_chromium_dbg_win_drmemory_full_1,
  b_chromium_dbg_win_drmemory_full_2,

  # NaCl
  b_chromium_rel_win32_morenacl,
  b_chromium_rel_win64_morenacl,
  b_chromium_rel_mac_morenacl,
  b_chromium_rel_linux_morenacl,

  # Memory
  b_chromium_rel_vista_memory,
  b_chromium_rel_linux_memory,
  b_chromium_rel_mac_memory,
  b_chromium_rel_win_memory_measurement,

  # Coverage
  b_coverage_dbg_linux,

  # Codesearch
  b_chromium_codesearch_scheduler,
  b_chromium_linux_codesearch,
  b_chromiumos_codesearch,

]

c['builders'].append(b_chromium_rel_linux_browser_valgrind_builder)
LINUX_BROWSER_VALGRIND_TESTERS = 4
for i in range(LINUX_BROWSER_VALGRIND_TESTERS):
  c['builders'].append(
      linux_browser_valgrind_tester(i + 1, LINUX_BROWSER_VALGRIND_TESTERS))

c['builders'].append(b_chromium_windows_drmemory_builder)
WINDOWS_BROWSER_DRMEMORY_FULL_TESTERS = 4
for i in range(WINDOWS_BROWSER_DRMEMORY_FULL_TESTERS):
  c['builders'].append(
      windows_browser_drmemory_full_tester(
          i + 1, WINDOWS_BROWSER_DRMEMORY_FULL_TESTERS))

WINDOWS_COVERAGE_TESTERS = 5
c['builders'].append(windows_coverage('Processor', WINDOWS_COVERAGE_TESTERS))
for i in range(WINDOWS_COVERAGE_TESTERS):
  c['builders'].append(
      windows_coverage('Tester', WINDOWS_COVERAGE_TESTERS, i + 1))

master_gitzip_cfg.Update(config, ActiveMaster, c)
master_win_asan_cfg.Update(config, ActiveMaster, c)

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


####### BUILDSLAVES

# 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())

# Make sure everything works together.
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 STATUS_PUSH:
  from buildbot.status.status_push import HttpStatusPush
  c['status'].append(HttpStatusPush(
      'http://craebuild.appspot.com/status-listener'))

if CODESEARCH_NOTIFIER:
  categories_steps = {
    'codesearch': ['update_scripts', 'update', 'svnkill', 'package_source'],
  }
  c['status'].append(chromium_notifier.ChromiumNotifier(
      fromaddr=ActiveMaster.from_address,
      categories_steps=categories_steps,
      exclusions={},
      relayhost=config.Master.smtp,
      status_header='Codesearch alert on "%(builder)s":\n%(steps)s',
      subject='codesearch buildbot %(result)s in %(projectName)s on '
              '%(builder)s, revision %(revision)s',
      extraRecipients=['jochen@chromium.org', 'klimek@google.com'],
      lookup=master_utils.FilterDomain(),
      forgiving_steps=[],
      use_getname=True))

if DRMEMORY_NOTIFIER:
  categories_steps = {
    'memory_tester': [
      'memory test: googleurl',
      'memory test: printing',
      'memory test: media',
      'memory test: remoting',
      'memory test: sql',
      'memory test: sync',
      'memory test: sync_unit_tests',
      'memory test: ipc_tests',
      'memory test: base_unittests',
      'memory test: content',
      'memory test: crypto',
      'memory test: net',
      'memory test: ui_unittests',
      'memory test: unit',  # unit_tests can be sharded
      'memory test: unit_1',
      'memory test: unit_2',
   ],
  }
  c['status'].append(failures_notifier.FailuresNotifier(
      fromaddr=ActiveMaster.from_address,
      categories_steps=categories_steps,
      exclusions={},
      relayhost=config.Master.smtp,
      status_header='New DrMemory failure on "%(builder)s":\n%(steps)s',
      subject='drmemory buildbot %(result)s in %(projectName)s on '
              '%(builder)s, revision %(revision)s',
      sendToInterestedUsers=False,  # don't send e-mails to the committers.
      extraRecipients=[
          'bruening+drmfyifailure@google.com',
          'rnk+drmfyifailure@google.com',
          'zhaoqin+drmfyifailure@google.com',
      ],
      lookup=master_utils.FilterDomain(),
      forgiving_steps=[],
      use_getname=True))

c['status'].append(MailNotifier(
      fromaddr='ukai@chromium.org',  # Reply-To address
      mode='failing',
      categories=['goma'],
      relayhost=config.Master.smtp,
      subject='goma canary buildbot %(result)s in %(projectName)s '
              'on %(builder)s',
      extraRecipients=['goma+alert@google.com'],
      sendToInterestedUsers=False))


####### PROJECT IDENTITY

# Buildbot master url:
c['buildbotURL'] = 'http://build.chromium.org/p/chromium.fyi/'
