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