Home | History | Annotate | Download | only in recipes
      1 # Copyright 2016 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 
      6 # Recipe module for Skia Swarming compile.
      7 
      8 
      9 DEPS = [
     10   'core',
     11   'recipe_engine/context',
     12   'recipe_engine/json',
     13   'recipe_engine/path',
     14   'recipe_engine/platform',
     15   'recipe_engine/properties',
     16   'recipe_engine/python',
     17   'recipe_engine/step',
     18   'flavor',
     19   'run',
     20   'vars',
     21 ]
     22 
     23 
     24 def build_targets_from_builder_dict(builder_dict):
     25   """Return a list of targets to build, depending on the builder type."""
     26   return ['most']
     27 
     28 
     29 def get_extra_env_vars(vars_api):
     30   env = {}
     31   if vars_api.builder_cfg.get('compiler') == 'Clang':
     32     env['CC'] = '/usr/bin/clang'
     33     env['CXX'] = '/usr/bin/clang++'
     34 
     35   # SKNX_NO_SIMD, SK_USE_DISCARDABLE_SCALEDIMAGECACHE, etc.
     36   # TODO(benjaminwagner): Same appears in gn_flavor.py to set extra_cflags. Are
     37   # both needed?
     38   if (len(vars_api.extra_tokens) == 1 and
     39       vars_api.extra_tokens[0].startswith('SK')):
     40     env['CPPFLAGS'] = '-D' + vars_api.extra_tokens[0]
     41 
     42   return env
     43 
     44 
     45 def RunSteps(api):
     46   bot_update=True
     47   if 'NoDEPS' in api.properties['buildername']:
     48     bot_update = False
     49   api.core.setup(bot_update=bot_update)
     50 
     51   env = get_extra_env_vars(api.vars)
     52   build_targets = build_targets_from_builder_dict(api.vars.builder_cfg)
     53 
     54   try:
     55     for target in build_targets:
     56       with api.context(env=env):
     57         api.flavor.compile(target)
     58     api.run.copy_build_products(
     59         api.flavor.out_dir,
     60         api.vars.swarming_out_dir.join(
     61             'out', api.vars.configuration))
     62     api.flavor.copy_extra_build_products(api.vars.swarming_out_dir)
     63   finally:
     64     if 'Win' in api.vars.builder_cfg.get('os', ''):
     65       api.python.inline(
     66           name='cleanup',
     67           program='''import psutil
     68 for p in psutil.process_iter():
     69   try:
     70     if p.name in ('mspdbsrv.exe', 'vctip.exe', 'cl.exe', 'link.exe'):
     71       p.kill()
     72   except psutil._error.AccessDenied:
     73     pass
     74 ''',
     75           infra_step=True)
     76 
     77   api.flavor.cleanup_steps()
     78   api.run.check_failure()
     79 
     80 
     81 TEST_BUILDERS = [
     82   'Build-Debian9-Clang-arm-Release-Chromebook_GLES',
     83   'Build-Debian9-Clang-arm64-Release-Android',
     84   'Build-Debian9-Clang-arm64-Release-Android_Vulkan',
     85   'Build-Debian9-Clang-arm64-Release-Android_ASAN',
     86   'Build-Debian9-Clang-x86_64-Debug',
     87   'Build-Debian9-Clang-x86_64-Debug-ASAN',
     88   'Build-Debian9-Clang-x86_64-Debug-Coverage',
     89   'Build-Debian9-Clang-x86_64-Debug-MSAN',
     90   'Build-Debian9-Clang-x86_64-Debug-SK_USE_DISCARDABLE_SCALEDIMAGECACHE',
     91   'Build-Debian9-Clang-x86_64-Release-Chromebook_GLES',
     92   'Build-Debian9-Clang-x86_64-Release-Fast',
     93   'Build-Debian9-Clang-x86_64-Release-Mini',
     94   'Build-Debian9-Clang-x86_64-Release-NoDEPS',
     95   'Build-Debian9-Clang-x86_64-Release-Vulkan',
     96   'Build-Debian9-Clang-x86_64-Release-Vulkan_Coverage',
     97   'Build-Debian9-EMCC-wasm-Release',
     98   'Build-Debian9-GCC-arm-Release-Chromecast',
     99   'Build-Debian9-GCC-x86-Debug',
    100   'Build-Debian9-GCC-x86_64-Debug-NoGPU',
    101   'Build-Debian9-GCC-x86_64-Release-ANGLE',
    102   'Build-Debian9-GCC-x86_64-Release-Flutter_Android',
    103   'Build-Debian9-GCC-x86_64-Release-PDFium',
    104   'Build-Debian9-GCC-x86_64-Release-PDFium_SkiaPaths',
    105   'Build-Debian9-GCC-x86_64-Release-Shared',
    106   'Build-Mac-Clang-arm64-Debug-Android',
    107   'Build-Mac-Clang-arm64-Debug-iOS',
    108   'Build-Mac-Clang-x64-Release-iOS',
    109   'Build-Mac-Clang-x86_64-Debug-CommandBuffer',
    110   'Build-Mac-Clang-x86_64-Release',
    111   'Build-Win-Clang-arm64-Release-Android',
    112   'Build-Win-Clang-x86_64-Release-Vulkan',
    113   'Build-Win-MSVC-x86-Debug',
    114   'Build-Win-MSVC-x86-Debug-ANGLE',
    115   'Build-Win-MSVC-x86-Debug-Exceptions',
    116   'Build-Win-MSVC-x86-Release-GDI',
    117 ]
    118 
    119 
    120 def GenTests(api):
    121   for builder in TEST_BUILDERS:
    122     test = (
    123       api.test(builder) +
    124       api.properties(buildername=builder,
    125                      repository='https://skia.googlesource.com/skia.git',
    126                      revision='abc123',
    127                      path_config='kitchen',
    128                      swarm_out_dir='[SWARM_OUT_DIR]') +
    129       api.path.exists(
    130           api.path['start_dir'].join('tmp', 'uninteresting_hashes.txt')
    131       )
    132     )
    133     if 'Win' in builder:
    134       test += api.platform('win', 64)
    135     elif 'Mac' in builder:
    136       test += api.platform('mac', 64)
    137     else:
    138       test += api.platform('linux', 64)
    139 
    140     yield test
    141 
    142 
    143   buildername = 'Build-Win-Clang-x86_64-Release-Vulkan'
    144   yield (
    145       api.test('trybot') +
    146       api.properties(buildername=buildername,
    147                      repository='https://skia.googlesource.com/skia.git',
    148                      revision='abc123',
    149                      path_config='kitchen',
    150                      swarm_out_dir='[SWARM_OUT_DIR]') +
    151       api.path.exists(
    152           api.path['start_dir'].join('tmp', 'uninteresting_hashes.txt')
    153       ) +
    154       api.properties(patch_storage='gerrit') +
    155       api.properties.tryserver(
    156           buildername=buildername,
    157           gerrit_project='skia',
    158           gerrit_url='https://skia-review.googlesource.com/',
    159       )
    160     )
    161 
    162   yield (
    163       api.test('alternate_repo') +
    164       api.properties(buildername=buildername,
    165                      repository='https://skia.googlesource.com/other_repo.git',
    166                      revision='abc123',
    167                      path_config='kitchen',
    168                      swarm_out_dir='[SWARM_OUT_DIR]') +
    169       api.path.exists(
    170           api.path['start_dir'].join('tmp', 'uninteresting_hashes.txt')
    171       )
    172     )
    173 
    174   buildername = 'Build-Debian9-GCC-x86_64-Release-PDFium'
    175   yield (
    176       api.test('pdfium_trybot') +
    177       api.properties(
    178           repository='https://skia.googlesource.com/skia.git',
    179           buildername=buildername,
    180           path_config='kitchen',
    181           swarm_out_dir='[SWARM_OUT_DIR]',
    182           revision='abc123',
    183           patch_issue=500,
    184           patch_repo='https://skia.googlesource.com/skia.git',
    185           patch_set=1,
    186           patch_storage='gerrit') +
    187       api.properties.tryserver(
    188           buildername=buildername,
    189           gerrit_project='skia',
    190           gerrit_url='https://skia-review.googlesource.com/',
    191       ) +
    192       api.path.exists(
    193           api.path['start_dir'].join('tmp', 'uninteresting_hashes.txt')
    194       )
    195   )
    196 
    197   buildername = 'Build-Debian9-GCC-x86_64-Release-Flutter_Android'
    198   yield (
    199       api.test('flutter_trybot') +
    200       api.properties(
    201           repository='https://skia.googlesource.com/skia.git',
    202           buildername=buildername,
    203           path_config='kitchen',
    204           swarm_out_dir='[SWARM_OUT_DIR]',
    205           revision='abc123',
    206           patch_issue=500,
    207           patch_repo='https://skia.googlesource.com/skia.git',
    208           patch_set=1,
    209           patch_storage='gerrit') +
    210       api.properties.tryserver(
    211           buildername=buildername,
    212           gerrit_project='skia',
    213           gerrit_url='https://skia-review.googlesource.com/',
    214       ) +
    215       api.path.exists(
    216           api.path['start_dir'].join('tmp', 'uninteresting_hashes.txt')
    217       )
    218   )
    219