| 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 |
|
| 6 |
from . import default |
| 7 |
from . import util |
| 8 |
|
| 9 |
IMAGES = { |
| 10 |
'gcc-debian11': ( |
| 11 |
'gcr.io/skia-public/gcc-debian11@sha256:' |
| 12 |
'1117ea368f43e45e0f543f74c8e3bf7ff6932df54ddaa4ba1fe6131209110d3d'), |
| 13 |
'gcc-debian11-x86': ( |
| 14 |
'gcr.io/skia-public/gcc-debian11-x86@sha256:' |
| 15 |
'eb30682887c4c74c95f769aacab8a1a170eb561536ded87f0914f88b7243ba23'), |
| 16 |
'gcc-ubuntu18': ( |
| 17 |
'gcr.io/skia-public/clang-ubuntu18@sha256:' |
| 18 |
'c46fdae57032646419baf125310c94363b5cb0e722ffcc63686468f485608aaa'), |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
def compile_fn(api, checkout_root, out_dir): |
| 23 |
compiler = api.vars.builder_cfg.get('compiler', '') |
| 24 |
extra_tokens = api.vars.extra_tokens |
| 25 |
extra_tokens.remove('Docker') |
| 26 |
os = api.vars.builder_cfg.get('os', '') |
| 27 |
target_arch = api.vars.builder_cfg.get('target_arch', '') |
| 28 |
|
| 29 |
workdir = api.path.cast_to_path('/SRC') |
| 30 |
args, env, _ = default.get_compile_flags(api, checkout_root, out_dir, workdir) |
| 31 |
|
| 32 |
image_name = None |
| 33 |
if os == 'Debian11' and compiler == 'GCC': |
| 34 |
if target_arch == 'x86_64': |
| 35 |
image_name = 'gcc-debian11' |
| 36 |
elif target_arch == 'x86': |
| 37 |
image_name = 'gcc-debian11-x86' |
| 38 |
|
| 39 |
if not image_name: |
| 40 |
raise Exception('Not implemented: ' + api.vars.builder_name) |
| 41 |
|
| 42 |
image_hash = IMAGES[image_name] |
| 43 |
|
| 44 |
args['extra_cflags'].append('-DREBUILD_IF_CHANGED_docker_image=%s' % image_hash) |
| 45 |
gn_flags = default.finalize_gn_flags(args) |
| 46 |
|
| 47 |
# We always perform an incremental compile, since out dir is cached across |
| 48 |
# compile tasks. However, we need to force a recompile when the toolchain |
| 49 |
# changes. The simplest way to do that is using a C define that changes |
| 50 |
# anytime the image changes. |
| 51 |
script = api.build.resource('docker-compile.sh') |
| 52 |
api.docker.run('Run build script in Docker', image_hash, |
| 53 |
api.vars.workdir, out_dir, script, args=[gn_flags], env=env) |
| 54 |
|
| 55 |
def copy_build_products(api, src, dst): |
| 56 |
util.copy_listed_files(api, src, dst, util.DEFAULT_BUILD_PRODUCTS) |