• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  clang_linux = api.vars.slave_dir.join('clang_linux')
12  # This is a pretty typical arm-linux-gnueabihf sysroot
13  sysroot_dir = api.vars.slave_dir.join('armhf_sysroot')
14
15  if 'arm' == target_arch:
16    # This is the extra things needed to link against for the chromebook.
17    #  For example, the Mali GL drivers.
18    gl_dir = api.vars.slave_dir.join('chromebook_arm_gles')
19    env = {'LD_LIBRARY_PATH': sysroot_dir.join('lib')}
20    extra_asmflags = [
21      '--target=armv7a-linux-gnueabihf',
22      '--sysroot=%s' % sysroot_dir,
23      '-march=armv7-a',
24      '-mfpu=neon',
25      '-mthumb',
26    ]
27
28    extra_cflags = [
29      '--target=armv7a-linux-gnueabihf',
30      '--sysroot=%s' % sysroot_dir,
31      '-I%s' % gl_dir.join('include'),
32      '-I%s' % sysroot_dir.join('include'),
33      '-I%s' % sysroot_dir.join('include', 'c++', '4.8.4'),
34      '-I%s' % sysroot_dir.join('include', 'c++', '4.8.4',
35                                'arm-linux-gnueabihf'),
36      '-DMESA_EGL_NO_X11_HEADERS',
37      '-U_GLIBCXX_DEBUG',
38    ]
39
40    extra_ldflags = [
41      '--target=armv7a-linux-gnueabihf',
42      '--sysroot=%s' % sysroot_dir,
43      # use sysroot's ld which can properly link things.
44      '-B%s' % sysroot_dir.join('bin'),
45      # helps locate crt*.o
46      '-B%s' % sysroot_dir.join('gcc-cross'),
47      # helps locate libgcc*.so
48      '-L%s' % sysroot_dir.join('gcc-cross'),
49      '-L%s' % sysroot_dir.join('lib'),
50      '-L%s' % gl_dir.join('lib'),
51      # Explicitly do not use lld for cross compiling like this - I observed
52      # failures like "Unrecognized reloc 41" and couldn't find out why.
53    ]
54  else:
55    gl_dir = api.vars.slave_dir.join('chromebook_x86_64_gles')
56    env = {}
57    extra_asmflags = []
58    extra_cflags = [
59      '-DMESA_EGL_NO_X11_HEADERS',
60      '-I%s' % gl_dir.join('include'),
61    ]
62    extra_ldflags = [
63      '-L%s' % gl_dir.join('lib'),
64      '-static-libstdc++', '-static-libgcc',
65      '-fuse-ld=lld',
66    ]
67
68  quote = lambda x: '"%s"' % x
69  args = {
70    'cc': quote(clang_linux.join('bin','clang')),
71    'cxx': quote(clang_linux.join('bin','clang++')),
72    'target_cpu': quote(target_arch),
73    'skia_use_fontconfig': 'false',
74    'skia_use_system_freetype2': 'false',
75    'skia_use_egl': 'true',
76  }
77  extra_cflags.append('-DDUMMY_clang_linux_version=%s' %
78                      api.run.asset_version('clang_linux', skia_dir))
79
80  if configuration != 'Debug':
81    args['is_debug'] = 'false'
82  args['extra_asmflags'] = repr(extra_asmflags).replace("'", '"')
83  args['extra_cflags'] = repr(extra_cflags).replace("'", '"')
84  args['extra_ldflags'] = repr(extra_ldflags).replace("'", '"')
85
86  gn_args = ' '.join('%s=%s' % (k,v) for (k,v) in sorted(args.iteritems()))
87  gn = skia_dir.join('bin', 'gn')
88
89  with api.context(cwd=skia_dir, env=env):
90    api.run(api.python, 'fetch-gn',
91            script=skia_dir.join('bin', 'fetch-gn'),
92            infra_step=True)
93    api.run(api.step, 'gn gen', cmd=[gn, 'gen', out_dir, '--args=' + gn_args])
94    api.run(api.step, 'ninja',
95            cmd=['ninja', '-C', out_dir, 'nanobench', 'dm'])
96
97
98def copy_extra_build_products(api, src, dst):
99  pass
100