Skip to content

Commit bef5dd2

Browse files
authored
[ocl-open-170] Error out in CMake if a clang patch fails to apply (#742)
failed patches were silently ignored
1 parent af0c058 commit bef5dd2

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

cmake/modules/CMakeFunctions.cmake

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,23 @@ function(apply_patches repo_dir patches_dirs base_revision target_branch)
143143
execute_process( # Apply the patch
144144
COMMAND ${GIT_EXECUTABLE} am --3way --keep-non-patch --ignore-whitespace -C0 ${patch}
145145
WORKING_DIRECTORY ${repo_dir}
146+
RESULT_VARIABLE ret_apply_patch
146147
OUTPUT_VARIABLE patching_log
148+
ERROR_VARIABLE patching_err
147149
)
148-
message(STATUS "[OPENCL-CLANG] Not present - ${patching_log}")
150+
message(STATUS "[OPENCL-CLANG] Applying ${patch}\n${patching_log}")
151+
if(ret_apply_patch)
152+
execute_process( # Abort the half-applied am so the repo is left in a sane state
153+
COMMAND ${GIT_EXECUTABLE} am --abort
154+
WORKING_DIRECTORY ${repo_dir}
155+
OUTPUT_QUIET ERROR_QUIET
156+
)
157+
message(FATAL_ERROR
158+
"[OPENCL-CLANG] Failed to apply patch ${patch}\n"
159+
"git am exit code: ${ret_apply_patch}\n"
160+
"stdout:\n${patching_log}\n"
161+
"stderr:\n${patching_err}")
162+
endif()
149163
endif()
150164
endforeach(patch)
151165
elseif(patches_needed EQUAL 0) # The target branch already exists

0 commit comments

Comments
 (0)