Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
build.android Namespace Reference

Functions

 compile_fn (api, checkout_root, out_dir)
 
 copy_build_products (api, src, dst)
 

Variables

list ANDROID_BUILD_PRODUCTS_LIST
 

Function Documentation

◆ compile_fn()

build.android.compile_fn (   api,
  checkout_root,
  out_dir 
)

Definition at line 10 of file android.py.

10def compile_fn(api, checkout_root, out_dir):
11 skia_dir = checkout_root.join('skia')
12 compiler = api.vars.builder_cfg.get('compiler')
13 configuration = api.vars.builder_cfg.get('configuration')
14 extra_tokens = api.vars.extra_tokens
15 os = api.vars.builder_cfg.get('os')
16 target_arch = api.vars.builder_cfg.get('target_arch')
17
18 assert compiler == 'Clang' # At this rate we might not ever support GCC.
19
20 extra_cflags = []
21 extra_ldflags = []
22 if configuration == 'Debug':
23 extra_cflags.append('-O1')
24
25 ndk_asset = 'android_ndk_linux'
26 ndk_path = ndk_asset
27 if 'Mac' in os:
28 ndk_asset = 'android_ndk_darwin'
29 ndk_path = ndk_asset
30 elif 'Win' in os:
31 ndk_asset = 'android_ndk_windows'
32 ndk_path = 'n'
33
34 quote = lambda x: '"%s"' % x
35 args = {
36 'ndk': quote(api.vars.workdir.join(ndk_path)),
37 'target_cpu': quote(target_arch),
38 'werror': 'true',
39 }
40 env = {}
41 extra_cflags.append('-DREBUILD_IF_CHANGED_ndk_version=%s' %
42 api.run.asset_version(ndk_asset, skia_dir))
43
44 if configuration != 'Debug':
45 args['is_debug'] = 'false'
46 if 'Dawn' in extra_tokens:
47 util.set_dawn_args_and_env(args, env, api, extra_tokens, skia_dir)
48 args['ndk_api'] = 26 #skia_use_gl=false, so use vulkan
49 if 'Vulkan' in extra_tokens and not 'Dawn' in extra_tokens:
50 args['ndk_api'] = 26
51 args['skia_enable_vulkan_debug_layers'] = 'false'
52 args['skia_use_gl'] = 'false'
53 args['skia_use_vulkan'] = 'true'
54 if 'ASAN' in extra_tokens:
55 args['sanitize'] = '"ASAN"'
56 if 'Graphite' in extra_tokens:
57 args['skia_enable_graphite'] = 'true'
58 if 'HWASAN' in extra_tokens:
59 args['sanitize'] = '"HWASAN"'
60 if 'Wuffs' in extra_tokens:
61 args['skia_use_wuffs'] = 'true'
62 if configuration == 'OptimizeForSize':
63 # build IDs are required for Bloaty if we want to use strip to ignore debug symbols.
64 # https://github.com/google/bloaty/blob/master/doc/using.md#debugging-stripped-binaries
65 extra_ldflags.append('-Wl,--build-id=sha1')
66 args.update({
67 'skia_use_runtime_icu': 'true',
68 'skia_enable_optimize_size': 'true',
69 'skia_use_jpeg_gainmaps': 'false',
70 })
71
72 # The 'FrameworkWorkarounds' bot is used to test special behavior that's
73 # normally enabled with SK_BUILD_FOR_ANDROID_FRAMEWORK.
74 if 'FrameworkWorkarounds' in extra_tokens:
75 extra_cflags.append('-DSK_SUPPORT_LEGACY_ALPHA_BITMAP_AS_COVERAGE')
76
77 # If an Android API level is specified, use that.
78 for t in extra_tokens:
79 m = re.search(r'API(\d+)', t)
80 if m and len(m.groups()) == 1:
81 args['ndk_api'] = m.groups()[0]
82 break
83
84 if extra_cflags:
85 args['extra_cflags'] = repr(extra_cflags).replace("'", '"')
86 if extra_ldflags:
87 args['extra_ldflags'] = repr(extra_ldflags).replace("'", '"')
88
89 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted(args.items()))
90 gn = skia_dir.join('bin', 'gn')
91
92 with api.context(cwd=skia_dir):
93 api.run(api.step, 'fetch-gn',
94 cmd=['python3', skia_dir.join('bin', 'fetch-gn')],
95 infra_step=True)
96
97 api.run(api.step, 'fetch-ninja',
98 cmd=['python3', skia_dir.join('bin', 'fetch-ninja')],
99 infra_step=True)
100
101 with api.env(env):
102 api.run(api.step, 'gn gen',
103 cmd=[gn, 'gen', out_dir, '--args=' + gn_args])
104 api.run(api.step, 'ninja', cmd=['ninja', '-C', out_dir])
105
106

◆ copy_build_products()

build.android.copy_build_products (   api,
  src,
  dst 
)
Copy Android build products from src to dst.

Definition at line 117 of file android.py.

117def copy_build_products(api, src, dst):
118 """Copy Android build products from src to dst."""
119 util.copy_listed_files(api, src, dst, ANDROID_BUILD_PRODUCTS_LIST)

Variable Documentation

◆ ANDROID_BUILD_PRODUCTS_LIST

list build.android.ANDROID_BUILD_PRODUCTS_LIST
Initial value:
1= [
2 'dm',
3 'nanobench',
4 'skpbench',
5 # The following only exists when building for OptimizeForSize
6 # This is the only target we currently measure: skbug.com/13657
7 'skottie_tool_gpu',
8]

Definition at line 107 of file android.py.