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

from buildbot.buildslave import BuildSlave
from buildbot.config import BuilderConfig
from buildbot.changes.gitpoller import GitPoller
from buildbot.changes.svnpoller import SVNPoller
from buildbot.changes.svnpoller import split_file_alwaystrunk
from buildbot.schedulers.basic import SingleBranchScheduler
from buildbot.schedulers.forcesched import ForceScheduler
from buildbot.schedulers.trysched import Try_Userpass
from buildbot.changes import filter

# This is a sample buildmaster config file. It must be installed as
# 'master.cfg' in your buildmaster's base directory.

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

####### BUILDSLAVES

import os

# The 'slaves' list defines the set of recognized buildslaves. Each element is
# a BuildSlave object, specifying a unique slave name and password.  The same
# slave name and password must be configured on the slave.

password = open('halide_bb_pass.txt').read()

slaves = []
slave_suffixes = ['-1', '-2', '-3', '-4', '-5', '-6']
for sfx in slave_suffixes:
    slaves.append(BuildSlave('linux-slave' + sfx,     password, max_builds = 2))
    slaves.append(BuildSlave('mac-slave' + sfx,       password, max_builds = 2))
    slaves.append(BuildSlave('arm32-linux-slave' + sfx, password, max_builds = 1))
    slaves.append(BuildSlave('arm64-linux-slave' + sfx, password, max_builds = 1))
    slaves.append(BuildSlave('win-slave' + sfx,       password, max_builds = 1))
    slaves.append(BuildSlave('mingw64-slave' + sfx,     password, max_builds = 1))

c['slaves'] = slaves

# 'protocols' contains information about protocols which master will use for
# communicating with slaves.
# You must define at least 'port' option that slaves could connect to your master
# with this protocol.
# 'port' must match the value configured into the buildslaves (with their
# --master option)
c['protocols'] = {'pb': {'port': 9989}}

####### LOCKS

# Performance testing requires exclusive use of a slave
from buildbot.plugins import util

# Compute-intensive build steps will grab this lock in reader
# mode. The performance test will grab it in exclusive mode.
performance_lock = util.SlaveLock("performance_lock",
                                  maxCount = 9999)

####### CHANGESOURCES

# the 'change_source' setting tells the buildmaster how it should find out
# about source code changes.  Here we point to the buildbot clone of halide.


c['change_source'] = []

c['change_source'].append(GitPoller(
        'git://github.com/Halide/halide.git',
        workdir = 'gitpoller-workdir',
        branch = 'master',
        pollinterval = 60*5)) # Check Halide repo every five minutes

c['change_source'].append(SVNPoller(
        svnurl = 'http://llvm.org/svn/llvm-project/llvm/trunk',
        split_file = split_file_alwaystrunk,
        pollinterval = 60*60*4, # Only check llvm once every four hours
        pollAtLaunch = True))

c['change_source'].append(SVNPoller(
        svnurl = 'http://llvm.org/svn/llvm-project/cfe/trunk',
        split_file = split_file_alwaystrunk,
        pollinterval = 60*60*4, # Only check llvm once every four hours
        pollAtLaunch = True))

####### CODEBASES

all_repositories = {
    r'git://github.com/Halide/halide.git' : 'halide',
    r'http://llvm.org/svn/llvm-project/llvm/trunk' : 'llvm-trunk',
    r'http://llvm.org/svn/llvm-project/cfe/trunk' : 'clang-trunk',
    r'http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_391/final' : 'llvm-391',
    r'http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_391/final' : 'clang-391',
    r'http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_381/final' : 'llvm-381',
    r'http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_381/final' : 'clang-381',
    r'http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_371/final' : 'llvm-371',
    r'http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_371/final' : 'clang-371',
}

def codebase_generator(chdict):
    print 'codebase_generator chdict=%s' % chdict
    return all_repositories[chdict['repository']]

c['codebaseGenerator'] = codebase_generator

####### BUILDERS

# The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
# what steps, and which slaves can execute them.  Note that any particular build will
# only take place on one slave.

from buildbot.process.factory import BuildFactory
from buildbot.steps.source.git import Git
from buildbot.steps.source.svn import SVN
from buildbot.steps.shell import ShellCommand
from buildbot.steps.slave import RemoveDirectory
from buildbot.steps.transfer import FileUpload
from buildbot.steps.slave import MakeDirectory
from buildbot.steps.master import MasterShellCommand
from buildbot.process.properties import Property
from buildbot.process.properties import renderer
from buildbot.process.properties import Interpolate

