OLD | NEW |
1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
2 # | 2 # |
3 # Use of this source code is governed by a BSD-style license | 3 # Use of this source code is governed by a BSD-style license |
4 # that can be found in the LICENSE file in the root of the source | 4 # that can be found in the LICENSE file in the root of the source |
5 # tree. An additional intellectual property rights grant can be found | 5 # tree. An additional intellectual property rights grant can be found |
6 # in the file PATENTS. All contributing project authors may | 6 # in the file PATENTS. All contributing project authors may |
7 # be found in the AUTHORS file in the root of the source tree. | 7 # be found in the AUTHORS file in the root of the source tree. |
8 | 8 |
9 import json | 9 import json |
10 import os | 10 import os |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 input_api, output_api)) | 568 input_api, output_api)) |
569 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api)) | 569 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api)) |
570 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 570 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
571 results.extend(_CheckNoPragmaOnce(input_api, output_api)) | 571 results.extend(_CheckNoPragmaOnce(input_api, output_api)) |
572 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) | 572 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) |
573 results.extend(_CheckGnChanges(input_api, output_api)) | 573 results.extend(_CheckGnChanges(input_api, output_api)) |
574 results.extend(_CheckUnwantedDependencies(input_api, output_api)) | 574 results.extend(_CheckUnwantedDependencies(input_api, output_api)) |
575 results.extend(_CheckJSONParseErrors(input_api, output_api)) | 575 results.extend(_CheckJSONParseErrors(input_api, output_api)) |
576 results.extend(_RunPythonTests(input_api, output_api)) | 576 results.extend(_RunPythonTests(input_api, output_api)) |
577 results.extend(_CheckUsageOfGoogleProtobufNamespace(input_api, output_api)) | 577 results.extend(_CheckUsageOfGoogleProtobufNamespace(input_api, output_api)) |
| 578 results.extend(_CheckOrphanHeaders(input_api, output_api)) |
578 return results | 579 return results |
579 | 580 |
580 | 581 |
581 def CheckChangeOnUpload(input_api, output_api): | 582 def CheckChangeOnUpload(input_api, output_api): |
582 results = [] | 583 results = [] |
583 results.extend(_CommonChecks(input_api, output_api)) | 584 results.extend(_CommonChecks(input_api, output_api)) |
584 results.extend( | 585 results.extend( |
585 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) | 586 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) |
586 return results | 587 return results |
587 | 588 |
588 | 589 |
589 def CheckChangeOnCommit(input_api, output_api): | 590 def CheckChangeOnCommit(input_api, output_api): |
590 results = [] | 591 results = [] |
591 results.extend(_CommonChecks(input_api, output_api)) | 592 results.extend(_CommonChecks(input_api, output_api)) |
592 results.extend(_VerifyNativeApiHeadersListIsValid(input_api, output_api)) | 593 results.extend(_VerifyNativeApiHeadersListIsValid(input_api, output_api)) |
593 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) | 594 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) |
594 results.extend(input_api.canned_checks.CheckChangeWasUploaded( | 595 results.extend(input_api.canned_checks.CheckChangeWasUploaded( |
595 input_api, output_api)) | 596 input_api, output_api)) |
596 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 597 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
597 input_api, output_api)) | 598 input_api, output_api)) |
598 results.extend(_CheckChangeHasBugField(input_api, output_api)) | 599 results.extend(_CheckChangeHasBugField(input_api, output_api)) |
599 results.extend(input_api.canned_checks.CheckChangeHasTestField( | 600 results.extend(input_api.canned_checks.CheckChangeHasTestField( |
600 input_api, output_api)) | 601 input_api, output_api)) |
601 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 602 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
602 input_api, output_api, | 603 input_api, output_api, |
603 json_url='http://webrtc-status.appspot.com/current?format=json')) | 604 json_url='http://webrtc-status.appspot.com/current?format=json')) |
604 return results | 605 return results |
| 606 |
| 607 |
| 608 def _CheckOrphanHeaders(input_api, output_api): |
| 609 # We need to wait until we have an input_api object and use this |
| 610 # roundabout construct to import prebubmit_checks_lib because this file is |
| 611 # eval-ed and thus doesn't have __file__. |
| 612 error_msg = """Header file {} is not listed in any GN target. |
| 613 Please create a target or add it to an existing one in {}""" |
| 614 results = [] |
| 615 original_sys_path = sys.path |
| 616 try: |
| 617 sys.path = sys.path + [input_api.os_path.join( |
| 618 input_api.PresubmitLocalPath(), 'tools_webrtc', 'presubmit_checks_lib')] |
| 619 from check_orphan_headers import GetBuildGnPathFromFilePath |
| 620 from check_orphan_headers import IsHeaderInBuildGn |
| 621 finally: |
| 622 # Restore sys.path to what it was before. |
| 623 sys.path = original_sys_path |
| 624 |
| 625 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): |
| 626 if f.LocalPath().endswith('.h'): |
| 627 file_path = os.path.abspath(f.LocalPath()) |
| 628 root_dir = os.getcwd() |
| 629 gn_file_path = GetBuildGnPathFromFilePath(file_path, os.path.exists, |
| 630 root_dir) |
| 631 in_build_gn = IsHeaderInBuildGn(file_path, gn_file_path) |
| 632 if not in_build_gn: |
| 633 results.append(output_api.PresubmitError(error_msg.format( |
| 634 file_path, gn_file_path))) |
| 635 return results |
OLD | NEW |