Files
TheRock/rocm-systems/emulation/mirage/hotswap/cmake/hotswap_copy_glob.cmake
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

52 lines
2.3 KiB
CMake

# hotswap_copy_glob.cmake — stage glob-matched artifacts into a directory.
#
# Invoked via `cmake -P` from the HotSwap ExternalProject install steps in
# cmake/Hotswap.cmake. It copies the files a HotSwap build stage produces
# (the comgr/ROCR shared libraries and the LLVM tools) into the flat
# `${stage}/lib`, `${stage}/llvm-tools` layout mirage discovers.
#
# Inputs (all passed with -D):
# HOTSWAP_ROOT Directory to resolve patterns against (a build tree).
# HOTSWAP_GLOB ;-separated list of filename glob patterns, e.g.
# "libamd_comgr.so*" or "lld;ld.lld;llc;llvm-mc".
# HOTSWAP_DST Destination directory (created if absent).
# HOTSWAP_RECURSE_ANCHOR Optional. When set, the file with this name is located
# recursively under HOTSWAP_ROOT and its parent directory
# is used as the glob base instead of HOTSWAP_ROOT (ROCR
# buries libhsa-runtime64.so in a build subdirectory whose
# path is not known ahead of time).
#
# FOLLOW_SYMLINK_CHAIN is used so versioned SONAME links (e.g.
# libhsa-runtime64.so -> libhsa-runtime64.so) are reproduced verbatim.
if(NOT DEFINED HOTSWAP_ROOT OR NOT DEFINED HOTSWAP_GLOB OR NOT DEFINED HOTSWAP_DST)
message(FATAL_ERROR "hotswap_copy_glob: HOTSWAP_ROOT, HOTSWAP_GLOB and HOTSWAP_DST are required")
endif()
set(_base "${HOTSWAP_ROOT}")
if(DEFINED HOTSWAP_RECURSE_ANCHOR AND NOT HOTSWAP_RECURSE_ANCHOR STREQUAL "")
file(GLOB_RECURSE _anchor "${HOTSWAP_ROOT}/${HOTSWAP_RECURSE_ANCHOR}")
if(NOT _anchor)
message(FATAL_ERROR "hotswap_copy_glob: ${HOTSWAP_RECURSE_ANCHOR} not found under ${HOTSWAP_ROOT}")
endif()
list(GET _anchor 0 _anchor0)
get_filename_component(_base "${_anchor0}" DIRECTORY)
endif()
set(_patterns)
foreach(_g IN LISTS HOTSWAP_GLOB)
list(APPEND _patterns "${_base}/${_g}")
endforeach()
file(GLOB _files LIST_DIRECTORIES false ${_patterns})
if(NOT _files)
message(FATAL_ERROR "hotswap_copy_glob: no files matched ${_patterns}")
endif()
file(MAKE_DIRECTORY "${HOTSWAP_DST}")
foreach(_f IN LISTS _files)
file(INSTALL "${_f}" DESTINATION "${HOTSWAP_DST}"
USE_SOURCE_PERMISSIONS FOLLOW_SYMLINK_CHAIN)
endforeach()
message(STATUS "hotswap: staged ${_files} -> ${HOTSWAP_DST}")