1 # Copyright 2016 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 """PDFium flavor utils, used for building PDFium with Skia.""" 11 12 13 class PDFiumFlavorUtils(default_flavor.DefaultFlavorUtils): 14 15 def compile(self, target): 16 """Build PDFium with Skia.""" 17 pdfium_dir = self.m.vars.checkout_root.join('pdfium') 18 19 # Runhook to generate the gn binary in buildtools. 20 with self.m.context(cwd=pdfium_dir): 21 # TODO(borenet): Remove this hack and replace with 22 # 'self.m.gclient.runhooks()' after the transition to Kitchen: 23 # https://bugs.chromium.org/p/skia/issues/detail?id=7050 24 depot_tools = self.m.vars.checkout_root.join('depot_tools') 25 self.m.git.checkout( 26 'https://chromium.googlesource.com/chromium/tools/depot_tools.git', 27 dir_path=depot_tools, ref='master') 28 self.m.run( 29 self.m.step, 30 'runhook', 31 cmd=[depot_tools.join('gclient'), 'runhook', 'gn_linux64']) 32 33 # Install the sysroot. 34 self.m.run( 35 self.m.step, 36 'sysroot', 37 cmd=['python', 'build/linux/sysroot_scripts/install-sysroot.py', 38 '--arch=amd64']) 39 40 # Setup gn args. 41 gn_args = [ 42 'pdf_is_standalone=true', 43 'clang_use_chrome_plugins=false', 44 'is_component_build=false', 45 'is_debug=false', 46 ] 47 if 'SkiaPaths' in self.m.vars.builder_name: 48 gn_args.append('pdf_use_skia_paths=true') 49 else: 50 gn_args.append('pdf_use_skia=true') 51 52 53 env = self.m.context.env 54 env['CHROMIUM_BUILDTOOLS_PATH'] = str(pdfium_dir.join('buildtools')) 55 with self.m.context(env=env): 56 self.m.run( 57 self.m.step, 58 'gn_gen', 59 cmd=['gn', 'gen', 'out/skia', '--args=%s' % ' '.join(gn_args)]) 60 61 # Build PDFium. 62 self.m.run( 63 self.m.step, 64 'build_pdfium', 65 cmd=['ninja', '-C', 'out/skia', '-j100']) 66