CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
94 lines
3.2 KiB
Python
94 lines
3.2 KiB
Python
# Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
import re
|
|
|
|
|
|
# Remove the text between the first occurance of start and the first occurrence of stop,
|
|
# after start, where stop and start are compiled regex patterns.
|
|
def remove_between_regex(text, start_regex, stop_regex):
|
|
start_match = start_regex.search(text)
|
|
if start_match:
|
|
stop_match = stop_regex.search(text, start_match.end())
|
|
if stop_match:
|
|
return text[: start_match.start()] + text[stop_match.end() :]
|
|
return text
|
|
|
|
|
|
# Repeatedly remove text between the first occurance of start and the first occurrence
|
|
# of stop, after start, until there are no more starts and stops, where stop and start
|
|
# are compiled regex patterns.
|
|
def remove_all_between_regex(text, start_regex, stop_regex):
|
|
while True:
|
|
start_match = start_regex.search(text)
|
|
if start_match:
|
|
stop_match = stop_regex.search(text, start_match.end())
|
|
if start_match and stop_match:
|
|
text = text[: start_match.start()] + text[stop_match.end() :]
|
|
else:
|
|
break
|
|
return text
|
|
|
|
|
|
# Remove the text between the first occurance of start and the first occurrence of stop,
|
|
# after start.
|
|
def remove_between(text, start, stop):
|
|
return remove_between_regex(
|
|
text,
|
|
re.compile(re.escape(start)),
|
|
re.compile(re.escape(stop)),
|
|
)
|
|
|
|
|
|
# Repeatedly remove the text between the first occurance of start and the first
|
|
# occurrence of stop, after start, until there are no more starts and stops.
|
|
def remove_all_between(text, start, stop):
|
|
return remove_all_between_regex(
|
|
text,
|
|
re.compile(re.escape(start)),
|
|
re.compile(re.escape(stop)),
|
|
)
|
|
|
|
|
|
# Get the text between the first occurance of start and the first occurrence of stop,
|
|
# after start, where stop and start are compiled regex patterns.
|
|
def get_between_regex(text, start_regex, stop_regex):
|
|
start_match = start_regex.search(text)
|
|
if start_match:
|
|
stop_match = stop_regex.search(text, start_match.end())
|
|
if start_match and stop_match:
|
|
return text[start_match.end() : stop_match.start()]
|
|
return ""
|
|
|
|
|
|
# Get the text between the first occurance of start and the first occurrence of stop,
|
|
# after start.
|
|
def get_between(text, start, stop):
|
|
return get_between_regex(
|
|
text,
|
|
re.compile(re.escape(start)),
|
|
re.compile(re.escape(stop)),
|
|
)
|
|
|
|
|
|
# Clean up all of the lines by removing comments and whitespace
|
|
def clean_lines(source_lines, leave_comments):
|
|
comment_start = re.compile(r"/\*")
|
|
comment_end = re.compile(r"\*/")
|
|
meta_start = re.compile(r"\.amdgpu_metadata")
|
|
meta_end = re.compile(r"\.end_amdgpu_metadata")
|
|
result = []
|
|
full_text = "\n".join(source_lines)
|
|
if not leave_comments:
|
|
full_text = remove_all_between_regex(full_text, comment_start, comment_end)
|
|
full_text = remove_all_between_regex(full_text, meta_start, meta_end)
|
|
source_lines = full_text.split("\n")
|
|
for my_line in source_lines:
|
|
if not leave_comments and "//" in my_line:
|
|
my_line = my_line[0 : my_line.find("//")]
|
|
my_line = my_line.strip()
|
|
my_line = my_line.replace("\\", "\\\\")
|
|
if my_line:
|
|
result += [my_line]
|
|
return result
|