Skip to content

Commit 1fbbdf1

Browse files
committed
Fetching all browser_protocol.pdl includes and concatenating them.
1 parent 3bace2e commit 1fbbdf1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

scripts/update_cdp.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,23 @@ def old_chrome(chrome_milestone):
6464
return str(int(new_chrome(chrome_milestone)) - 3)
6565

6666

67+
def flatten_browser_pdl(file_path, chrome_version):
68+
"""Fetches all included domain .pdl files and concatenates them."""
69+
with open(file_path, "r") as file:
70+
content = file.read()
71+
# Find all include lines
72+
includes = re.findall(r"include domains/([A-Za-z0-9_]+\.pdl)", content)
73+
base_url = f"https://raw.githubusercontent.com/chromium/chromium/{chrome_version}/third_party/blink/public/devtools_protocol/domains/"
74+
concatenated = ""
75+
for domain_file in includes:
76+
url = base_url + domain_file
77+
response = http.request("GET", url)
78+
concatenated += response.data.decode("utf-8") + "\n"
79+
# Overwrite the file with concatenated domains
80+
with open(file_path, "w") as file:
81+
file.write(concatenated)
82+
83+
6784
def add_pdls(chrome_milestone):
6885
source_dir = (
6986
root_dir / f"common/devtools/chromium/v{previous_chrome(chrome_milestone)}"
@@ -84,6 +101,10 @@ def add_pdls(chrome_milestone):
84101
f"{target_dir}/browser_protocol.pdl",
85102
)
86103

104+
flatten_browser_pdl(
105+
f"{target_dir}/browser_protocol.pdl", chrome_milestone["version"]
106+
)
107+
87108
deps_content = http.request(
88109
"GET",
89110
f"https://raw.githubusercontent.com/chromium/chromium/{chrome_milestone['version']}/DEPS",

0 commit comments

Comments
 (0)