1# Copyright 2018 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"""Shared utilities for the build recipe module."""
7
8
9BUILD_PRODUCTS_ISOLATE_WHITELIST = [
10  'bookmaker',
11  'dm',
12  'dm.exe',
13  'dm.app',
14  'nanobench.app',
15  'get_images_from_skps',
16  'get_images_from_skps.exe',
17  'hello-opencl',
18  'hello-opencl.exe',
19  'nanobench',
20  'nanobench.exe',
21  'skpbench',
22  'skpbench.exe',
23  '*.so',
24  '*.dll',
25  '*.dylib',
26  'skia_launcher',
27  'skiaserve',
28  'lib/*.so',
29  'run_testlab',
30  'skqp-universal-debug.apk',
31  'whitelist_devices.json',
32]
33
34
35def copy_whitelisted_build_products(api, src, dst):
36  """Copy whitelisted build products from src to dst."""
37  api.python.inline(
38      name='copy build products',
39      program='''import errno
40import glob
41import os
42import shutil
43import sys
44
45src = sys.argv[1]
46dst = sys.argv[2]
47build_products_whitelist = %s
48
49try:
50  os.makedirs(dst)
51except OSError as e:
52  if e.errno != errno.EEXIST:
53    raise
54
55for pattern in build_products_whitelist:
56  path = os.path.join(src, pattern)
57  for f in glob.glob(path):
58    dst_path = os.path.join(dst, os.path.relpath(f, src))
59    if not os.path.isdir(os.path.dirname(dst_path)):
60      os.makedirs(os.path.dirname(dst_path))
61    print 'Copying build product %%s to %%s' %% (f, dst_path)
62    shutil.move(f, dst_path)
63''' % str(BUILD_PRODUCTS_ISOLATE_WHITELIST),
64      args=[src, dst],
65      infra_step=True)
66