| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Helper script for PPAPI's PRESUBMIT.py to detect if additions or removals of | 6 """Helper script for PPAPI's PRESUBMIT.py to detect if additions or removals of |
| 7 PPAPI interfaces have been propagated to the Native Client libraries (.dsc | 7 PPAPI interfaces have been propagated to the Native Client libraries (.dsc |
| 8 files). | 8 files). |
| 9 | 9 |
| 10 For example, if a user adds "ppapi/c/foo.h", we check that the interface has | 10 For example, if a user adds "ppapi/c/foo.h", we check that the interface has |
| 11 been added to "native_client_sdk/src/libraries/ppapi/library.dsc". | 11 been added to "native_client_sdk/src/libraries/ppapi/library.dsc". |
| 12 """ | 12 """ |
| 13 | 13 |
| 14 import optparse | 14 import argparse |
| 15 import os | 15 import os |
| 16 import sys | 16 import sys |
| 17 | 17 |
| 18 from build_paths import PPAPI_DIR, SRC_DIR, SDK_LIBRARY_DIR | 18 from build_paths import PPAPI_DIR, SRC_DIR, SDK_LIBRARY_DIR |
| 19 import parse_dsc | 19 import parse_dsc |
| 20 | 20 |
| 21 | 21 |
| 22 # Add a file to this list if it should not be added to a .dsc file; i.e. if it | 22 # Add a file to this list if it should not be added to a .dsc file; i.e. if it |
| 23 # should not be included in the Native Client SDK. This will silence the | 23 # should not be included in the Native Client SDK. This will silence the |
| 24 # presubmit warning. | 24 # presubmit warning. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 'Should they be added to the Native Client SDK? <<<\n') | 160 'Should they be added to the Native Client SDK? <<<\n') |
| 161 if not e.unexpected: | 161 if not e.unexpected: |
| 162 should_fail = False | 162 should_fail = False |
| 163 sys.stderr.write(str(e) + '\n') | 163 sys.stderr.write(str(e) + '\n') |
| 164 if should_fail: | 164 if should_fail: |
| 165 return False | 165 return False |
| 166 return True | 166 return True |
| 167 | 167 |
| 168 | 168 |
| 169 def main(args): | 169 def main(args): |
| 170 usage = '%prog <file>...' | 170 parser = argparse.ArgumentParser(description=__doc__) |
| 171 description = __doc__ | 171 parser.add_argument('sources', nargs='+') |
| 172 parser = optparse.OptionParser(usage=usage, description=description) | 172 options = parser.parse_args(args) |
| 173 args = parser.parse_args(args)[1] | |
| 174 if not args: | |
| 175 parser.error('Expected a PPAPI header or source file.') | |
| 176 | 173 |
| 177 retval = 0 | 174 retval = 0 |
| 178 lib_files = PartitionFiles(args) | 175 lib_files = PartitionFiles(options.sources) |
| 179 directory_list = GetDirectoryList(PPAPI_DIR, relative_to=SRC_DIR) | 176 directory_list = GetDirectoryList(PPAPI_DIR, relative_to=SRC_DIR) |
| 180 for lib_name, filenames in lib_files.iteritems(): | 177 for lib_name, filenames in lib_files.iteritems(): |
| 181 if not filenames: | 178 if not filenames: |
| 182 continue | 179 continue |
| 183 | 180 |
| 184 changed_filenames, removed_filenames = \ | 181 changed_filenames, removed_filenames = \ |
| 185 GetChangedAndRemovedFilenames(filenames, directory_list) | 182 GetChangedAndRemovedFilenames(filenames, directory_list) |
| 186 | 183 |
| 187 dsc_filename = GetDscFilenameFromLibraryName(lib_name) | 184 dsc_filename = GetDscFilenameFromLibraryName(lib_name) |
| 188 dsc = parse_dsc.LoadProject(dsc_filename) | 185 dsc = parse_dsc.LoadProject(dsc_filename) |
| 189 dsc_sources_and_headers = GetDscSourcesAndHeaders(dsc) | 186 dsc_sources_and_headers = GetDscSourcesAndHeaders(dsc) |
| 190 | 187 |
| 191 # Use the relative path to the .dsc to make the error messages shorter. | 188 # Use the relative path to the .dsc to make the error messages shorter. |
| 192 rel_dsc_filename = os.path.relpath(dsc_filename, SRC_DIR) | 189 rel_dsc_filename = os.path.relpath(dsc_filename, SRC_DIR) |
| 193 is_private = lib_name == 'ppapi_cpp_private' | 190 is_private = lib_name == 'ppapi_cpp_private' |
| 194 if not VerifyOrPrintError(rel_dsc_filename, dsc_sources_and_headers, | 191 if not VerifyOrPrintError(rel_dsc_filename, dsc_sources_and_headers, |
| 195 changed_filenames, removed_filenames, | 192 changed_filenames, removed_filenames, |
| 196 is_private=is_private): | 193 is_private=is_private): |
| 197 retval = 1 | 194 retval = 1 |
| 198 return retval | 195 return retval |
| 199 | 196 |
| 200 | 197 |
| 201 if __name__ == '__main__': | 198 if __name__ == '__main__': |
| 202 sys.exit(main(sys.argv[1:])) | 199 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |