Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions scripts/update_cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ def old_chrome(chrome_milestone):
return str(int(new_chrome(chrome_milestone)) - 3)


def flatten_browser_pdl(file_path, chrome_version):
"""Fetches all included domain .pdl files and concatenates them."""
with open(file_path, "r") as file:
content = file.read()
# Find all include lines
includes = re.findall(r"include domains/([A-Za-z0-9_]+\.pdl)", content)
base_url = f"https://raw.githubusercontent.com/chromium/chromium/{chrome_version}/third_party/blink/public/devtools_protocol/domains/"
concatenated = ""
for domain_file in includes:
url = base_url + domain_file
response = http.request("GET", url)
concatenated += response.data.decode("utf-8") + "\n"
# Overwrite the file with concatenated domains
with open(file_path, "w") as file:
file.write(concatenated)


def add_pdls(chrome_milestone):
source_dir = (
root_dir / f"common/devtools/chromium/v{previous_chrome(chrome_milestone)}"
Expand All @@ -84,6 +101,10 @@ def add_pdls(chrome_milestone):
f"{target_dir}/browser_protocol.pdl",
)

flatten_browser_pdl(
f"{target_dir}/browser_protocol.pdl", chrome_milestone["version"]
)

deps_content = http.request(
"GET",
f"https://raw.githubusercontent.com/chromium/chromium/{chrome_milestone['version']}/DEPS",
Expand Down
Loading