def add_get_source_steps(factory, llvm):

  llvm_codebase  = 'llvm-' + llvm
  clang_codebase = 'clang-' + llvm
  if llvm == 'trunk':
    llvm_svn_path = 'trunk'
  else:
    llvm_svn_path = 'tags/RELEASE_' + llvm + '/final'

  factory.addStep(Git(name = 'Get Halide master',
                      locks = [performance_lock.access('counting')],
                      codebase = 'halide',
                      workdir = 'halide',
                      repourl = 'git://github.com/Halide/halide.git',
                      mode = 'incremental'))

  factory.addStep(ShellCommand(name = 'svn cleanup',
                               locks = [performance_lock.access('counting')],
                               flunkOnFailure = False,
                               workdir = 'llvm',
                               command = ['svn', 'cleanup']))

  factory.addStep(ShellCommand(name = 'svn cleanup',
                               locks = [performance_lock.access('counting')],
                               flunkOnFailure = False,
                               workdir = 'llvm/tools/clang',
                               command = ['svn', 'cleanup']))

  factory.addStep(SVN(name = 'Get LLVM source',
                      locks = [performance_lock.access('counting')],
                      codebase = llvm_codebase,
                      workdir = 'llvm',
                      repourl = r'http://llvm.org/svn/llvm-project/llvm/%s' % llvm_svn_path,
                      mode = 'incremental'))

  factory.addStep(SVN(name = 'Get Clang source',
                      locks = [performance_lock.access('counting')],
                      codebase = clang_codebase,
                      workdir = 'llvm/tools/clang',
                      repourl = r'http://llvm.org/svn/llvm-project/cfe/%s' % llvm_svn_path,
                      mode = 'incremental'))

@renderer
def get_distrib_name(props):
  rev = props.getProperty('got_revision')['halide']
  builder = props.getProperty('buildername')
  if builder.startswith('win'): suffix = '.zip'
  else: suffix = '.tgz'
  return '~/artifacts/halide-' + builder + '-' + rev + suffix

def get_llvm_cmake_command(os):
  llvm_cmake_command = [
    'cmake',
    '-DCMAKE_INSTALL_PREFIX=../llvm-install',
    '-DLLVM_ENABLE_TERMINFO=OFF',
    '-DLLVM_TARGETS_TO_BUILD=X86;ARM;NVPTX;AArch64;Mips;Hexagon;PowerPC',
    '-DCMAKE_BUILD_TYPE=Release']
  if '-32' in os:
    llvm_cmake_command.append('-DLLVM_BUILD_32_BITS=ON')
  else:
    llvm_cmake_command.append('-DLLVM_BUILD_32_BITS=OFF')

  llvm_cmake_command.append('../llvm/')

  if os.startswith('linux-32'):
    llvm_cmake_command.append('-DCMAKE_FIND_ROOT_PATH=/usr/lib/i386-linux-gnu')
    llvm_cmake_command.append('-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY')

  if os.startswith('mac-32'):
    llvm_cmake_command.append('-DCMAKE_FIND_ROOT_PATH=/usr/lib')
    llvm_cmake_command.append('-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY')

  if os.startswith('mingw'):
    llvm_cmake_command.append('-G')
    llvm_cmake_command.append('MSYS Makefiles')
    # mingw gcc 5.2 doesn't compile llvm correctly with assertions on
    llvm_cmake_command.append('-DLLVM_ENABLE_ASSERTIONS=OFF')
  else:
    llvm_cmake_command.append('-DLLVM_ENABLE_ASSERTIONS=ON')


  return llvm_cmake_command

