Avi Drissman | 04c79e10 | 2022-10-06 18:59:02 | [diff] [blame] | 1 | # Copyright 2011 The Chromium Authors |
thakis@chromium.org | 99f1a48 | 2011-04-12 00:11:23 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
Dan Harrington | b60e1aa | 2019-11-20 08:48:54 | [diff] [blame] | 5 | import os |
| 6 | |
Dan Le Febvre | 7c5784d | 2022-11-10 07:07:41 | [diff] [blame] | 7 | PRESUBMIT_VERSION = '2.0.0' |
| 8 | |
Anne Redulla | 4f87551 | 2023-09-20 07:46:39 | [diff] [blame] | 9 | |
| 10 | def CheckThirdPartyMetadataFiles(input_api, output_api): |
| 11 | """Checks that third party metadata files are correctly formatted |
| 12 | and valid. |
| 13 | """ |
| 14 | def readme_filter(f): |
| 15 | local_path = f.LocalPath() |
| 16 | |
| 17 | # Limit to README.chromium files within //third_party/. |
| 18 | if (not local_path.endswith('README.chromium') |
| 19 | or not local_path.startswith('third_party' + input_api.os_path.sep)): |
| 20 | return False |
| 21 | |
| 22 | # Some folders are currently exempt from being checked. |
| 23 | skip_dirs = ( |
| 24 | ('third_party', 'blink'), |
| 25 | ('third_party', 'boringssl'), |
| 26 | ('third_party', 'closure_compiler', 'externs'), |
| 27 | ('third_party', 'closure_compiler', 'interfaces'), |
| 28 | ('third_party', 'feed_library'), |
| 29 | ('third_party', 'ipcz'), |
Sam Maier | 2e94220 | 2024-01-24 17:52:55 | [diff] [blame] | 30 | ('third_party', 'jni_zero'), |
Anne Redulla | 4f87551 | 2023-09-20 07:46:39 | [diff] [blame] | 31 | # TODO(danakj): We should look for the README.chromium file in |
| 32 | # third_party/rust/CRATE_NAME/vVERSION/. |
| 33 | ('third_party', 'rust'), |
| 34 | ('third_party', 'webxr_test_pages'), |
| 35 | ) |
| 36 | for path in skip_dirs: |
| 37 | prefix = ''.join([dir_name + input_api.os_path.sep for dir_name in path]) |
| 38 | if local_path.startswith(prefix): |
| 39 | return False |
| 40 | |
| 41 | return True |
| 42 | |
| 43 | return input_api.canned_checks.CheckChromiumDependencyMetadata( |
| 44 | input_api, output_api, file_filter=readme_filter) |