diff options
Diffstat (limited to 'cmake/scripts/windowsstore/tools/patch.cmake')
| -rw-r--r-- | cmake/scripts/windowsstore/tools/patch.cmake | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/cmake/scripts/windowsstore/tools/patch.cmake b/cmake/scripts/windowsstore/tools/patch.cmake new file mode 100644 index 0000000..0a342fa --- /dev/null +++ b/cmake/scripts/windowsstore/tools/patch.cmake | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | find_program(PATCH_FOUND NAMES patch patch.exe) | ||
| 2 | if(PATCH_FOUND) | ||
| 3 | message(STATUS "patch utility found at ${PATCH_FOUND}") | ||
| 4 | else() | ||
| 5 | set(PATCH_ARCHIVE_NAME "patch-2.5.9-7-bin-3") | ||
| 6 | set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip") | ||
| 7 | set(PATCH_URL "${KODI_MIRROR}/build-deps/win32/${PATCH_ARCHIVE}") | ||
| 8 | set(PATCH_DOWNLOAD ${BUILD_DIR}/download/${PATCH_ARCHIVE}) | ||
| 9 | |||
| 10 | # download the archive containing patch.exe | ||
| 11 | message(STATUS "Downloading patch utility from ${PATCH_URL}...") | ||
| 12 | file(DOWNLOAD "${PATCH_URL}" "${PATCH_DOWNLOAD}" STATUS PATCH_DL_STATUS LOG PATCH_LOG SHOW_PROGRESS) | ||
| 13 | list(GET PATCH_DL_STATUS 0 PATCH_RETCODE) | ||
| 14 | if(NOT PATCH_RETCODE EQUAL 0) | ||
| 15 | message(FATAL_ERROR "ERROR downloading ${PATCH_URL} - status: ${PATCH_DL_STATUS} log: ${PATCH_LOG}") | ||
| 16 | endif() | ||
| 17 | |||
| 18 | # extract the archive containing patch.exe | ||
| 19 | execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${PATCH_DOWNLOAD} | ||
| 20 | WORKING_DIRECTORY ${BUILD_DIR}) | ||
| 21 | |||
| 22 | # make sure the extraction worked and that patch.exe is there | ||
| 23 | set(PATCH_PATH ${BUILD_DIR}/${PATCH_ARCHIVE_NAME}) | ||
| 24 | set(PATCH_BINARY_PATH ${PATCH_PATH}/bin/patch.exe) | ||
| 25 | if(NOT EXISTS ${PATCH_PATH} OR NOT EXISTS ${PATCH_BINARY_PATH}) | ||
| 26 | message(FATAL_ERROR "ERROR extracting patch utility from ${PATCH_PATH}") | ||
| 27 | endif() | ||
| 28 | |||
| 29 | # copy patch.exe into the output directory | ||
| 30 | file(INSTALL ${PATCH_BINARY_PATH} DESTINATION ${ADDON_DEPENDS_PATH}/bin) | ||
| 31 | |||
| 32 | # make sure that cmake can find the copied patch.exe | ||
| 33 | find_program(PATCH_FOUND NAMES patch patch.exe) | ||
| 34 | if(NOT PATCH_FOUND) | ||
| 35 | message(FATAL_ERROR "ERROR installing patch utility from ${PATCH_BINARY_PATH} to ${ADDON_DEPENDS_PATH}/bin") | ||
| 36 | endif() | ||
| 37 | endif() | ||
