OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import re | 5 import re |
6 | 6 |
7 import default_flavor | 7 import default_flavor |
8 | 8 |
9 | 9 |
10 """PDFium flavor utils, used for building PDFium with Skia.""" | 10 """PDFium flavor utils, used for building PDFium with Skia.""" |
11 | 11 |
12 | 12 |
13 class PDFiumFlavorUtils(default_flavor.DefaultFlavorUtils): | 13 class PDFiumFlavorUtils(default_flavor.DefaultFlavorUtils): |
14 | 14 |
15 def compile(self, target): | 15 def compile(self, target, **kwargs): |
16 """Build PDFium with Skia.""" | 16 """Build PDFium with Skia.""" |
17 pdfium_dir = self.m.vars.checkout_root.join('pdfium') | 17 pdfium_dir = self.m.vars.checkout_root.join('pdfium') |
18 | 18 |
19 # Runhook to generate the gn binary in buildtools. | 19 # Runhook to generate the gn binary in buildtools. |
20 self.m.run( | 20 self.m.run( |
21 self.m.step, | 21 self.m.step, |
22 'runhook', | 22 'runhook', |
23 cmd=['gclient', 'runhook', 'gn_linux64'], | 23 cmd=['gclient', 'runhook', 'gn_linux64'], |
24 cwd=pdfium_dir) | 24 cwd=pdfium_dir, |
| 25 **kwargs) |
25 | 26 |
26 # Setup gn args. | 27 # Setup gn args. |
27 gn_args = ['pdf_use_skia=true', 'pdf_is_standalone=true', | 28 gn_args = ['pdf_use_skia=true', 'pdf_is_standalone=true', |
28 'clang_use_chrome_plugins=false'] | 29 'clang_use_chrome_plugins=false'] |
| 30 env = kwargs.pop('env', {}) |
| 31 env['CHROMIUM_BUILDTOOLS_PATH'] = str(pdfium_dir.join('buildtools')) |
29 self.m.run( | 32 self.m.run( |
30 self.m.step, | 33 self.m.step, |
31 'gn_gen', | 34 'gn_gen', |
32 cmd=['gn', 'gen', 'out/skia', '--args=%s' % ' '.join(gn_args)], | 35 cmd=['gn', 'gen', 'out/skia', '--args=%s' % ' '.join(gn_args)], |
33 cwd=pdfium_dir, | 36 cwd=pdfium_dir, |
34 env={'CHROMIUM_BUILDTOOLS_PATH': str(pdfium_dir.join('buildtools'))}) | 37 env=env) |
35 | 38 |
36 # Modify DEPS file to contain the current Skia revision. | 39 # Modify DEPS file to contain the current Skia revision. |
37 skia_revision = self.m.vars.got_revision | 40 skia_revision = self.m.vars.got_revision |
38 deps_file = pdfium_dir.join('DEPS') | 41 deps_file = pdfium_dir.join('DEPS') |
39 test_data = "'skia_revision': 'abc'" | 42 test_data = "'skia_revision': 'abc'" |
40 | 43 |
41 original_contents = self.m.file.read( | 44 original_contents = self.m.file.read( |
42 'read PDFium DEPS', deps_file, test_data=test_data, infra_step=True) | 45 'read PDFium DEPS', deps_file, test_data=test_data, infra_step=True) |
43 | 46 |
44 deps_skia_regexp = re.compile( | 47 deps_skia_regexp = re.compile( |
45 r'(?<=["\']skia_revision["\']: ["\'])([a-fA-F0-9]+)(?=["\'])', | 48 r'(?<=["\']skia_revision["\']: ["\'])([a-fA-F0-9]+)(?=["\'])', |
46 re.MULTILINE) | 49 re.MULTILINE) |
47 patched_contents = re.sub(deps_skia_regexp, str(skia_revision), | 50 patched_contents = re.sub(deps_skia_regexp, str(skia_revision), |
48 original_contents) | 51 original_contents) |
49 self.m.file.write('write PDFium DEPs', deps_file, | 52 self.m.file.write('write PDFium DEPs', deps_file, |
50 patched_contents, infra_step=True) | 53 patched_contents, infra_step=True) |
51 | 54 |
52 # gclient sync after updating DEPS. | 55 # gclient sync after updating DEPS. |
53 self.m.run( | 56 self.m.run( |
54 self.m.step, | 57 self.m.step, |
55 'sync_pdfium', | 58 'sync_pdfium', |
56 cmd=['gclient', 'sync'], | 59 cmd=['gclient', 'sync'], |
57 cwd=pdfium_dir) | 60 cwd=pdfium_dir) |
58 | 61 |
59 # Build PDFium. | 62 # Build PDFium. |
60 self.m.run( | 63 self.m.run( |
61 self.m.step, | 64 self.m.step, |
62 'build_pdfium', | 65 'build_pdfium', |
63 cmd=['ninja', '-C', 'out/skia', '-j100'], | 66 cmd=['ninja', '-C', 'out/skia', '-j100'], |
64 cwd=pdfium_dir) | 67 cwd=pdfium_dir, |
| 68 env=env, |
| 69 **kwargs) |
OLD | NEW |