skia2/infra/bots/recipe_modules/build/util.py
Kevin Lubick 446b974be8 Remove old devices.json and code
The code in cts subfolder was unused in over a year, and the SKQP stuff
was also unused (and non-inclusive).

Bug: 1097221
Change-Id: Icf3d37fbe773125ab714a9b68b1b620f39857b5c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305438
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Eric Boren <borenet@google.com>
Auto-Submit: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Eric Boren <borenet@google.com>
2020-07-23 12:24:26 +00:00

83 lines
2.1 KiB
Python

# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Shared utilities for the build recipe module."""
# This lists the products we want to isolate as outputs for future steps.
DEFAULT_BUILD_PRODUCTS = [
'dm',
'dm.exe',
'dm.app',
'fm',
'nanobench.app',
'get_images_from_skps',
'get_images_from_skps.exe',
'hello-opencl',
'hello-opencl.exe',
'nanobench',
'nanobench.exe',
'skpbench',
'skpbench.exe',
'*.so',
'*.dll',
'*.dylib',
'skia_launcher',
'skottie_tool',
'lib/*.so',
'run_testlab',
'skqp-universal-debug.apk',
]
# TODO(westont): Use this in docker.py, instead of a copy of it.
def py_to_gn(val):
"""Convert val to a string that can be used as GN args."""
if isinstance(val, bool):
return 'true' if val else 'false'
elif isinstance(val, basestring):
# TODO(dogben): Handle quoting "$\
return '"%s"' % val
elif isinstance(val, (list, tuple)):
return '[%s]' % (','.join(py_to_gn(x) for x in val))
elif isinstance(val, dict):
gn = ' '.join(
'%s=%s' % (k, py_to_gn(v)) for (k, v) in sorted(val.iteritems()))
return gn
else: # pragma: nocover
raise Exception('Converting %s to gn is not implemented.' % type(val))
def copy_listed_files(api, src, dst, product_list):
"""Copy listed files src to dst."""
api.python.inline(
name='copy build products',
program='''import errno
import glob
import os
import shutil
import sys
src = sys.argv[1]
dst = sys.argv[2]
build_products = %s
try:
os.makedirs(dst)
except OSError as e:
if e.errno != errno.EEXIST:
raise
for pattern in build_products:
path = os.path.join(src, pattern)
for f in glob.glob(path):
dst_path = os.path.join(dst, os.path.relpath(f, src))
if not os.path.isdir(os.path.dirname(dst_path)):
os.makedirs(os.path.dirname(dst_path))
print 'Copying build product %%s to %%s' %% (f, dst_path)
shutil.move(f, dst_path)
''' % str(product_list),
args=[src, dst],
infra_step=True)