Skip to content

Commit

Permalink
fixup! Use the same patching script and command for all repos
Browse files Browse the repository at this point in the history
  • Loading branch information
dcandler committed Nov 29, 2024
1 parent 88c5d02 commit 6cb16d3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cmake/fetch_llvm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ if(NOT VERSIONS_JSON)
include(${CMAKE_CURRENT_LIST_DIR}/read_versions.cmake)
endif()
read_repo_version(llvmproject llvm-project)
get_patch_command(llvm-project llvm_patch_command)
get_patch_command(${CMAKE_CURRENT_LIST_DIR}/.. llvm-project llvm_patch_command)
if(APPLY_LLVM_PERFORMANCE_PATCHES)
get_patch_command(llvm-project-perf llvm_perf_patch_command)
get_patch_command(${CMAKE_CURRENT_LIST_DIR}/.. llvm-project-perf llvm_perf_patch_command)
set(llvm_patch_command ${llvm_patch_command} && ${llvm_perf_patch_command} )
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/fetch_newlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(NOT VERSIONS_JSON)
include(${CMAKE_CURRENT_LIST_DIR}/read_versions.cmake)
endif()
read_repo_version(newlib newlib)
get_patch_command(newlib newlib_patch_command)
get_patch_command(${CMAKE_CURRENT_LIST_DIR}/.. newlib newlib_patch_command)

FetchContent_Declare(newlib
GIT_REPOSITORY https://sourceware.org/git/newlib-cygwin.git
Expand Down
2 changes: 1 addition & 1 deletion cmake/fetch_picolibc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(NOT VERSIONS_JSON)
include(${CMAKE_CURRENT_LIST_DIR}/read_versions.cmake)
endif()
read_repo_version(picolibc picolibc)
get_patch_command(picolibc picolibc_patch_command)
get_patch_command(${CMAKE_CURRENT_LIST_DIR}/.. picolibc picolibc_patch_command)

FetchContent_Declare(picolibc
GIT_REPOSITORY https://github.com/picolibc/picolibc.git
Expand Down
6 changes: 3 additions & 3 deletions cmake/patch_repo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# Function to generate a PATCH_COMMAND, calling the
# patch_repo.py script using a target set of patches.

function(get_patch_command patch_dir patch_command_out)
set(patch_script ${CMAKE_CURRENT_LIST_DIR}/patch_repo.py)
function(get_patch_command toolchain_root patch_dir patch_command_out)
set(patch_script ${toolchain_root}/cmake/patch_repo.py)
list(APPEND patch_script_args ${Python3_EXECUTABLE} ${patch_script})
if(GIT_PATCH_METHOD STREQUAL "am")
list(APPEND patch_script_args "--method" "am")
elseif(GIT_PATCH_METHOD STREQUAL "apply")
list(APPEND patch_script_args "--method" "apply")
endif()
list(APPEND patch_script_args ${CMAKE_CURRENT_LIST_DIR}/../patches/${patch_dir})
list(APPEND patch_script_args ${toolchain_root}/patches/${patch_dir})

set(${patch_command_out} ${patch_script_args} PARENT_SCOPE)
endfunction()
4 changes: 4 additions & 0 deletions cmake/patch_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def main():
)
args = parser.parse_args()

# If the patch is valid but contain conflicts, using --3way --apply can apply
# the patch but leave conflict markers in the source for the user to resolve.
# This doesn't return an error code, making it compatible with this script's
# --restore_on_fail option, which relies on the error code from running --check.
if args.method == "apply" and args.restore_on_fail and args.three_way:
print("--restore_on_fail is incompatible with --3way using apply")
exit(1)
Expand Down

0 comments on commit 6cb16d3

Please sign in to comment.