skia2/infra/bots/recipe_modules/build/flutter.py
Kevin Lubick 9e951cd782 Reduce bandwidth to RPIs
PS1 refactors to make copying more explicit.

Change-Id: I35c3aecd10bbdb5ab2a462c72b062d979f48fce8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/246099
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Ben Wagner aka dogben <benjaminwagner@google.com>
2019-10-04 14:50:49 +00:00

62 lines
1.5 KiB
Python

# Copyright 2018 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.
from . import util
def compile_fn(api, checkout_root, out_dir):
flutter_dir = checkout_root.join('src')
configuration = api.vars.builder_cfg.get('configuration').lower()
extra_tokens = api.vars.extra_tokens
with api.context(cwd=flutter_dir):
# Setup GN args.
gn_args = [
'--runtime-mode=%s' % configuration,
]
if 'Android' in extra_tokens:
gn_args.append('--android')
# Delete out_dir so that we start from a clean slate. See skbug/6310.
api.run.rmtree(out_dir)
# Run GN.
api.run(
api.step,
'gn_gen',
cmd=['flutter/tools/gn'] + gn_args)
# Build Flutter.
api.run(
api.step,
'build_flutter',
cmd=['ninja', '-C', out_dir, '-j100'])
FLUTTER_BUILD_PRODUCTS_LIST = [
'*.so',
'lib/*.so',
]
def copy_build_products(api, src, dst):
util.copy_listed_files(api, src, dst, FLUTTER_BUILD_PRODUCTS_LIST)
stripped_src = src.join('lib.stripped', 'libflutter.so')
stripped_dst = dst.join('libflutter_stripped.so')
api.python.inline(
name='copy stripped library',
program='''
import os
import shutil
import sys
src = sys.argv[1]
dst = sys.argv[2]
if not os.path.isdir(os.path.dirname(dst)):
os.makedirs(os.path.dirname(dst))
shutil.copyfile(src, dst)
''',
args=[stripped_src, stripped_dst],
infra_step=True)