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