|
9 | 9 | set(SYCL_JIT_VIRTUAL_TOOLCHAIN_ROOT "/sycl-jit-toolchain/") |
10 | 10 | endif() |
11 | 11 |
|
12 | | -set(SYCL_JIT_RESOURCE_DEPS |
13 | | - sycl-headers # include/sycl |
14 | | - clang # lib/clang/N/include |
15 | | - ${CMAKE_CURRENT_SOURCE_DIR}/utils/generate.py) |
| 12 | +set(SYCL_JIT_RESOURCE_INSTALL_COMPONENTS sycl-headers OpenCL-Headers clang-resource-headers) |
16 | 13 |
|
17 | 14 | if ("libclc" IN_LIST LLVM_ENABLE_PROJECTS) |
18 | | - # Somehow just "libclc" doesn't build "remangled-*" (and maybe whatever else). |
19 | | - list(APPEND SYCL_JIT_RESOURCE_DEPS libclc libspirv-builtins) # lib/clc/*.bc |
| 15 | + list(APPEND SYCL_JIT_RESOURCE_INSTALL_COMPONENTS libspirv-builtins) |
20 | 16 | endif() |
21 | 17 |
|
22 | 18 | if ("libdevice" IN_LIST LLVM_ENABLE_PROJECTS) |
23 | | - list(APPEND SYCL_JIT_RESOURCE_DEPS libsycldevice) # lib/*.bc |
| 19 | + list(APPEND SYCL_JIT_RESOURCE_INSTALL_COMPONENTS libsycldevice) |
24 | 20 | endif() |
25 | 21 |
|
| 22 | +set(SYCL_JIT_RESOURCE_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/rtc-resources-install) |
| 23 | + |
| 24 | +set(SYCL_JIT_PREPARE_RESOURCE_COMMANDS) |
| 25 | +foreach(component IN LISTS SYCL_JIT_RESOURCE_INSTALL_COMPONENTS) |
| 26 | + list(APPEND SYCL_JIT_PREPARE_RESOURCE_COMMANDS |
| 27 | + COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${SYCL_JIT_RESOURCE_INSTALL_DIR} --component "${component}" |
| 28 | + ) |
| 29 | +endforeach() |
| 30 | + |
| 31 | +set(SYCL_JIT_RESOURCE_DEPS ${SYCL_JIT_RESOURCE_INSTALL_COMPONENTS}) |
| 32 | + # OpenCL-Headers doesn't have a corresponding build target: |
| 33 | +list(FILTER SYCL_JIT_RESOURCE_DEPS EXCLUDE REGEX "^OpenCL-Headers$") |
| 34 | + |
| 35 | +# This is very hacky and I don't quite know what I'm doing, but it's necessary |
| 36 | +# to have `resource.cpp` re-generated/re-built when some SYCL header changes. |
| 37 | +# |
| 38 | +# Inspired by the way `sycl-headers` target is created. |
| 39 | +file(GLOB_RECURSE SYCL_JIT_RESOURCE_FILES CONFIGURE_DEPENDS "${SYCL_JIT_RESOURCE_INSTALL_DIR}/*" ) |
| 40 | + |
| 41 | +add_custom_target(rtc-prepare-resources |
| 42 | + DEPENDS ${SYCL_JIT_RESOURCE_DEPS} |
| 43 | + ${SYCL_JIT_PREPARE_RESOURCE_COMMANDS} |
| 44 | + BYPRODUCTS |
| 45 | + ${SYCL_JIT_RESOURCE_FILES} |
| 46 | +) |
| 47 | + |
26 | 48 | add_custom_command( |
27 | 49 | OUTPUT ${SYCL_JIT_RESOURCE_CPP} |
28 | | - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/generate.py --toolchain-dir ${CMAKE_BINARY_DIR} --output ${SYCL_JIT_RESOURCE_CPP} --prefix ${SYCL_JIT_VIRTUAL_TOOLCHAIN_ROOT} |
| 50 | + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/generate.py --toolchain-dir ${SYCL_JIT_RESOURCE_INSTALL_DIR} --output ${SYCL_JIT_RESOURCE_CPP} --prefix ${SYCL_JIT_VIRTUAL_TOOLCHAIN_ROOT} |
29 | 51 | DEPENDS |
| 52 | + rtc-prepare-resources |
30 | 53 | ${SYCL_JIT_RESOURCE_DEPS} |
| 54 | + ${SYCL_JIT_RESOURCE_FILES} |
| 55 | + ${CMAKE_CURRENT_SOURCE_DIR}/utils/generate.py |
31 | 56 | ) |
32 | 57 |
|
33 | 58 | # We use C23/C++26's `#embed` to implement this resource creation, and "current" |
@@ -67,6 +92,8 @@ add_custom_command( |
67 | 92 | ${clang_exe} --target=${LLVM_HOST_TRIPLE} ${SYCL_JIT_RESOURCE_CPP} -I ${CMAKE_CURRENT_SOURCE_DIR}/include -c -o ${SYCL_JIT_RESOURCE_OBJ} ${SYCL_JIT_RESOURCE_CXX_FLAGS} |
68 | 93 | DEPENDS |
69 | 94 | ${SYCL_JIT_RESOURCE_CPP} |
| 95 | + ${SYCL_JIT_RESOURCE_DEPS} |
| 96 | + ${SYCL_JIT_RESOURCE_FILES} |
70 | 97 | ${CMAKE_CURRENT_SOURCE_DIR}/include/Resource.h |
71 | 98 | ) |
72 | 99 |
|
|
0 commit comments