@@ -87,7 +87,7 @@ endfunction()
8787# Then all patches from the `patches_dir` are committed to the `target_branch`.
8888# Does nothing if the `target_branch` is already checked out in the `repo_dir`.
8989#
90- function (apply_patches repo_dir patches_dir base_revision target_branch ret )
90+ function (apply_patches repo_dir patches_dir base_revision target_branch)
9191 foreach (patches_dir ${patches_dir} )
9292 file (GLOB patches_in_dir ${patches_dir} /*.patch)
9393 list (APPEND patches ${patches_in_dir} )
@@ -97,19 +97,20 @@ function(apply_patches repo_dir patches_dir base_revision target_branch ret)
9797 return ()
9898 endif ()
9999
100- message (STATUS "[OPENCL-CLANG] Patching repository ${repo_dir} " )
100+ # Check if it's a git repo
101+ if (EXISTS "${repo_dir} /.git" )
102+ message (STATUS "[OPENCL-CLANG] Patching repository ${repo_dir} " )
103+ else ()
104+ message (STATUS "[OPENCL-CLANG][Warning] ${repo_dir} is not a git repository, therefore, local patches are not applied" )
105+ return ()
106+ endif ()
101107 # Check if the target branch already exists
102108 execute_process (
103109 COMMAND ${GIT_EXECUTABLE} rev-parse --verify --no -revs -q ${target_branch}
104110 WORKING_DIRECTORY ${repo_dir}
105111 RESULT_VARIABLE patches_needed
106112 OUTPUT_QUIET
107113 )
108- if (patches_needed EQUAL 128) # not a git repo
109- set (${ret} True PARENT_SCOPE)
110- message (STATUS "[OPENCL-CLANG][Warning] ${repo_dir} is not a git repository, therefore, local patches are not applied" )
111- return ()
112- endif ()
113114 if (patches_needed EQUAL 1) # The target branch doesn't exist
114115 list (SORT patches)
115116 is_valid_revision(${repo_dir} ${base_revision} exists_base_rev)
@@ -159,7 +160,7 @@ function(apply_patches repo_dir patches_dir base_revision target_branch ret)
159160 )
160161 endif ()
161162 if (NOT (ret_check_out OR ret_apply_patch))
162- set ( ${ret} True PARENT_SCOPE )
163+ message ( STATUS "[OPENCL-CLANG] Applied patch successfully!" )
163164 else ()
164165 message (FATAL_ERROR "[OPENCL-CLANG] Failed to apply patch!" )
165166 endif ()
0 commit comments