• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 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
6from . import util
7
8IMAGES = {
9    'gcc-debian10': (
10        'gcr.io/skia-public/gcc-debian10@sha256:'
11        'cd1dd99a3c423332a00998a20c4363aa1d5998b41f21e6e86ca016b412082777'),
12    'gcc-debian10-x86': (
13        'gcr.io/skia-public/gcc-debian10-x86@sha256:'
14        'e30b4616f842fa2fd89329abf3d8e81cf6c25e147640289f37692f18862515c8'),
15}
16
17
18def compile_fn(api, checkout_root, out_dir):
19  compiler = api.vars.builder_cfg.get('compiler', '')
20  configuration = api.vars.builder_cfg.get('configuration', '')
21  extra_tokens = api.vars.extra_tokens
22  extra_tokens.remove('Docker')
23  os = api.vars.builder_cfg.get('os', '')
24  target_arch = api.vars.builder_cfg.get('target_arch', '')
25
26  args = {
27      'extra_cflags': [],
28      'extra_ldflags': [],
29      'target_cpu': target_arch,
30      'werror': True
31  }
32
33  if configuration == 'Debug':
34    args['extra_cflags'].append('-O1')
35  else:
36    args['is_debug'] = False
37
38  if 'NoGPU' in extra_tokens:
39    args['skia_enable_ganesh'] = False
40    extra_tokens.remove('NoGPU')
41  if 'Shared' in extra_tokens:
42    args['is_component_build'] = True
43    extra_tokens.remove('Shared')
44
45  image_name = None
46  if os == 'Debian10' and compiler == 'GCC' and not extra_tokens:
47    args['cc'] = 'gcc'
48    args['cxx'] = 'g++'
49    # Newer GCC includes tons and tons of debugging symbols. This seems to
50    # negatively affect our bots (potentially only in combination with other
51    # bugs in Swarming or recipe code). Use g1 to reduce it a bit.
52    args['extra_cflags'].append('-g1')
53    if target_arch == 'x86_64':
54      image_name = 'gcc-debian10'
55    elif target_arch == 'x86':
56      image_name = 'gcc-debian10-x86'
57
58  if not image_name:
59    raise Exception('Not implemented: ' + api.vars.builder_name)
60
61  image_hash = IMAGES[image_name]
62  # We always perform an incremental compile, since out dir is cached across
63  # compile tasks. However, we need to force a recompile when the toolchain
64  # changes. The simplest way to do that is using a C define that changes
65  # anytime the image changes.
66  args['extra_cflags'].append('-DREBUILD_IF_CHANGED_docker_image=%s' % image_hash)
67
68  script = api.build.resource('docker-compile.sh')
69  api.docker.run('Run build script in Docker', image_hash,
70                 checkout_root, out_dir, script, args=[util.py_to_gn(args)])
71
72def copy_build_products(api, src, dst):
73  util.copy_listed_files(api, src, dst, util.DEFAULT_BUILD_PRODUCTS)
74