def get_env(os):
  env = {'LLVM_CONFIG': '../llvm-build/bin/llvm-config',
         'CLANG': '../llvm-build/bin/clang'}

  cxx = 'c++'
  cc = 'cc'
  ld = 'ld'

  if os.startswith('linux'):
    if os.endswith('48'):
      cc = 'gcc-4.8'
      cxx = 'g++-4.8'
    elif os.endswith('49'):
      cc = 'gcc-4.9'
      cxx = 'g++-4.9'
    elif os.endswith('51'):
      cc = 'gcc-5.1'
      cxx = 'g++-5.1'
    elif os.endswith('52'):
      cc = 'gcc-5.2'
      cxx = 'g++-5.2'
    elif os.endswith('53'):
      cc = 'gcc-5.3'
      cxx = 'g++-5.3'
    else:
      assert(False)

    ld = 'ld'
    if '-32' in os:
      cxx += ' -m32'
      cc += ' -m32'
      ld += ' -melf_i386'
  elif os.startswith('mac'):
    if '-32' in os:
      cxx += ' -m32'
      cc += ' -m32'

  env['CXX'] = cxx
  env['CC'] = cc
  env['LD'] = ld

  if os == 'linux-64-gcc49':
      # Environment variables for testing Hexagon DSP
      env['HL_HEXAGON_TOOLS'] = '/usr/local/hexagon'
      env['HL_HEXAGON_SIM_REMOTE'] = '${PWD}/slave/' + os + '-trunk/halide/src/runtime/hexagon_remote/bin/v60/hexagon_sim_remote'
      env['HL_HEXAGON_SIM_CYCLES'] = '1'

  return env

def get_make_threads(os):
  if os.startswith('linux'):
    return 16
  elif os.startswith('mac'):
    return 4
  elif os.startswith('arm64'):
    return 4
  elif os.startswith('mingw'):
    return 4
  else:
    return 1

def get_targets(os, llvm):
  targets = [('distrib', 'host'),
             ('build_tests', 'host'),
             ('test_correctness', 'host'),
             ('test_performance', 'host'),
             ('test_generators', 'host')]

  if '-32' in os and 'arm' not in os and 'mingw' not in os:
    # Also test without sse 4.1
    targets.append(('test_correctness', 'x86-32'))

  if '-64' in os and 'arm' not in os and 'gcc48' not in os and 'gcc5' not in os:
    if 'mingw' not in os:
      targets.extend([('test_correctness', 'x86-64'),
                      ('test_correctness', 'x86-64-sse41')])

    targets.extend([('test_apps', 'host'),
                    ('test_tutorials', 'host'),
                    ('test_correctness', 'host-opencl'),
                    ('test_generators', 'host-opencl'),
                    ('test_apps', 'host-opencl')])

    if 'gcc5' not in os and 'mingw' not in os:
      targets.append(('test_python', 'host'))

    if os.startswith('linux-64') or os.startswith('mingw64'):
      # The linux build-bot has an nvidia card
      targets.extend([('test_correctness', 'host-cuda'),
                      ('test_generators', 'host-cuda'),
                      ('test_apps', 'host-cuda')])

  if os == 'linux-64-gcc49' and llvm == 'trunk':
    # Also test hexagon using the simulator
    for t in ['host-hvx_128', 'host-hvx_64']:
      targets.extend([('test_correctness', t),
                      ('test_generators', t),
                      ('test_apps', t)])

  return targets

def get_slaves(os):
  if os.startswith('linux'):
    return ['linux-slave' + sfx for sfx in slave_suffixes]
  elif os.startswith('mac'):
    return ['mac-slave' + sfx for sfx in slave_suffixes]
  elif os.startswith('win'):
    return ['win-slave' + sfx for sfx in slave_suffixes]
  elif os.startswith('arm32-linux'):
    return ['arm32-linux-slave' + sfx for sfx in slave_suffixes]
  elif os.startswith('arm64-linux'):
    return ['arm64-linux-slave' + sfx for sfx in slave_suffixes]
  elif os.startswith('mingw64'):
    return ['mingw64-slave' + sfx for sfx in slave_suffixes]

