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 5import re 6 7import default_flavor 8 9 10"""Flutter flavor utils, used for building Flutter with Skia.""" 11 12 13class 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_config = self.m.vars.builder_cfg.get('extra_config', '') 21 out_dir = configuration 22 23 with self.m.step.context({'cwd': flutter_dir}): 24 # Runhook to generate the gn binary in buildtools. 25 self.m.run( 26 self.m.step, 27 'runhook', 28 cmd=['gclient', 'runhooks']) 29 30 # Setup GN args. 31 gn_args = [ 32 '--runtime-mode=%s' % configuration, 33 ] 34 if 'Android' in extra_config: 35 gn_args.append('--android') 36 out_dir = 'android_' + out_dir 37 38 # Delete out_dir so that we start from a clean slate. See skbug/6310. 39 self.m.run.rmtree(flutter_dir.join('out', out_dir)) 40 41 # Run GN. 42 self.m.run( 43 self.m.step, 44 'gn_gen', 45 cmd=['flutter/tools/gn'] + gn_args) 46 47 # Build Flutter. 48 self.m.run( 49 self.m.step, 50 'build_flutter', 51 cmd=['ninja', '-C', 'out/' + out_dir, '-j100']) 52