diff options
Diffstat (limited to 'project/cmake/scripts')
| -rw-r--r-- | project/cmake/scripts/common/handle-depends.cmake | 20 | ||||
| -rw-r--r-- | project/cmake/scripts/common/prepare-env.cmake | 41 |
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 b3bf3cd..4d78928 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) | |||
| 86 | file(GLOB patches ${dir}/*.patch) | 86 | file(GLOB patches ${dir}/*.patch) |
| 87 | list(SORT patches) | 87 | list(SORT patches) |
| 88 | foreach(patch ${patches}) | 88 | foreach(patch ${patches}) |
| 89 | if(NOT PATCH_PROGRAM OR "${PATCH_PROGRAM}" STREQUAL "") | ||
| 90 | if(NOT PATCH_EXECUTABLE) | ||
| 91 | # find the path to the patch executable | ||
| 92 | find_program(PATCH_EXECUTABLE NAMES patch) | ||
| 93 | |||
| 94 | if(NOT PATCH_EXECUTABLE) | ||
| 95 | message(FATAL_ERROR "Missing patch command (we looked in ${CMAKE_PREFIX_PATH})") | ||
| 96 | endif() | ||
| 97 | endif() | ||
| 98 | |||
| 99 | # on windows "patch.exe" can only handle CR-LF line-endings so we | ||
| 100 | # need to force it to also handle LF-only line endings | ||
| 101 | set(PATCH_PROGRAM ${PATCH_EXECUTABLE}) | ||
| 102 | if(WIN32) | ||
| 103 | set(PATCH_PROGRAM "\"${PATCH_PROGRAM}\" --binary") | ||
| 104 | endif() | ||
| 105 | endif() | ||
| 106 | |||
| 89 | file(APPEND ${PATCH_FILE} | 107 | file(APPEND ${PATCH_FILE} |
| 90 | "execute_process(COMMAND patch -p1 -i ${patch})\n") | 108 | "execute_process(COMMAND ${PATCH_PROGRAM} -p1 -i \"${patch}\")\n") |
| 91 | endforeach() | 109 | endforeach() |
| 92 | 110 | ||
| 93 | 111 | ||
diff --git a/project/cmake/scripts/common/prepare-env.cmake b/project/cmake/scripts/common/prepare-env.cmake index 7df421c..3413c45 100644 --- a/project/cmake/scripts/common/prepare-env.cmake +++ b/project/cmake/scripts/common/prepare-env.cmake | |||
| @@ -86,3 +86,44 @@ foreach(binding ${bindings}) | |||
| 86 | #include \"kodi/${headerfile}\"") | 86 | #include \"kodi/${headerfile}\"") |
| 87 | endif() | 87 | endif() |
| 88 | endforeach() | 88 | endforeach() |
| 89 | |||
| 90 | ### on windows we need a "patch" binary to be able to patch 3rd party sources | ||
| 91 | if(WIN32) | ||
| 92 | find_program(PATCH_FOUND NAMES patch patch.exe) | ||
| 93 | if(PATCH_FOUND) | ||
| 94 | message(STATUS "patch utility found at ${PATCH_FOUND}") | ||
| 95 | else() | ||
| 96 | set(PATCH_ARCHIVE_NAME "patch-2.5.9-7-bin-1") | ||
| 97 | set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip") | ||
| 98 | set(PATCH_URL "http://mirrors.xbmc.org/build-deps/win32/${PATCH_ARCHIVE}") | ||
| 99 | set(PATCH_DOWNLOAD ${BUILD_DIR}/download/${PATCH_ARCHIVE}) | ||
| 100 | |||
| 101 | # download the archive containing patch.exe | ||
| 102 | message(STATUS "Downloading patch utility from ${PATCH_URL}...") | ||
| 103 | file(DOWNLOAD "${PATCH_URL}" "${PATCH_DOWNLOAD}" STATUS PATCH_DL_STATUS LOG PATCH_LOG SHOW_PROGRESS) | ||
| 104 | list(GET PATCH_DL_STATUS 0 PATCH_RETCODE) | ||
| 105 | if(NOT ${PATCH_RETCODE} EQUAL 0) | ||
| 106 | message(FATAL_ERROR "ERROR downloading ${PATCH_URL} - status: ${PATCH_DL_STATUS} log: ${PATCH_LOG}") | ||
| 107 | endif() | ||
| 108 | |||
| 109 | # extract the archive containing patch.exe | ||
| 110 | execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${PATCH_DOWNLOAD} | ||
| 111 | WORKING_DIRECTORY ${BUILD_DIR}) | ||
| 112 | |||
| 113 | # make sure the extraction worked and that patch.exe is there | ||
| 114 | set(PATCH_PATH ${BUILD_DIR}/${PATCH_ARCHIVE_NAME}) | ||
| 115 | set(PATCH_BINARY_PATH ${PATCH_PATH}/bin/patch.exe) | ||
| 116 | if(NOT EXISTS ${PATCH_PATH} OR NOT EXISTS ${PATCH_BINARY_PATH}) | ||
| 117 | message(FATAL_ERROR "ERROR extracting patch utility from ${PATCH_DOWNLOAD_DIR}") | ||
| 118 | endif() | ||
| 119 | |||
| 120 | # copy patch.exe into the output directory | ||
| 121 | file(INSTALL ${PATCH_BINARY_PATH} DESTINATION ${DEPENDS_PATH}/bin) | ||
| 122 | |||
| 123 | # make sure that cmake can find the copied patch.exe | ||
| 124 | find_program(PATCH_FOUND NAMES patch patch.exe) | ||
| 125 | if(NOT PATCH_FOUND) | ||
| 126 | message(FATAL_ERROR "ERROR installing patch utility from ${PATCH_BINARY_PATH} to ${DEPENDS_PATH}/bin") | ||
| 127 | endif() | ||
| 128 | endif() | ||
| 129 | endif() | ||