def create_factory(os, llvm):

  if os.startswith('win'): return create_win_factory(os, llvm)

  llvm_cmake_command = get_llvm_cmake_command(os)
  env           = get_env(os)
  targets       = get_targets(os, llvm)
  make_threads  = get_make_threads(os)

  factory = BuildFactory()
  add_get_source_steps(factory, llvm)

  factory.addStep(ShellCommand(name = 'Configure LLVM',
                               description = 'Configure LLVM',
                               locks = [performance_lock.access('counting')],
                               workdir = 'llvm-build',
                               env = env,
                               command = llvm_cmake_command))
  factory.addStep(ShellCommand(name = 'Build LLVM',
                               description = 'Build LLVM',
                               locks = [performance_lock.access('counting')],
                               workdir = 'llvm-build',
                               env = env,
                               command = ['make', '-j%s' % make_threads]))

  # Force a full rebuild of Halide every time
  factory.addStep(RemoveDirectory(dir='halide-build'))

  for (target, hl_target) in targets:
    target_env = env.copy()
    target_env['HL_TARGET'] = hl_target
    target_env['HL_JIT_TARGET'] = hl_target
    p = make_threads
    lock_mode = 'counting'
    if target == 'test_performance' or target == 'test_tutorials':
      p = 1
      lock_mode = 'exclusive'
    factory.addStep(ShellCommand(name = 'make ' + target,
                                 description = target + ' ' + hl_target,
                                 locks = [performance_lock.access(lock_mode)],
                                 workdir = 'halide-build',
                                 env = target_env,
                                 command = ['make', '-f', '../halide/Makefile', '-j%s' % p, target],
                                 timeout = 3600))
    if target == 'distrib':
      factory.addStep(
        FileUpload(slavesrc = 'distrib/halide.tgz',
                   workdir = 'halide-build',
                   mode = 0644,
                   masterdest = get_distrib_name))

      factory.addStep(MasterShellCommand(
        path = '/home/abadams/artifacts',
        command = ['bash', '/home/abadams/build_bot/clean_artifacts.sh']))

  return factory

