@@ -89,8 +89,12 @@ endfunction()
89
89
# Then all patches from the `patches_dir` are committed to the `target_branch`.
90
90
# Does nothing if the `target_branch` is already checked out in the `repo_dir`.
91
91
#
92
- function (apply_patches repo_dir patches_dir base_revision target_branch )
93
- file (GLOB patches ${patches_dir} /*.patch )
92
+ function (apply_patches repo_dir patches_dir base_revision target_branch ret )
93
+ set (patches "" )
94
+ foreach (patches_dir ${patches_dir} )
95
+ file (GLOB patches_in_dir ${patches_dir} /*.patch )
96
+ list (APPEND patches ${patches_in_dir} )
97
+ endforeach ()
94
98
if (NOT patches )
95
99
message (STATUS "[OPENCL-CLANG] No patches in ${patches_dir} " )
96
100
return ()
@@ -105,7 +109,9 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
105
109
ERROR_QUIET
106
110
OUTPUT_QUIET
107
111
)
108
- if (patches_needed ) # The target branch doesn't exist
112
+ if (patches_needed EQUAL 128 ) # not a git repo
113
+ set (ret_not_git_repo 1 )
114
+ elseif (patches_needed ) # The target branch doesn't exist
109
115
list (SORT patches )
110
116
is_valid_revision (${repo_dir} ${base_revision} exists_base_rev )
111
117
@@ -139,8 +145,12 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
139
145
WORKING_DIRECTORY ${repo_dir}
140
146
OUTPUT_VARIABLE patching_log
141
147
ERROR_QUIET
148
+ RESULT_VARIABLE ret_apply_patch
142
149
)
143
150
message (STATUS "[OPENCL-CLANG] Not present - ${patching_log} " )
151
+ if (ret_apply_patch )
152
+ break ()
153
+ endif ()
144
154
endif ()
145
155
endforeach (patch )
146
156
else () # The target branch already exists
@@ -149,8 +159,14 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
149
159
WORKING_DIRECTORY ${repo_dir}
150
160
ERROR_QUIET
151
161
OUTPUT_QUIET
162
+ RESULT_VARIABLE ret_check_out
152
163
)
153
164
endif ()
165
+ if (NOT (ret_not_git_repo OR ret_check_out OR ret_apply_patch ))
166
+ set (${ret} True PARENT_SCOPE )
167
+ else ()
168
+ message (FATAL_ERROR "[OPENCL-CLANG] Failed to apply patch!" )
169
+ endif ()
154
170
endfunction ()
155
171
156
172
# Usage
0 commit comments