# 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 master import master_config
from master.factory import chromium_factory

import config

ActiveMaster = config.Master.ChromiumWebkit

defaults = {}

helper = master_config.Helper(defaults)
B = helper.Builder
F = helper.Factory
S = helper.Scheduler
T = helper.Triggerable

def win(): return chromium_factory.ChromiumFactory('src/build', 'win32')

defaults['category'] = '4webkit win latest'

webkit_tests = [
  'test_shell',
  'webkit',
  'webkit_lint',
  'webkit_unit',
]

################################################################################
## Release
################################################################################

# Archive location
rel_archive = master_config.GetArchiveUrl('ChromiumWebkit',
                                          'WebKit Win Builder',
                                          'webkit-win-latest-rel', 'win32')
#
# Main release scheduler for webkit
#
S('s4_webkit_rel', branch='trunk', treeStableTimer=60)

#
# Triggerable scheduler for testers
#
T('s4_webkit_rel_trigger')

#
# Win Rel Builder
#
B('WebKit Win Builder', 'f_webkit_win_rel', gatekeeper='compile',
  scheduler='s4_webkit_rel', builddir='webkit-win-latest-rel',
  auto_reboot=False)
F('f_webkit_win_rel', win().ChromiumFactory(
    slave_type='Builder',
    project='all.sln;webkit_builder_win',
    factory_properties={
        'trigger': 's4_webkit_rel_trigger',
        'blink_config': 'blink',
    }))

#
# Win Rel WebKit testers
#
B('WebKit XP', 'f_webkit_rel_tests', scheduler='s4_webkit_rel_trigger')
F('f_webkit_rel_tests', win().ChromiumFactory(
    slave_type='Tester',
    build_url=rel_archive,
    tests=webkit_tests,
    factory_properties={
        'archive_webkit_results': ActiveMaster.is_production_host,
        'generate_gtest_json': True,
        'test_results_server': 'test-results.appspot.com',
        'blink_config': 'blink',
    }))

B('WebKit Win7', 'f_webkit_rel_tests', scheduler='s4_webkit_rel_trigger')

################################################################################
## Debug
################################################################################

# Archive location
dbg_archive = master_config.GetArchiveUrl('ChromiumWebkit',
                                          'WebKit Win Builder (dbg)',
                                          'webkit-win-latest-dbg', 'win32')
#
# Main debug scheduler for webkit
#
S('s4_webkit_dbg', branch='trunk', treeStableTimer=60)

#
# Triggerable scheduler for testers
#
T('s4_webkit_dbg_trigger')

#
# Win Dbg Builder
#
B('WebKit Win Builder (dbg)', 'f_webkit_win_dbg', scheduler='s4_webkit_dbg',
  builddir='webkit-win-latest-dbg', auto_reboot=False)
F('f_webkit_win_dbg', win().ChromiumFactory(
    target='Debug',
    slave_type='Builder',
    project='all.sln;webkit_builder_win',
    factory_properties={
        'trigger': 's4_webkit_dbg_trigger',
        'blink_config': 'blink',
    }))

#
# Win Dbg WebKit testers
#

B('WebKit Win7 (dbg)(1)', 'f_webkit_dbg_tests_1',
    scheduler='s4_webkit_dbg_trigger')
F('f_webkit_dbg_tests_1', win().ChromiumFactory(
    target='Debug',
    slave_type='Tester',
    build_url=dbg_archive,
    tests=webkit_tests,
    factory_properties={
        'archive_webkit_results': ActiveMaster.is_production_host,
        'generate_gtest_json': True,
        'layout_part': '1:2',
        'test_results_server': 'test-results.appspot.com',
        'blink_config': 'blink',
    }))

B('WebKit Win7 (dbg)(2)', 'f_webkit_dbg_tests_2',
    scheduler='s4_webkit_dbg_trigger')
F('f_webkit_dbg_tests_2', win().ChromiumFactory(
    target='Debug',
    slave_type='Tester',
    build_url=dbg_archive,
    tests=['webkit'],
    factory_properties={
        'archive_webkit_results': ActiveMaster.is_production_host,
        'layout_part': '2:2',
        'test_results_server': 'test-results.appspot.com',
        'blink_config': 'blink',
    }))

def Update(_config, active_master, c):
  return helper.Update(c)

@@ -492,21 +492,19 @@
 ry('src/
-build
+out
 ', 'win3
@@ -1439,33 +1439,48 @@
 r',%0A    
-project='all.sln;
+options=%5B'--build-tool=ninja', '
 webkit_b
@@ -1482,32 +1482,33 @@
 kit_builder_win'
+%5D
 ,%0A    factory_pr
@@ -1587,32 +1587,106 @@
 nfig': 'blink',%0A
+        'gclient_env': %7B%0A            'GYP_GENERATORS':'ninja',%0A        %7D,%0A
     %7D))%0A%0A#%0A# Win
@@ -3019,25 +3019,40 @@
     
-project='all.sln;
+options=%5B'--build-tool=ninja', '
 webk
@@ -3066,16 +3066,17 @@
 der_win'
+%5D
 ,%0A    fa
@@ -3130,32 +3130,32 @@
 t_dbg_trigger',%0A
-
         'blink_c
@@ -3163,32 +3163,106 @@
 nfig': 'blink',%0A
+        'gclient_env': %7B%0A            'GYP_GENERATORS':'ninja',%0A        %7D,%0A
     %7D))%0A%0A#%0A# Win

Switch WebKit Win Builder and WebKit Win Builder (dbg) to ninja.