def create_win_factory(os, llvm):
  assert os.startswith('win')

  factory = BuildFactory()
  add_get_source_steps(factory, llvm)

  if llvm == 'trunk':
    llvm_version = '50'
  else:
    llvm_version = llvm[0:2]

  # Configure llvm
  if '-32' in os:
    build_32_bits = 'ON'
    project_type = 'Visual Studio 14'
  else:
    assert '-64' in os
    build_32_bits = 'OFF'
    project_type = 'Visual Studio 14 Win64'

  # Build llvm and Halide in release and debug modes
  for config in ['Release', 'Debug']:

    #factory.addStep(RemoveDirectory(dir = 'halide-build-' + config, haltOnFailure = False))
    factory.addStep(MakeDirectory(dir = 'halide-build-' + config, haltOnFailure = False))

    #factory.addStep(RemoveDirectory(dir = 'llvm-build-' + config, haltOnFailure = False))
    factory.addStep(MakeDirectory(dir = 'llvm-build-' + config, haltOnFailure = False))

    #factory.addStep(RemoveDirectory(dir = 'llvm-install-' + config, haltOnFailure = False))
    factory.addStep(MakeDirectory(dir = 'llvm-install-' + config, haltOnFailure = False))

    factory.addStep(
      ShellCommand(name = 'Configure LLVM',
                   description = 'Configure LLVM',
                   locks = [performance_lock.access('counting')],
                   workdir = 'llvm-build-' + config,
                   command = ['cmake',
                              '-DCMAKE_INSTALL_PREFIX=../llvm-install-' + config,
                              '-DLLVM_ENABLE_TERMINFO=OFF',
                              '-DLLVM_TARGETS_TO_BUILD=X86;ARM;NVPTX;AArch64;Mips;Hexagon;PowerPC',
                              '-DLLVM_ENABLE_ASSERTIONS=ON',
                              '-DLLVM_BUILD_32_BITS=' + build_32_bits,
                              '-DCMAKE_BUILD_TYPE=' + config,
                              '../llvm/',
                              '-G',
                              project_type]))

    factory.addStep(
      ShellCommand(workdir = 'llvm-build-' + config,
                   locks = [performance_lock.access('counting')],
                   name = 'Build LLVM ' + config,
                   description = 'Build LLVM ' + config,
                   command = ['MSBuild.exe',
                              '/m:4', # Using all cores requires >32GB of ram when linking debug llvm
                              '/t:Build',
                              '/p:Configuration=' + config,
                              '.\\INSTALL.vcxproj']))

    factory.addStep(
      ShellCommand(name = 'Configure Halide ' + config,
                   description = 'Configure Halide ' + config,
                   locks = [performance_lock.access('counting')],
                   workdir = 'halide-build-' + config,
                   command = ['cmake',
                               Interpolate('-DLLVM_DIR=%(prop:workdir)s\\llvm-install-' + config + '\\lib\\cmake\\llvm'),
                               '-DLLVM_VERSION=' + llvm_version,
                               '-DCMAKE_BUILD_TYPE=' + config,
                               '-G',
                               project_type,
                               '..\\halide']))
    factory.addStep(
      ShellCommand(name = 'Build Halide ' + config,
                   description = 'Build Halide ' + config,
                   locks = [performance_lock.access('counting')],
                   workdir = 'halide-build-' + config,
                   command = ['MSBuild.exe',
                              '/m',
                              '/t:Build',
                              '/p:Configuration=' + config,
                              '.\\ALL_BUILD.vcxproj']))


  # Make and upload a distro
  factory.addStep(RemoveDirectory(dir = 'distrib', haltOnFailure = False))
  factory.addStep(MakeDirectory(dir = 'distrib', haltOnFailure = False))
  factory.addStep(MakeDirectory(dir = 'distrib\\halide', haltOnFailure = False))
  for d in ['Release', 'Debug', 'include', 'tools']:
    factory.addStep(MakeDirectory(dir = 'distrib\\halide\\' + d, haltOnFailure = False))

  file_pairs = [
    ('..\\halide-build-Release\\bin\\Release\\Halide.dll', 'Release'),
    ('..\\halide-build-Release\\lib\\Release\\Halide.lib', 'Release'),
    ('..\\halide-build-Debug\\bin\\Debug\\Halide.dll', 'Debug'),
    ('..\\halide-build-Debug\\lib\\Debug\\Halide.lib', 'Debug'),
    ('..\\halide-build-Release\\include\\Halide.h', 'include'),
    ('..\\halide\\src\\runtime\\HalideRuntim*.h', 'include'),
    ('..\\halide\\src\\runtime\\HalideBuffer.h', 'include'),
    ('..\\halide\\tools\\mex_halide.m', 'tools'),
    ('..\\halide\\tools\\halide_image_io.h', 'tools'),
    ('..\\halide\\tools\\GenGen.cpp', 'tools'),
    ('..\\halide\\README.md', '.')]
  for (file, dir) in file_pairs:
    factory.addStep(
      ShellCommand(name = 'Copying ' + file,
                   workdir = 'distrib',
                   command = ['copy', file, 'halide\\' + dir + '\\']))

  factory.addStep(
    ShellCommand(name = 'Zipping distribution',
                 workdir = 'distrib',
                 command = ['C:\\Program Files\\7-Zip\\7z.exe',
                            'a',
                            'halide.zip',
                            'halide']))

  factory.addStep(
    FileUpload(slavesrc = 'halide.zip',
               workdir = 'distrib',
               mode = 0644,
               masterdest = get_distrib_name))

  # Run the tests
  env = {}
  for hl_target in ['host', 'host-opencl', 'host-cuda']:
    target_env = env.copy()
    target_env['HL_TARGET'] = hl_target
    target_env['HL_JIT_TARGET'] = hl_target
    factory.addStep(
      ShellCommand(name = 'correctness',
                   description = 'correctness',
                   locks = [performance_lock.access('counting')],
                   workdir = 'halide-build-Release',
                   env = target_env,
                   timeout = 3600,
                   command = ['cmd', '/c',
                              'for', '%i', 'in', '(bin\\Release\\correctness*.exe)', 'do', '(%i)']))
    factory.addStep(
      ShellCommand(name = 'performance',
                   description = 'performance',
                   locks = [performance_lock.access('exclusive')],
                   workdir = 'halide-build-Release',
                   env = target_env,
                   timeout = 3600,
                   command = ['cmd', '/c',
                              'for', '%i', 'in', '(bin\\Release\\performance*.exe)', 'do', '(%i)']))
    factory.addStep(
      ShellCommand(name = 'generators',
                   description = 'generators',
                   locks = [performance_lock.access('counting')],
                   workdir = 'halide-build-Release',
                   env = target_env,
                   timeout = 3600,
                   command = ['cmd', '/c',
                              'for', '%i', 'in', '(bin\\Release\\generator*.exe)', 'do', '(%i)']))

  return factory


def create_builder(os, llvm):
  factory = create_factory(os, llvm)

  builder = BuilderConfig(name = os + '-' + llvm,
                          slavenames = get_slaves(os),
                          factory = factory,
                          tags = ['os-' + os, 'llvm-' + llvm])

  builder.llvm = llvm
  builder.os = os

  c['builders'].append(builder)

