aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/bots/recipe_modules/flavor/flutter_flavor.py
blob: ebc498edab38a4fd7e44be7a69a5463ebd88c1cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright 2017 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.

import re

import default_flavor


"""Flutter flavor utils, used for building Flutter with Skia."""


class FlutterFlavorUtils(default_flavor.DefaultFlavorUtils):

  def compile(self, target):
    """Build Flutter with Skia."""

    flutter_dir = self.m.vars.checkout_root.join('src')
    configuration = self.m.vars.builder_cfg.get('configuration').lower()
    extra_tokens = self.m.vars.extra_tokens
    out_dir = configuration

    with self.m.context(cwd=flutter_dir):
      # Runhook to generate the gn binary in buildtools.
      # TODO(borenet): Remove this hack and replace with
      # 'self.m.gclient.runhooks()' after the transition to Kitchen:
      # https://bugs.chromium.org/p/skia/issues/detail?id=7050
      depot_tools = self.m.vars.checkout_root.join('depot_tools')
      self.m.git.checkout(
          'https://chromium.googlesource.com/chromium/tools/depot_tools.git',
          dir_path=depot_tools, ref='06493714339009216197d59c5413da2a1efdf4a2')
      self.m.run(
          self.m.step,
          'runhook',
          cmd=[depot_tools.join('gclient'), 'runhooks'])

      # Setup GN args.
      gn_args = [
          '--runtime-mode=%s' % configuration,
      ]
      if 'Android' in extra_tokens:
        gn_args.append('--android')
        out_dir = 'android_' + out_dir

      # Delete out_dir so that we start from a clean slate. See skbug/6310.
      self.m.run.rmtree(flutter_dir.join('out', out_dir))

      # Run GN.
      self.m.run(
          self.m.step,
          'gn_gen',
          cmd=['flutter/tools/gn'] + gn_args)

      # Build Flutter.
      self.m.run(
          self.m.step,
          'build_flutter',
          cmd=['ninja', '-C', 'out/' + out_dir, '-j100'])