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
55 lines
2.6 KiB
CMake
55 lines
2.6 KiB
CMake
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
# Standalone CMake script that embeds kernel source files as C++ string literals.
|
|
#
|
|
# Invoked at build time via:
|
|
# cmake -DKERNEL_FILES="file1.cpp|file2.cpp"
|
|
# -DTEMPLATE_DIR=/path/to/templates
|
|
# -DOUTPUT_DIR=/path/to/output
|
|
# -P EmbedKernelSources.cmake
|
|
#
|
|
# KERNEL_FILES uses pipe (|) as the separator instead of semicolons to avoid
|
|
# escaping issues when VERBATIM passes the argument through the shell.
|
|
#
|
|
# Reads each file in KERNEL_FILES, classifies it as a kernel source (.cpp) or
|
|
# a kernel header (.h/.hpp), and populates template variables used by
|
|
# configure_file() to generate GpuRefKernelSources.hpp / GpuRefKernelSources.cpp.
|
|
|
|
# Convert pipe-separated list back to CMake list (semicolons)
|
|
string(REPLACE "|" ";" KERNEL_FILES "${KERNEL_FILES}")
|
|
|
|
set(KERNEL_DECLARATIONS "")
|
|
set(KERNEL_DEFINITIONS "")
|
|
set(KERNEL_MAP_ENTRIES "")
|
|
set(HEADER_DECLARATIONS "")
|
|
set(HEADER_DEFINITIONS "")
|
|
set(HEADER_MAP_ENTRIES "")
|
|
set(HEADER_FILENAMES "")
|
|
|
|
foreach(KERNEL_FILE ${KERNEL_FILES})
|
|
file(READ ${KERNEL_FILE} KERNEL_CONTENT)
|
|
get_filename_component(KERNEL_NAME ${KERNEL_FILE} NAME_WE)
|
|
get_filename_component(KERNEL_FILENAME ${KERNEL_FILE} NAME)
|
|
get_filename_component(KERNEL_EXT ${KERNEL_FILE} EXT)
|
|
string(TOUPPER ${KERNEL_NAME} KERNEL_VAR_NAME)
|
|
|
|
if(KERNEL_EXT STREQUAL ".h" OR KERNEL_EXT STREQUAL ".hpp")
|
|
string(APPEND HEADER_DECLARATIONS "extern const char* const ${KERNEL_VAR_NAME}_SOURCE;\n")
|
|
string(APPEND HEADER_DEFINITIONS "const char* const ${KERNEL_VAR_NAME}_SOURCE = R\"KERNEL_SOURCE(\n")
|
|
string(APPEND HEADER_DEFINITIONS "${KERNEL_CONTENT}")
|
|
string(APPEND HEADER_DEFINITIONS "\n)KERNEL_SOURCE\";\n\n")
|
|
string(APPEND HEADER_MAP_ENTRIES " {\"${KERNEL_FILENAME}\", ${KERNEL_VAR_NAME}_SOURCE},\n")
|
|
string(APPEND HEADER_FILENAMES " \"${KERNEL_FILENAME}\",\n")
|
|
else()
|
|
string(APPEND KERNEL_DECLARATIONS "extern const char* const ${KERNEL_VAR_NAME}_SOURCE;\n")
|
|
string(APPEND KERNEL_DEFINITIONS "const char* const ${KERNEL_VAR_NAME}_SOURCE = R\"KERNEL_SOURCE(\n")
|
|
string(APPEND KERNEL_DEFINITIONS "${KERNEL_CONTENT}")
|
|
string(APPEND KERNEL_DEFINITIONS "\n)KERNEL_SOURCE\";\n\n")
|
|
string(APPEND KERNEL_MAP_ENTRIES " {\"${KERNEL_FILENAME}\", ${KERNEL_VAR_NAME}_SOURCE},\n")
|
|
endif()
|
|
endforeach()
|
|
|
|
configure_file(${TEMPLATE_DIR}/GpuRefKernelSources.hpp.in ${OUTPUT_DIR}/GpuRefKernelSources.hpp @ONLY)
|
|
configure_file(${TEMPLATE_DIR}/GpuRefKernelSources.cpp.in ${OUTPUT_DIR}/GpuRefKernelSources.cpp @ONLY)
|