OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 """Presubmit script for pdfium. | 5 """Presubmit script for pdfium. |
6 | 6 |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
8 for more details about the presubmit API built into depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
9 """ | 9 """ |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 # We need to wait until we have an input_api object and use this | 43 # We need to wait until we have an input_api object and use this |
44 # roundabout construct to import checkdeps because this file is | 44 # roundabout construct to import checkdeps because this file is |
45 # eval-ed and thus doesn't have __file__. | 45 # eval-ed and thus doesn't have __file__. |
46 original_sys_path = sys.path | 46 original_sys_path = sys.path |
47 try: | 47 try: |
48 sys.path = sys.path + [input_api.os_path.join( | 48 sys.path = sys.path + [input_api.os_path.join( |
49 input_api.PresubmitLocalPath(), 'buildtools', 'checkdeps')] | 49 input_api.PresubmitLocalPath(), 'buildtools', 'checkdeps')] |
50 import checkdeps | 50 import checkdeps |
51 from cpp_checker import CppChecker | 51 from cpp_checker import CppChecker |
52 from rules import Rule | 52 from rules import Rule |
| 53 except ImportError: |
| 54 return [output_api.PresubmitError( |
| 55 'Unable to run checkdeps, does pdfium/buildtools/checkdeps exist?')] |
53 finally: | 56 finally: |
54 # Restore sys.path to what it was before. | 57 # Restore sys.path to what it was before. |
55 sys.path = original_sys_path | 58 sys.path = original_sys_path |
56 | 59 |
57 added_includes = [] | 60 added_includes = [] |
58 for f in input_api.AffectedFiles(): | 61 for f in input_api.AffectedFiles(): |
59 if not CppChecker.IsCppFile(f.LocalPath()): | 62 if not CppChecker.IsCppFile(f.LocalPath()): |
60 continue | 63 continue |
61 | 64 |
62 changed_lines = [line for line_num, line in f.ChangedContents()] | 65 changed_lines = [line for line_num, line in f.ChangedContents()] |
(...skipping 26 matching lines...) Expand all Loading... |
89 | 92 |
90 | 93 |
91 def CheckChangeOnUpload(input_api, output_api): | 94 def CheckChangeOnUpload(input_api, output_api): |
92 results = [] | 95 results = [] |
93 results += _CheckUnwantedDependencies(input_api, output_api) | 96 results += _CheckUnwantedDependencies(input_api, output_api) |
94 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api) | 97 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api) |
95 results += input_api.canned_checks.CheckChangeLintsClean( | 98 results += input_api.canned_checks.CheckChangeLintsClean( |
96 input_api, output_api, None, LINT_FILTERS) | 99 input_api, output_api, None, LINT_FILTERS) |
97 | 100 |
98 return results | 101 return results |
OLD | NEW |