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
155 lines
5.0 KiB
Python
155 lines
5.0 KiB
Python
# Copyright Advanced Micro Devices, Inc.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
"""
|
|
This script runs the Linux and Windows build configurations
|
|
|
|
Required environment variables:
|
|
- amdgpu_families
|
|
- package_version
|
|
- extra_cmake_options
|
|
- BUILD_DIR
|
|
|
|
Optional environment variables:
|
|
- VCToolsInstallDir
|
|
- GITHUB_WORKSPACE
|
|
- EXTRA_C_COMPILER_LAUNCHER: Compiler launcher for C (e.g., resource_info.py for build
|
|
time analysis). If set, this replaces ccache as the launcher.
|
|
Note: resource_info.py automatically invokes ccache internally.
|
|
- EXTRA_CXX_COMPILER_LAUNCHER: Compiler launcher for CXX. Same behavior as above.
|
|
"""
|
|
|
|
import argparse
|
|
import logging
|
|
import os
|
|
from pathlib import Path
|
|
import platform
|
|
import shlex
|
|
import subprocess
|
|
|
|
from manylinux_config import DIST_PYTHON_EXECUTABLES, SHARED_PYTHON_EXECUTABLES
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
THIS_SCRIPT_DIR = Path(__file__).resolve().parent
|
|
THEROCK_DIR = THIS_SCRIPT_DIR.parent.parent
|
|
|
|
PLATFORM = platform.system().lower()
|
|
|
|
cmake_preset = os.getenv("cmake_preset")
|
|
amdgpu_families = os.getenv("amdgpu_families")
|
|
package_version = os.getenv("package_version")
|
|
extra_cmake_options = os.getenv("extra_cmake_options")
|
|
github_workspace = os.getenv("GITHUB_WORKSPACE")
|
|
extra_c_compiler_launcher = os.getenv("EXTRA_C_COMPILER_LAUNCHER", "")
|
|
extra_cxx_compiler_launcher = os.getenv("EXTRA_CXX_COMPILER_LAUNCHER", "")
|
|
|
|
# Normalize paths to use forward slashes for CMake compatibility on Windows
|
|
if extra_c_compiler_launcher:
|
|
extra_c_compiler_launcher = extra_c_compiler_launcher.replace("\\", "/")
|
|
if extra_cxx_compiler_launcher:
|
|
extra_cxx_compiler_launcher = extra_cxx_compiler_launcher.replace("\\", "/")
|
|
|
|
|
|
def build_compiler_launcher(
|
|
extra_launcher: str, default_launcher: str = "ccache"
|
|
) -> str:
|
|
"""Build compiler launcher string.
|
|
|
|
Args:
|
|
extra_launcher: Custom launcher to use (e.g., resource_info.py).
|
|
If provided, this replaces the default launcher entirely.
|
|
Note: resource_info.py automatically invokes ccache internally,
|
|
so no semicolon-separated list is needed.
|
|
default_launcher: Default launcher to use when extra_launcher is not set.
|
|
|
|
Returns:
|
|
Launcher string for CMake. If extra_launcher is provided, returns it directly.
|
|
Otherwise returns default_launcher.
|
|
|
|
Example:
|
|
build_compiler_launcher("/path/to/resource_info.py", "ccache")
|
|
-> "/path/to/resource_info.py"
|
|
|
|
build_compiler_launcher("", "ccache")
|
|
-> "ccache"
|
|
"""
|
|
if extra_launcher:
|
|
return extra_launcher
|
|
return default_launcher
|
|
|
|
|
|
platform_options = {
|
|
"windows": [
|
|
"-DTHEROCK_BACKGROUND_BUILD_JOBS=4",
|
|
],
|
|
}
|
|
|
|
|
|
def build_configure(build_dir, manylinux=False):
|
|
logging.info(f"Building package {package_version}")
|
|
|
|
cmd = [
|
|
"cmake",
|
|
"-B",
|
|
build_dir,
|
|
"-GNinja",
|
|
".",
|
|
]
|
|
if cmake_preset:
|
|
cmd.extend(["--preset", cmake_preset])
|
|
# Build compiler launcher strings (prepend extra launcher if provided)
|
|
c_launcher = build_compiler_launcher(extra_c_compiler_launcher)
|
|
cxx_launcher = build_compiler_launcher(extra_cxx_compiler_launcher)
|
|
|
|
cmd.extend(
|
|
[
|
|
f"-DTHEROCK_AMDGPU_FAMILIES={amdgpu_families}",
|
|
f"-DTHEROCK_PACKAGE_VERSION={package_version}",
|
|
f"-DCMAKE_C_COMPILER_LAUNCHER={c_launcher}",
|
|
f"-DCMAKE_CXX_COMPILER_LAUNCHER={cxx_launcher}",
|
|
"-DBUILD_TESTING=ON",
|
|
]
|
|
)
|
|
|
|
# Adding platform specific options
|
|
cmd += platform_options.get(PLATFORM, [])
|
|
|
|
# Adding manylinux Python executables if --manylinux is set
|
|
if manylinux:
|
|
cmd.append(f"-DTHEROCK_DIST_PYTHON_EXECUTABLES={DIST_PYTHON_EXECUTABLES}")
|
|
cmd.append("-DTHEROCK_ENABLE_SYSDEPS_AMD_MESA=ON")
|
|
cmd.append("-DTHEROCK_ENABLE_ROCDECODE=ON")
|
|
cmd.append("-DTHEROCK_ENABLE_ROCJPEG=ON")
|
|
|
|
# Python executables with shared libpython support. This is needed for
|
|
# ROCgdb.
|
|
cmd.append(f"-DTHEROCK_SHARED_PYTHON_EXECUTABLES={SHARED_PYTHON_EXECUTABLES}")
|
|
|
|
# Splitting cmake options into an array (ex: "-flag X" -> ["-flag", "X"]) for subprocess.run
|
|
cmake_options_arr = extra_cmake_options.split()
|
|
cmd += cmake_options_arr
|
|
|
|
logging.info(shlex.join(cmd))
|
|
subprocess.run(cmd, cwd=THEROCK_DIR, check=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Run build configuration")
|
|
parser.add_argument(
|
|
"--manylinux",
|
|
action="store_true",
|
|
help="Enable manylinux build with multiple Python versions",
|
|
)
|
|
parser.add_argument(
|
|
"--build-dir",
|
|
type=str,
|
|
default=os.getenv("BUILD_DIR", ""),
|
|
help="Directory to use for build files",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
# Support both command-line flag and environment variable
|
|
manylinux = args.manylinux or os.getenv("MANYLINUX") in ["1", "true"]
|
|
|
|
build_configure(args.build_dir, manylinux=manylinux)
|