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 self.m.run( 22 self.m.step, 23 'runhook', 24 cmd=['gclient', 'runhook', 'gn_linux64']) 25 26 # Install the sysroot. 27 self.m.run( 28 self.m.step, 29 'sysroot', 30 cmd=['python', 'build/linux/sysroot_scripts/install-sysroot.py', 31 '--arch=amd64']) 32 33 # Setup gn args. 34 gn_args = [ 35 'pdf_is_standalone=true', 36 'clang_use_chrome_plugins=false', 37 'is_component_build=false', 38 'is_debug=false', 39 ] 40 if 'SkiaPaths' in self.m.vars.builder_name: 41 gn_args.append('pdf_use_skia_paths=true') 42 else: 43 gn_args.append('pdf_use_skia=true') 44 45 46 env = self.m.context.env 47 env['CHROMIUM_BUILDTOOLS_PATH'] = str(pdfium_dir.join('buildtools')) 48 with self.m.context(env=env): 49 self.m.run( 50 self.m.step, 51 'gn_gen', 52 cmd=['gn', 'gen', 'out/skia', '--args=%s' % ' '.join(gn_args)]) 53 54 # Build PDFium. 55 self.m.run( 56 self.m.step, 57 'build_pdfium', 58 cmd=['ninja', '-C', 'out/skia', '-j100']) 59