Liviu Rau | 3da5d4a | 2022-02-23 11:07:12 | [diff] [blame] | 1 | #!/usr/bin/env vpython3 |
Tim van der Lippe | dcc95c9 | 2022-01-17 12:14:06 | [diff] [blame] | 2 | # -*- coding: UTF-8 -*- |
| 3 | # |
| 4 | # Copyright 2022 The Chromium Authors. All rights reserved. |
| 5 | # Use of this source code is governed by a BSD-style license that can be |
| 6 | # found in the LICENSE file. |
| 7 | """ |
| 8 | Asserts that all third_party packages are included in additional_readme_paths.json. |
| 9 | """ |
| 10 | |
| 11 | import sys |
| 12 | import json |
| 13 | |
| 14 | |
| 15 | def main(argv): |
| 16 | grd_sources = open(argv[1], 'r').read() |
| 17 | listed_third_party_directories = open(argv[2], 'r').read() |
| 18 | stamp_file = argv[3] |
| 19 | |
| 20 | grd_json = json.loads(grd_sources) |
| 21 | listed_third_party_directories_json = json.loads( |
| 22 | listed_third_party_directories) |
| 23 | |
| 24 | grd_json.sort() |
| 25 | listed_third_party_directories_json.sort() |
| 26 | |
| 27 | return_code = 0 |
| 28 | found_directories = set() |
| 29 | missing_directories = set() |
| 30 | |
| 31 | for grd_file in grd_json: |
| 32 | if grd_file.startswith("front_end/third_party"): |
| 33 | third_party_directory_name = grd_file.split("/")[2] |
| 34 | found_directories.add(third_party_directory_name) |
| 35 | if third_party_directory_name not in listed_third_party_directories_json: |
| 36 | missing_directories.add(third_party_directory_name) |
| 37 | |
| 38 | for missing_directory in missing_directories: |
| 39 | print( |
| 40 | "Directory `" + missing_directory + "`" + |
| 41 | " is not listed in the `additional_readme_paths.json` file " + |
| 42 | " in `front_end/third_party`. Make sure to include all third_party" |
| 43 | + |
| 44 | " directories in the `.json` file to ensure all licenses are listed" |
| 45 | + " in chrome://credits.\n") |
| 46 | |
| 47 | return_code = 1 |
| 48 | |
| 49 | for listed_directory in listed_third_party_directories_json: |
| 50 | if (listed_directory not in found_directories |
| 51 | # TODO(crbug.com/1287519): Remove exception for codemirror 5 |
Tim van der Lippe | f2adc90 | 2022-01-20 13:37:54 | [diff] [blame] | 52 | and not listed_directory == "codemirror" |
| 53 | and not listed_directory == "puppeteer"): |
Tim van der Lippe | dcc95c9 | 2022-01-17 12:14:06 | [diff] [blame] | 54 | print( |
| 55 | "Directory `" + listed_directory + "`" + |
| 56 | " is not included in `config/gni/devtools_grd_files.gni`." + |
Alex Rudenko | 4c118bf | 2022-02-22 12:34:39 | [diff] [blame] | 57 | " Make sure to only include third_party directories that are shipped" |
Tim van der Lippe | dcc95c9 | 2022-01-17 12:14:06 | [diff] [blame] | 58 | + " in Chromium.\n") |
| 59 | |
| 60 | return_code = 1 |
| 61 | |
| 62 | with open(stamp_file, 'w', encoding="utf8") as fp: |
| 63 | fp.write("") |
| 64 | |
| 65 | return return_code |
| 66 | |
| 67 | |
| 68 | if __name__ == '__main__': |
| 69 | sys.exit(main(sys.argv)) |