Skip to content

Commit a50a6ab

Browse files
committed
fix: use patch rather than git for patching the vendored modules
This way distro build systems don't need to setup git (`user.email` and `user.name`).
1 parent 2ff622d commit a50a6ab

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ include(GNUInstallDirs)
66

77
enable_language(C CXX)
88

9+
option(ANDROID_BUILD_TOOLS_DEV_MODE "Enable dev mode to ease upstreaming of patches to Google" OFF)
10+
911
# Use C11 with GNU extensions.
1012
set(CMAKE_C_STANDARD 11)
1113
set(CMAKE_C_EXTENSIONS ON)

vendor/CMakeLists.txt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,23 @@ if(ANDROID_BUILD_TOOLS_PATCH_VENDOR AND EXISTS "${ANDROID_PATCH_DIR}/")
2222
file(GLOB patches ${ANDROID_PATCH_DIR}/${v}/*.patch)
2323
if(patches)
2424
message(STATUS "Applying patches for: ${v}")
25-
execute_process(COMMAND git -C
26-
${CMAKE_CURRENT_SOURCE_DIR}/${v} am ${patches}
27-
RESULT_VARIABLE ret)
28-
if(NOT "${ret}" STREQUAL "0")
29-
message(FATAL_ERROR "Couldn't apply patches for ${v}")
25+
26+
if (ANDROID_BUILD_TOOLS_DEV_MODE)
27+
foreach (patch ${patches})
28+
execute_process(COMMAND patch -d
29+
${CMAKE_CURRENT_SOURCE_DIR}/${v} -p1 -i ${patch}
30+
RESULT_VARIABLE ret)
31+
if(NOT "${ret}" STREQUAL "0")
32+
message(FATAL_ERROR "Couldn't apply patch ${patch} for ${v}")
33+
endif()
34+
endforeach(patch)
35+
else()
36+
execute_process(COMMAND git -C
37+
${CMAKE_CURRENT_SOURCE_DIR}/${v} am ${patches}
38+
RESULT_VARIABLE ret)
39+
if(NOT "${ret}" STREQUAL "0")
40+
message(FATAL_ERROR "Couldn't apply patches for ${v}")
41+
endif()
3042
endif()
3143
endif(patches)
3244
endforeach(v)

0 commit comments

Comments
 (0)