aboutsummaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
authormontellese <montellese@xbmc.org>2015-03-05 22:16:42 +0100
committermontellese <montellese@xbmc.org>2015-03-14 09:13:12 +0100
commit927e5af632fc9ad75fb6039d28e00407d8104a75 (patch)
treec3b930e59751e7d32f3acfc226b947449d094372 /project
parent665ddb6a18fbdc4c97a81e2056cd3f2c38a1be78 (diff)
[win32] make sure we have access to a patch command
Diffstat (limited to 'project')
-rw-r--r--project/cmake/scripts/common/handle-depends.cmake20
-rw-r--r--project/cmake/scripts/common/prepare-env.cmake41
2 files changed, 60 insertions, 1 deletions
diff --git a/project/cmake/scripts/common/handle-depends.cmake b/project/cmake/scripts/common/handle-depends.cmake
index b3bf3cd531..4d78928e13 100644
--- a/project/cmake/scripts/common/handle-depends.cmake
+++ b/project/cmake/scripts/common/handle-depends.cmake
@@ -86,8 +86,26 @@ function(add_addon_depends addon searchpath)
file(GLOB patches ${dir}/*.patch)
list(SORT patches)
foreach(patch ${patches})
+ if(NOT PATCH_PROGRAM OR "${PATCH_PROGRAM}" STREQUAL "")
+ if(NOT PATCH_EXECUTABLE)
+ # find the path to the patch executable
+ find_program(PATCH_EXECUTABLE NAMES patch)
+
+ if(NOT PATCH_EXECUTABLE)
+ message(FATAL_ERROR "Missing patch command (we looked in ${CMAKE_PREFIX_PATH})")
+ endif()
+ endif()
+
+ # on windows "patch.exe" can only handle CR-LF line-endings so we
+ # need to force it to also handle LF-only line endings
+ set(PATCH_PROGRAM ${PATCH_EXECUTABLE})
+ if(WIN32)
+ set(PATCH_PROGRAM "\"${PATCH_PROGRAM}\" --binary")
+ endif()
+ endif()
+
file(APPEND ${PATCH_FILE}
- "execute_process(COMMAND patch -p1 -i ${patch})\n")
+ "execute_process(COMMAND ${PATCH_PROGRAM} -p1 -i \"${patch}\")\n")
endforeach()
diff --git a/project/cmake/scripts/common/prepare-env.cmake b/project/cmake/scripts/common/prepare-env.cmake
index 7df421cfc1..3413c4519f 100644
--- a/project/cmake/scripts/common/prepare-env.cmake
+++ b/project/cmake/scripts/common/prepare-env.cmake
@@ -86,3 +86,44 @@ foreach(binding ${bindings})
#include \"kodi/${headerfile}\"")
endif()
endforeach()
+
+### on windows we need a "patch" binary to be able to patch 3rd party sources
+if(WIN32)
+ find_program(PATCH_FOUND NAMES patch patch.exe)
+ if(PATCH_FOUND)
+ message(STATUS "patch utility found at ${PATCH_FOUND}")
+ else()
+ set(PATCH_ARCHIVE_NAME "patch-2.5.9-7-bin-1")
+ set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip")
+ set(PATCH_URL "http://mirrors.xbmc.org/build-deps/win32/${PATCH_ARCHIVE}")
+ set(PATCH_DOWNLOAD ${BUILD_DIR}/download/${PATCH_ARCHIVE})
+
+ # download the archive containing patch.exe
+ message(STATUS "Downloading patch utility from ${PATCH_URL}...")
+ file(DOWNLOAD "${PATCH_URL}" "${PATCH_DOWNLOAD}" STATUS PATCH_DL_STATUS LOG PATCH_LOG SHOW_PROGRESS)
+ list(GET PATCH_DL_STATUS 0 PATCH_RETCODE)
+ if(NOT ${PATCH_RETCODE} EQUAL 0)
+ message(FATAL_ERROR "ERROR downloading ${PATCH_URL} - status: ${PATCH_DL_STATUS} log: ${PATCH_LOG}")
+ endif()
+
+ # extract the archive containing patch.exe
+ execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${PATCH_DOWNLOAD}
+ WORKING_DIRECTORY ${BUILD_DIR})
+
+ # make sure the extraction worked and that patch.exe is there
+ set(PATCH_PATH ${BUILD_DIR}/${PATCH_ARCHIVE_NAME})
+ set(PATCH_BINARY_PATH ${PATCH_PATH}/bin/patch.exe)
+ if(NOT EXISTS ${PATCH_PATH} OR NOT EXISTS ${PATCH_BINARY_PATH})
+ message(FATAL_ERROR "ERROR extracting patch utility from ${PATCH_DOWNLOAD_DIR}")
+ endif()
+
+ # copy patch.exe into the output directory
+ file(INSTALL ${PATCH_BINARY_PATH} DESTINATION ${DEPENDS_PATH}/bin)
+
+ # make sure that cmake can find the copied patch.exe
+ find_program(PATCH_FOUND NAMES patch patch.exe)
+ if(NOT PATCH_FOUND)
+ message(FATAL_ERROR "ERROR installing patch utility from ${PATCH_BINARY_PATH} to ${DEPENDS_PATH}/bin")
+ endif()
+ endif()
+endif()