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 skia_dir = checkout_root.join('skia') 8 configuration = api.vars.builder_cfg.get('configuration') 9 target_arch = api.vars.builder_cfg.get('target_arch') 10 11 # TODO(kjlubick): can this toolchain be replaced/shared with chromebook? 12 toolchain_dir = api.vars.slave_dir.join('cast_toolchain', 'armv7a') 13 gles_dir = api.vars.slave_dir.join('chromebook_arm_gles') 14 15 target = ['-target', 'armv7a-cros-linux-gnueabi'] 16 sysroot = ['--sysroot', 17 '%s/usr/armv7a-cros-linux-gnueabi' % toolchain_dir] 18 19 extra_asmflags = target 20 21 extra_cflags = target + sysroot + [ 22 '-I%s' % gles_dir.join('include'), 23 '-DMESA_EGL_NO_X11_HEADERS', 24 "-DSK_NO_COMMAND_BUFFER", 25 # Avoid unused warning with yyunput 26 '-Wno-error=unused-function', 27 # Makes the binary small enough to fit on the small disk. 28 '-g0', 29 ('-DDUMMY_cast_toolchain_version=%s' % 30 api.run.asset_version('cast_toolchain', skia_dir)), 31 ] 32 33 extra_ldflags = target + sysroot + [ 34 # Chromecast does not package libstdc++ 35 '-static-libstdc++', '-static-libgcc', 36 '-L%s' % toolchain_dir.join('lib'), 37 '-fuse-ld=gold', 38 '-B%s/usr/libexec/gcc' % toolchain_dir, 39 ] 40 41 quote = lambda x: '"%s"' % x 42 args = { 43 'cc': quote(toolchain_dir.join('usr', 'bin', 'clang-3.9.elf')), 44 'cxx': quote(toolchain_dir.join('usr', 'bin', 'clang++-3.9.elf')), 45 'ar': quote(toolchain_dir.join('bin','armv7a-cros-linux-gnueabi-ar')), 46 'target_cpu': quote(target_arch), 47 'skia_use_fontconfig': 'false', 48 'skia_enable_gpu': 'true', 49 # The toolchain won't allow system libraries to be used 50 # when cross-compiling 51 'skia_use_system_freetype2': 'false', 52 # Makes the binary smaller 53 'skia_use_icu': 'false', 54 'skia_use_egl': 'true', 55 } 56 57 if configuration != 'Debug': 58 args['is_debug'] = 'false' 59 args['extra_asmflags'] = repr(extra_asmflags).replace("'", '"') 60 args['extra_cflags'] = repr(extra_cflags).replace("'", '"') 61 args['extra_ldflags'] = repr(extra_ldflags).replace("'", '"') 62 63 gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted(args.iteritems())) 64 gn = skia_dir.join('bin', 'gn') 65 66 with api.context(cwd=skia_dir): 67 api.run(api.python, 'fetch-gn', 68 script=skia_dir.join('bin', 'fetch-gn'), 69 infra_step=True) 70 api.run(api.step, 'gn gen', cmd=[gn, 'gen', out_dir, '--args=' + gn_args]) 71 api.run(api.step, 'ninja', 72 cmd=['ninja', '-C', out_dir, 'nanobench', 'dm']) 73 74 75def copy_extra_build_products(api, src, dst): 76 pass 77