• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
6def compile_fn(api, checkout_root, out_dir):
7  flutter_dir   = checkout_root.join('src')
8  configuration = api.vars.builder_cfg.get('configuration').lower()
9  extra_tokens = api.vars.extra_tokens
10
11  with api.context(cwd=flutter_dir):
12    # Setup GN args.
13    gn_args = [
14        '--runtime-mode=%s' % configuration,
15    ]
16    if 'Android' in extra_tokens:
17      gn_args.append('--android')
18
19    # Delete out_dir so that we start from a clean slate. See skbug/6310.
20    api.run.rmtree(out_dir)
21
22    # Run GN.
23    api.run(
24        api.step,
25        'gn_gen',
26        cmd=['flutter/tools/gn'] + gn_args)
27
28    # Build Flutter.
29    api.run(
30        api.step,
31        'build_flutter',
32        cmd=['ninja', '-C', out_dir, '-j100'])
33
34
35def copy_extra_build_products(api, src, dst):
36  stripped_src = src.join('lib.stripped', 'libflutter.so')
37  stripped_dst = dst.join('libflutter_stripped.so')
38  api.python.inline(
39      name='copy stripped library',
40      program='''
41import shutil
42import sys
43
44src = sys.argv[1]
45dst = sys.argv[2]
46
47shutil.copyfile(src, dst)
48''',
49      args=[stripped_src, stripped_dst],
50      infra_step=True)
51