def create_scheduler(llvm):

  oses = [b.os for b in c['builders'] if b.llvm == llvm]

  scheduler = SingleBranchScheduler(
    name = 'halide-' + llvm,
    codebases = {'halide': {'repository':''},
                 'llvm-' + llvm: {'repository':''},
                 'clang-' + llvm: {'repository':''}},
                 change_filter = filter.ChangeFilter(),
                 treeStableTimer = 10, # seconds
                 builderNames = [b.name for b in c['builders'] if b.llvm == llvm])

  c['schedulers'].append(scheduler)

  scheduler = ForceScheduler(
    name = 'force-' + llvm,
    builderNames = [b.name for b in c['builders'] if b.llvm == llvm],
    codebases = {'halide': {'repository':''},
                 'llvm-' + llvm: {'repository':''},
                 'clang-' + llvm: {'repository':''}})

  c['schedulers'].append(scheduler)

c['builders'] = []
create_builder('arm32-linux-32', 'trunk')
create_builder('arm64-linux-64', 'trunk')
for gcc in ['gcc48', 'gcc49', 'gcc51', 'gcc52', 'gcc53']:
    create_builder('linux-32-' + gcc, 'trunk')
    create_builder('linux-64-' + gcc, 'trunk')

create_builder('linux-32-gcc49', '391')
create_builder('linux-32-gcc49', '381')
create_builder('linux-32-gcc49', '371')
create_builder('linux-64-gcc49', '391')
create_builder('linux-64-gcc49', '381')
create_builder('linux-64-gcc49', '371')

create_builder('mac-32', 'trunk')
create_builder('mac-32', '391')
create_builder('mac-32', '381')
create_builder('mac-32', '371')
create_builder('mac-64', 'trunk')
create_builder('mac-64', '391')
create_builder('mac-64', '381')
create_builder('mac-64', '371')
create_builder('win-32', 'trunk')
create_builder('win-64', 'trunk')
create_builder('mingw64-64', 'trunk')

c['schedulers'] = []
create_scheduler('trunk')
create_scheduler('371')
create_scheduler('381')
create_scheduler('391')

# Set the builder priorities
def prioritize_builders(master, builders):
  def importance(builder):
    # gccs other than 4.9 are just for making distros. They don't need
    # frequent testing.
    if 'gcc' in builder.name and 'gcc49' not in builder.name: return 6
    # 32-bit is also less important than getting immediate feedback on 64-bit.
    if '-32' in builder.name: return 5
    # Order llvm versions by age
    if '371' in builder.name: return 4
    if '381' in builder.name: return 3
    if '391' in builder.name: return 2
    # These builders are the highest priority
    if builder.name in ['mac-64-trunk']: return 0
    return 1

  builders.sort(key = importance)

  return builders

c['prioritizeBuilders'] = prioritize_builders

####### STATUS TARGETS

# 'status' is a list of Status Targets. The results of each build will be
# pushed to these targets. buildbot/status/*.py has a variety to choose from,
# including web pages, email senders, and IRC bots.

c['status'] = []

from buildbot.status import html
from buildbot.status.web import authz, auth
from os.path import expanduser

authz_cfg = authz.Authz(
    # change any of these to True to enable; see the manual for more
    # options
    auth=auth.HTPasswdAprAuth(expanduser('~') + '/.htpasswd-halide'),
    gracefulShutdown = False,
    forceBuild = 'auth', # use this to test your slave once it is set up
    forceAllBuilds = 'auth',  # ..or this
    pingBuilder = True,
    stopBuild = True,
    stopAllBuilds = True,
    cancelPendingBuild = True,
)
c['status'].append(html.WebStatus(http_port = 8010,
                                  authz = authz_cfg,
                                  order_console_by_time = True))

####### PROJECT IDENTITY

# the 'title' string will appear at the top of this buildbot
# installation's html.WebStatus home page (linked to the
# 'titleURL') and is embedded in the title of the waterfall HTML page.

c['title'] = 'Halide'
c['titleURL'] = 'http://halide-lang.org'

# the 'buildbotURL' string should point to the location where the buildbot's
# internal web server (usually the html.WebStatus 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://104.154.46.123/'

####### DB URL

c['db'] = {
    # This specifies what database buildbot uses to store its state.  You can leave
    # this at its default for all but the largest installations.
    'db_url' : 'sqlite:///state.sqlite',
}
