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
66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
# Copyright Advanced Micro Devices, Inc.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
# patch_third_party_source.py is designed to act as the PATCH_COMMAND for
|
|
# therock_subproject_fetch
|
|
# ExternalProject_Add
|
|
# from CMake.
|
|
# See https://cmake.org/cmake/help/latest/module/ExternalProject.html#patch-step-options
|
|
#
|
|
# SYNOPSIS: patch_third_party_source.py PATCHES_DIR
|
|
#
|
|
# Uses `patch -p1 -i PATCH` for the actual patching.
|
|
# Assumes the current working directory is the source directory of the extracted tarball.
|
|
|
|
import sys
|
|
import os
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
def run_command(cmd_list, cwd=None):
|
|
print(f"\n--- Executing: {' '.join(map(str, cmd_list))} ---", flush=True)
|
|
try:
|
|
process = subprocess.run(cmd_list, cwd=cwd, check=True, text=True)
|
|
except FileNotFoundError:
|
|
print(
|
|
f"ERROR: Command not found: {cmd_list[0]}. Is it installed and in PATH?",
|
|
file=sys.stderr,
|
|
)
|
|
sys.exit(1)
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"ERROR: Command failed with exit code {e.returncode}", file=sys.stderr)
|
|
sys.exit(e.returncode)
|
|
except Exception as e:
|
|
print(f"ERROR: An unexpected error occurred: {e}", file=sys.stderr)
|
|
sys.exit(1)
|
|
return process
|
|
|
|
|
|
def create_stamp_file(filename):
|
|
with open(filename, "w") as f:
|
|
pass
|
|
|
|
|
|
def main(args):
|
|
try:
|
|
(patches_dir,) = args
|
|
except ValueError:
|
|
sys.stderr.write("usage: patch_third_party_source PATCHES_DIR\n")
|
|
sys.exit(2)
|
|
|
|
stamp_filename = "patch_third_party_source.stamp"
|
|
if os.path.exists(stamp_filename):
|
|
sys.exit(0)
|
|
|
|
patches = sorted(os.listdir(patches_dir))
|
|
patches_dir = Path(patches_dir)
|
|
for i in patches:
|
|
p = patches_dir / i
|
|
run_command(["patch", "-p1", "-i", p])
|
|
create_stamp_file(stamp_filename)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main(sys.argv[1:])
|