Skip to content

Commit 54ed276

Browse files
authored
Fix apply_patches in CMake to work with two directories (#673)
This reverts recent change that split apply_patches into two calls. Then it fixes apply_patches implementation to properly apply patches from multiple direcotires.
1 parent 925ad71 commit 54ed276

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,13 @@ if(NOT USE_PREBUILT_LLVM)
165165
set(SPIRV_BASE_REVISION llvm_release_170)
166166
set(TARGET_BRANCH "ocl-open-170")
167167
get_filename_component(LLVM_MONOREPO_DIR ${LLVM_SOURCE_DIR} DIRECTORY)
168+
set(LLVM_PATCHES_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/patches/llvm
169+
${CMAKE_CURRENT_SOURCE_DIR}/patches/clang)
170+
168171
if(APPLY_PATCHES)
169172
message(STATUS "APPLY_PATCHES is enabled.")
170173
apply_patches(${LLVM_MONOREPO_DIR}
171-
${CMAKE_CURRENT_SOURCE_DIR}/patches/llvm
172-
${LLVM_BASE_REVISION}
173-
${TARGET_BRANCH})
174-
apply_patches(${LLVM_MONOREPO_DIR}
175-
${CMAKE_CURRENT_SOURCE_DIR}/patches/clang
174+
"${LLVM_PATCHES_DIRS}"
176175
${LLVM_BASE_REVISION}
177176
${TARGET_BRANCH})
178177
apply_patches(${SPIRV_SOURCE_DIR}

cmake/modules/CMakeFunctions.cmake

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,18 @@ endfunction()
8383

8484
#
8585
# Creates `target_branch` starting at the `base_revision` in the `repo_dir`.
86-
# Then all patches from the `patches_dir` are committed to the `target_branch`.
86+
# Then all patches from the `patches_dirs` are committed to the `target_branch`.
87+
# `patches_dirs` can be a single directory or a semicolon-separated list.
8788
# Does nothing if the `target_branch` is already checked out in the `repo_dir`.
8889
#
89-
function(apply_patches repo_dir patches_dir base_revision target_branch)
90-
file(GLOB patches ${patches_dir}/*.patch)
90+
function(apply_patches repo_dir patches_dirs base_revision target_branch)
91+
set(patches)
92+
foreach(dir ${patches_dirs})
93+
file(GLOB dir_patches ${dir}/*.patch)
94+
list(APPEND patches ${dir_patches})
95+
endforeach()
9196
if(NOT patches)
92-
message(STATUS "[OPENCL-CLANG] No patches in ${patches_dir}")
97+
message(STATUS "[OPENCL-CLANG] No patches in ${patches_dirs}")
9398
return()
9499
endif()
95100

0 commit comments

Comments
 (0)