OLD | NEW |
| (Empty) |
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._skia_api.checkout_root.join('pdfium') | |
18 | |
19 # Runhook to generate the gn binary in buildtools. | |
20 self._skia_api.run( | |
21 self._skia_api.m.step, | |
22 'runhook', | |
23 cmd=['gclient', 'runhook', 'gn_linux64'], | |
24 cwd=pdfium_dir) | |
25 | |
26 # Setup gn args. | |
27 gn_args = ['pdf_use_skia=true', 'pdf_is_standalone=true', | |
28 'clang_use_chrome_plugins=false'] | |
29 self._skia_api.run( | |
30 self._skia_api.m.step, | |
31 'gn_gen', | |
32 cmd=['gn', 'gen', 'out/skia', '--args=%s' % ' '.join(gn_args)], | |
33 cwd=pdfium_dir, | |
34 env={'CHROMIUM_BUILDTOOLS_PATH': str(pdfium_dir.join('buildtools'))}) | |
35 | |
36 # Modify DEPS file to contain the current Skia revision. | |
37 skia_revision = self._skia_api.got_revision | |
38 deps_file = pdfium_dir.join('DEPS') | |
39 test_data = "'skia_revision': 'abc'" | |
40 | |
41 original_contents = self._skia_api.m.file.read( | |
42 'read PDFium DEPS', deps_file, test_data=test_data, infra_step=True) | |
43 | |
44 deps_skia_regexp = re.compile( | |
45 r'(?<=["\']skia_revision["\']: ["\'])([a-fA-F0-9]+)(?=["\'])', | |
46 re.MULTILINE) | |
47 patched_contents = re.sub(deps_skia_regexp, str(skia_revision), | |
48 original_contents) | |
49 self._skia_api.m.file.write('write PDFium DEPs', deps_file, | |
50 patched_contents, infra_step=True) | |
51 | |
52 # gclient sync after updating DEPS. | |
53 self._skia_api.run( | |
54 self._skia_api.m.step, | |
55 'sync_pdfium', | |
56 cmd=['gclient', 'sync'], | |
57 cwd=pdfium_dir) | |
58 | |
59 # Build PDFium. | |
60 self._skia_api.run( | |
61 self._skia_api.m.step, | |
62 'build_pdfium', | |
63 cmd=['ninja', '-C', 'out/skia', '-j100'], | |
64 cwd=pdfium_dir) | |
OLD | NEW |