blob: 315d09e8cf5c6d812eae4df2a74e3a23ac1563ca [file] [log] [blame]
Liviu Rau3da5d4a2022-02-23 11:07:121#!/usr/bin/env vpython3
Tim van der Lippedcc95c92022-01-17 12:14:062# -*- 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"""
8Asserts that all third_party packages are included in additional_readme_paths.json.
9"""
10
11import sys
12import json
13
14
15def 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 Lippef2adc902022-01-20 13:37:5452 and not listed_directory == "codemirror"
53 and not listed_directory == "puppeteer"):
Tim van der Lippedcc95c92022-01-17 12:14:0654 print(
55 "Directory `" + listed_directory + "`" +
56 " is not included in `config/gni/devtools_grd_files.gni`." +
Alex Rudenko4c118bf2022-02-22 12:34:3957 " Make sure to only include third_party directories that are shipped"
Tim van der Lippedcc95c92022-01-17 12:14:0658 + " 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
68if __name__ == '__main__':
69 sys.exit(main(sys.argv))