Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
util.py
Go to the documentation of this file.
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
9# This lists the products we want to isolate as outputs for future steps.
10DEFAULT_BUILD_PRODUCTS = [
11 'dm',
12 'dm.exe',
13 'dm.app',
14 'nanobench.app',
15 'get_images_from_skps',
16 'get_images_from_skps.exe',
17 'nanobench',
18 'nanobench.exe',
19 'skpbench',
20 'skpbench.exe',
21 '*.so',
22 '*.dll',
23 '*.dylib',
24 'skottie_tool',
25 'lib/*.so',
26 'run_testlab',
27]
28
29def py_to_gn(val):
30 """Convert val to a string that can be used as GN args."""
31 if isinstance(val, bool):
32 return 'true' if val else 'false'
33 elif '%s' % val == val:
34 # TODO(dogben): Handle quoting "$\
35 return '"%s"' % val
36 elif isinstance(val, (list, tuple)):
37 return '[%s]' % (','.join(py_to_gn(x) for x in val))
38 elif isinstance(val, dict):
39 gn = ' '.join(
40 '%s=%s' % (k, py_to_gn(v)) for (k, v) in sorted(val.items()))
41 return gn
42 else: # pragma: nocover
43 raise Exception('Converting %s to gn is not implemented.' % type(val))
44
45
46def copy_listed_files(api, src, dst, product_list):
47 """Copy listed files src to dst."""
48 script = api.build.resource('copy_build_products.py')
49 api.step(
50 name='copy build products',
51 cmd=['python3', script, src, dst, ','.join(product_list)],
52 infra_step=True)
53
54
55def set_dawn_args_and_env(args, env, api, extra_tokens, skia_dir):
56 """Add to ``args`` and ``env`` the gn args and environment vars needed to
57 make a build targeting Dawn."""
58 args['skia_use_dawn'] = 'true'
59 args['skia_use_gl'] = 'false'
60 # Set dawn specific args to limit which backends are built
61 args['dawn_enable_d3d11'] = 'false'
62 args['dawn_enable_d3d12'] = 'false'
63 args['dawn_enable_metal'] = 'false'
64 args['dawn_enable_desktop_gl'] = 'false'
65 args['dawn_enable_opengles'] = 'false'
66 args['dawn_enable_vulkan'] = 'false'
67 if 'D3D11' in extra_tokens:
68 args['dawn_enable_d3d11'] = 'true'
69 if 'D3D12' in extra_tokens:
70 args['dawn_enable_d3d12'] = 'true'
71 if 'Metal' in extra_tokens:
72 args['dawn_enable_metal'] = 'true'
73 if 'Vulkan' in extra_tokens:
74 args['dawn_enable_vulkan'] = 'true'
75 env['PYTHONPATH'] = api.path.pathsep.join([
76 str(skia_dir.join('third_party', 'externals')), '%%(PYTHONPATH)s'])
set_dawn_args_and_env(args, env, api, extra_tokens, skia_dir)
Definition util.py:55
py_to_gn(val)
Definition util.py:29
copy_listed_files(api, src, dst, product_list)
Definition util.py:46