Skip to content

Commit 1678c0c

Browse files
committed
Check if apply_patches is successful
1 parent c3754c2 commit 1678c0c

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,21 @@ if(NOT USE_PREBUILT_LLVM)
9191
apply_patches(${LLVM_SOURCE_DIR}
9292
${CMAKE_CURRENT_SOURCE_DIR}/patches/llvm
9393
${LLVM_BASE_REVISION}
94-
${TARGET_BRANCH})
94+
${TARGET_BRANCH}
95+
ret)
96+
if(${ret})
97+
add_definitions(-DAPPLIED_LLVM_PATCHES)
98+
endif()
9599
apply_patches(${CLANG_SOURCE_DIR}
96100
${CMAKE_CURRENT_SOURCE_DIR}/patches/clang
97101
${CLANG_BASE_REVISION}
98-
${TARGET_BRANCH})
102+
${TARGET_BRANCH}
103+
ret)
99104
apply_patches(${SPIRV_SOURCE_DIR}
100105
${CMAKE_CURRENT_SOURCE_DIR}/patches/spirv
101106
${SPIRV_BASE_REVISION}
102-
${TARGET_BRANCH})
107+
${TARGET_BRANCH}
108+
ret)
103109
endif(NOT USE_PREBUILT_LLVM)
104110

105111
#

cmake/modules/CMakeFunctions.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ endmacro(use_eh)
4444
# Then all patches from the `patches_dir` are committed to the `target_branch`.
4545
# Does nothing if the `target_branch` is already checked out in the `repo_dir`.
4646
#
47-
function(apply_patches repo_dir patches_dir base_revision target_branch)
47+
function(apply_patches repo_dir patches_dir base_revision target_branch ret)
4848
file(GLOB patches ${patches_dir}/*.patch)
4949
if(NOT patches)
5050
message(STATUS "No patches in ${patches_dir}")
@@ -58,22 +58,30 @@ function(apply_patches repo_dir patches_dir base_revision target_branch)
5858
WORKING_DIRECTORY ${repo_dir}
5959
RESULT_VARIABLE patches_needed
6060
)
61-
if(patches_needed) # The target branch doesn't exist
61+
if(patches_needed EQUAL 128) # not a git repo
62+
set(ret_not_git_repo 1)
63+
elseif(patches_needed) # The target branch doesn't exist
6264
list(SORT patches)
6365
execute_process( # Create the target branch
6466
COMMAND ${GIT_EXECUTABLE} checkout -b ${target_branch} ${base_revision}
6567
WORKING_DIRECTORY ${repo_dir}
68+
RESULT_VARIABLE ret_check_out
6669
)
6770
execute_process( # Apply the pathces
6871
COMMAND ${GIT_EXECUTABLE} am --3way --ignore-whitespace ${patches}
6972
WORKING_DIRECTORY ${repo_dir}
73+
RESULT_VARIABLE ret_apply_patch
7074
)
7175
else() # The target branch already exists
7276
execute_process( # Check it out
7377
COMMAND ${GIT_EXECUTABLE} checkout ${target_branch}
7478
WORKING_DIRECTORY ${repo_dir}
79+
RESULT_VARIABLE ret_check_out
7580
)
7681
endif()
82+
if (NOT (ret_not_git_repo OR ret_check_out OR ret_apply_patch))
83+
set(${ret} True PARENT_SCOPE)
84+
endif()
7785
endfunction()
7886

7987
# Usage

common_clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static llvm::ManagedStatic<llvm::sys::SmartMutex<true>> compileMutex;
8989

9090
void CommonClangTerminate() {
9191
llvm::llvm_shutdown();
92-
#ifndef USE_PREBUILT_LLVM
92+
#ifdef APPLIED_LLVM_PATCHES
9393
llvm::deleteManagedStaticMutex();
9494
#endif
9595
}

0 commit comments

Comments
 (0)