| 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 |
from . import util |
| 6 |
|
| 7 |
# This git revision refers to the Skia version of the cmake-release/Dockerfile that was built. |
| 8 |
DOCKER_IMAGE = 'gcr.io/skia-public/cmake-release:git-376aa231c94dd9fabb170903dcfb8e95f2da502c' |
| 9 |
INNER_BUILD_SCRIPT = '/SRC/skia/infra/cmake/build_skia.sh' |
| 10 |
|
| 11 |
|
| 12 |
def compile_fn(api, checkout_root, _ignore): |
| 13 |
out_dir = api.vars.cache_dir.joinpath('docker', 'cmake') |
| 14 |
configuration = api.vars.builder_cfg.get('configuration', '') |
| 15 |
if configuration != 'Release': # pragma: nocover |
| 16 |
# If a debug mode is wanted, update the infra/cmake/build_skia.sh |
| 17 |
# to support that also. |
| 18 |
raise 'Only Release mode supported for CMake' |
| 19 |
|
| 20 |
# We want to make sure the directories exist and were created by chrome-bot, |
| 21 |
# because if that isn't the case, docker will make them and they will be |
| 22 |
# owned by root, which causes mysterious failures. To mitigate this risk |
| 23 |
# further, we don't use the same out_dir as everyone else (thus the _ignore) |
| 24 |
# param. Instead, we use a "cmake" subdirectory in the "docker" named_cache. |
| 25 |
api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0o777) |
| 26 |
|
| 27 |
# This uses the cmake docker image and says "run the |
| 28 |
# build_skia.sh helper script in there". Additionally, it binds two |
| 29 |
# folders: the Skia checkout to /SRC and the output directory to /OUT |
| 30 |
# The called helper script will make the compile happen and put the |
| 31 |
# output in the right spot. The neat thing is that since the Skia checkout |
| 32 |
# (and, by extension, the build script) is not a part of the image, but |
| 33 |
# bound in at runtime, we don't have to re-build the image, except when the |
| 34 |
# toolchain changes. |
| 35 |
cmd = ['docker', 'run', '--rm', '--volume', '%s:/SRC' % checkout_root, |
| 36 |
'--volume', '%s:/OUT' % out_dir, |
| 37 |
DOCKER_IMAGE, INNER_BUILD_SCRIPT] |
| 38 |
# It's always Release mode (for now?) This is mostly an FYI |
| 39 |
# thing, to make sure we don't break CMake users. |
| 40 |
|
| 41 |
# Override DOCKER_CONFIG set by Kitchen. |
| 42 |
env = {'DOCKER_CONFIG': '/home/chrome-bot/.docker'} |
| 43 |
with api.env(env): |
| 44 |
api.run( |
| 45 |
api.step, |
| 46 |
'Build Skia using CMake in Docker', |
| 47 |
cmd=cmd) |
| 48 |
|
| 49 |
def copy_build_products(api, src, dst): |
| 50 |
util.copy_listed_files(api, src, dst, util.DEFAULT_BUILD_PRODUCTS) |