Home | History | Annotate | Download | only in flavor
      1 # Copyright 2017 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 import re
      6 
      7 import default_flavor
      8 
      9 
     10 """Flutter flavor utils, used for building Flutter with Skia."""
     11 
     12 
     13 class FlutterFlavorUtils(default_flavor.DefaultFlavorUtils):
     14 
     15   def compile(self, target):
     16     """Build Flutter with Skia."""
     17 
     18     flutter_dir = self.m.vars.checkout_root.join('src')
     19     configuration = self.m.vars.builder_cfg.get('configuration').lower()
     20     extra_tokens = self.m.vars.extra_tokens
     21     out_dir = configuration
     22 
     23     with self.m.context(cwd=flutter_dir):
     24       # Runhook to generate the gn binary in buildtools.
     25       # TODO(borenet): Remove this hack and replace with
     26       # 'self.m.gclient.runhooks()' after the transition to Kitchen:
     27       # https://bugs.chromium.org/p/skia/issues/detail?id=7050
     28       depot_tools = self.m.vars.checkout_root.join('depot_tools')
     29       self.m.git.checkout(
     30           'https://chromium.googlesource.com/chromium/tools/depot_tools.git',
     31           dir_path=depot_tools, ref='master')
     32       self.m.run(
     33           self.m.step,
     34           'runhook',
     35           cmd=[depot_tools.join('gclient'), 'runhooks'])
     36 
     37       # Setup GN args.
     38       gn_args = [
     39           '--runtime-mode=%s' % configuration,
     40       ]
     41       if 'Android' in extra_tokens:
     42         gn_args.append('--android')
     43         out_dir = 'android_' + out_dir
     44 
     45       # Delete out_dir so that we start from a clean slate. See skbug/6310.
     46       self.m.run.rmtree(flutter_dir.join('out', out_dir))
     47 
     48       # Run GN.
     49       self.m.run(
     50           self.m.step,
     51           'gn_gen',
     52           cmd=['flutter/tools/gn'] + gn_args)
     53 
     54       # Build Flutter.
     55       self.m.run(
     56           self.m.step,
     57           'build_flutter',
     58           cmd=['ninja', '-C', 'out/' + out_dir, '-j100'])
     59