From 1e5bdca69f7676b2dbcd64f0f44f31b12b337b7c Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 13 Dec 2016 13:45:04 +0100 Subject: sync with upstream --- project/cmake/scripts/common/ArchSetup.cmake | 5 +++ .../cmake/scripts/common/CheckTargetPlatform.cmake | 6 ++- project/cmake/scripts/common/HandleDepends.cmake | 43 +++++++++++++++++--- project/cmake/scripts/common/Macros.cmake | 9 +++-- project/cmake/scripts/common/PrepareEnv.cmake | 47 +++++----------------- 5 files changed, 63 insertions(+), 47 deletions(-) (limited to 'project/cmake/scripts/common') diff --git a/project/cmake/scripts/common/ArchSetup.cmake b/project/cmake/scripts/common/ArchSetup.cmake index 438e3bd..538fcaf 100644 --- a/project/cmake/scripts/common/ArchSetup.cmake +++ b/project/cmake/scripts/common/ArchSetup.cmake @@ -14,6 +14,7 @@ include(CheckCXXSourceCompiles) include(CheckSymbolExists) include(CheckFunctionExists) +include(CheckIncludeFile) # Macro to check if a given type exists in a given header # Arguments: @@ -109,6 +110,10 @@ check_symbol_exists(PRIdMAX inttypes.h HAVE_INTTYPES_H) check_builtin("long* temp=0; long ret=__sync_add_and_fetch(temp, 1)" HAS_BUILTIN_SYNC_ADD_AND_FETCH) check_builtin("long* temp=0; long ret=__sync_sub_and_fetch(temp, 1)" HAS_BUILTIN_SYNC_SUB_AND_FETCH) check_builtin("long* temp=0; long ret=__sync_val_compare_and_swap(temp, 1, 1)" HAS_BUILTIN_SYNC_VAL_COMPARE_AND_SWAP) +check_include_file(sys/inotify.h HAVE_INOTIFY) +if(HAVE_INOTIFY) + list(APPEND SYSTEM_DEFINES -DHAVE_INOTIFY=1) +endif() if(HAVE_POSIX_FADVISE) list(APPEND SYSTEM_DEFINES -DHAVE_POSIX_FADVISE=1) endif() diff --git a/project/cmake/scripts/common/CheckTargetPlatform.cmake b/project/cmake/scripts/common/CheckTargetPlatform.cmake index 5b5d9a1..82ee668 100644 --- a/project/cmake/scripts/common/CheckTargetPlatform.cmake +++ b/project/cmake/scripts/common/CheckTargetPlatform.cmake @@ -9,7 +9,11 @@ function(check_target_platform dir target_platform build) if(EXISTS ${dir} AND EXISTS ${dir}/platforms.txt) # get all the specified platforms file(STRINGS ${dir}/platforms.txt platforms) - string(REPLACE " " ";" platforms ${platforms}) + + list( LENGTH platforms listlen ) + if(${listlen} EQUAL 1) + string(REPLACE " " ";" platforms ${platforms}) + endif() # check if the addon/dependency should be built for the current platform foreach(platform ${platforms}) diff --git a/project/cmake/scripts/common/HandleDepends.cmake b/project/cmake/scripts/common/HandleDepends.cmake index 880ccdf..adc105b 100644 --- a/project/cmake/scripts/common/HandleDepends.cmake +++ b/project/cmake/scripts/common/HandleDepends.cmake @@ -17,6 +17,7 @@ function(add_addon_depends addon searchpath) file MATCHES noinstall.txt OR file MATCHES flags.txt OR file MATCHES deps.txt OR + file MATCHES "[a-z]+-deps[.]txt" OR file MATCHES platforms.txt)) message(STATUS "Processing ${file}") file(STRINGS ${file} def) @@ -49,7 +50,11 @@ function(add_addon_depends addon searchpath) if(EXISTS ${dir}/flags.txt) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/flags.txt) file(STRINGS ${dir}/flags.txt extraflags) + + # replace some custom placeholders + string(REPLACE "@MINGW_TOOLCHAIN_FILE@" "${OUTPUT_DIR}/Toolchain_mingw32.cmake" extraflags "${extraflags}") string(REPLACE " " ";" extraflags ${extraflags}) + message(STATUS "${id} extraflags: ${extraflags}") endif() @@ -103,11 +108,18 @@ function(add_addon_depends addon searchpath) 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}) + + # On Windows "patch.exe" can only handle CR-LF line-endings. + # Our patches have LF-only line endings - except when they + # have been checked out as part of a dependency hosted on Git + # and core.autocrlf=true. if(WIN32) - set(PATCH_PROGRAM "\"${PATCH_PROGRAM}\" --binary") + file(READ ${patch} patch_content_hex HEX) + # Force handle LF-only line endings + if(NOT patch_content_hex MATCHES "0d0a") + set(PATCH_PROGRAM "\"${PATCH_PROGRAM}\" --binary") + endif() endif() endif() @@ -131,8 +143,11 @@ function(add_addon_depends addon searchpath) set(INSTALL_COMMAND INSTALL_COMMAND "") endif() - # check if there's a deps.txt containing dependencies on other libraries - if(EXISTS ${dir}/deps.txt) + # check if there's a platform-specific or generic deps.txt containing dependencies on other libraries + if(EXISTS ${dir}/${CORE_SYSTEM_NAME}-deps.txt) + file(STRINGS ${dir}/${CORE_SYSTEM_NAME}-deps.txt deps) + message(STATUS "${id} depends: ${deps}") + elseif(EXISTS ${dir}/deps.txt) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/deps.txt) file(STRINGS ${dir}/deps.txt deps) message(STATUS "${id} depends: ${deps}") @@ -161,6 +176,10 @@ function(add_addon_depends addon searchpath) PATCH_COMMAND ${PATCH_COMMAND} "${INSTALL_COMMAND}") + if(CMAKE_VERSION VERSION_GREATER 3.5.9) + list(APPEND EXTERNALPROJECT_SETUP GIT_SHALLOW 1) + endif() + # if there's an url defined we need to pass that to externalproject_add() if(DEFINED url AND NOT "${url}" STREQUAL "") # check if there's a third parameter in the file @@ -172,6 +191,20 @@ function(add_addon_depends addon searchpath) GIT_REPOSITORY ${url} GIT_TAG ${revision} "${EXTERNALPROJECT_SETUP}") + + # For patchfiles to work, disable (users globally set) autocrlf=true + if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_GREATER 3.7) + message(AUTHOR_WARNING "Make use of GIT_CONFIG") + endif() + if(WIN32 AND patches) + externalproject_add_step(${id} gitconfig + COMMAND git config core.autocrlf false + COMMAND git rm -rf --cached . + COMMAND git reset --hard HEAD + COMMENT "Performing gitconfig step: Disabling autocrlf to enable patching for '${id}'" + DEPENDERS patch + WORKING_DIRECTORY ) + endif() else() set(CONFIGURE_COMMAND "") if(NOT WIN32) diff --git a/project/cmake/scripts/common/Macros.cmake b/project/cmake/scripts/common/Macros.cmake index 71c39ef..cce3245 100644 --- a/project/cmake/scripts/common/Macros.cmake +++ b/project/cmake/scripts/common/Macros.cmake @@ -155,9 +155,12 @@ function(core_add_shared_library name) add_library(${name} SHARED ${SOURCES} ${HEADERS} ${OTHERS}) set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} - RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} - RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} OUTPUT_NAME ${OUTPUT_NAME} PREFIX "") + foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) + set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY} + RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}) + endforeach() set(LIBRARY_FILES ${LIBRARY_FILES} ${CMAKE_BINARY_DIR}/${OUTPUT_DIRECTORY}/${OUTPUT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE STRING "" FORCE) add_dependencies(${APP_NAME_LC}-libraries ${name}) @@ -595,9 +598,9 @@ macro(core_find_versions) set(APP_VERSION ${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}) if(APP_VERSION_TAG) set(APP_VERSION ${APP_VERSION}-${APP_VERSION_TAG}) + string(TOLOWER ${APP_VERSION_TAG} APP_VERSION_TAG_LC) endif() string(REPLACE "." "," FILE_VERSION ${APP_ADDON_API}.0) - string(TOLOWER ${APP_VERSION_TAG} APP_VERSION_TAG_LC) file(STRINGS ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h guilib_version REGEX "^.*GUILIB_API_VERSION (.*)$") string(REGEX REPLACE ".*\"(.*)\"" "\\1" guilib_version ${guilib_version}) file(STRINGS ${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h guilib_version_min REGEX "^.*GUILIB_MIN_API_VERSION (.*)$") diff --git a/project/cmake/scripts/common/PrepareEnv.cmake b/project/cmake/scripts/common/PrepareEnv.cmake index 8e02382..51be739 100644 --- a/project/cmake/scripts/common/PrepareEnv.cmake +++ b/project/cmake/scripts/common/PrepareEnv.cmake @@ -51,43 +51,14 @@ foreach(binding ${bindings}) configure_file(${CORE_SOURCE_DIR}/${header} ${APP_INCLUDE_DIR} COPYONLY) 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-3") - set(PATCH_ARCHIVE "${PATCH_ARCHIVE_NAME}.zip") - set(PATCH_URL "${KODI_MIRROR}/build-deps/win32/${PATCH_ARCHIVE}") - set(PATCH_DOWNLOAD ${BUILD_DIR}/download/${PATCH_ARCHIVE}) +### processing additional tools required by the platform +if(EXISTS ${CORE_SOURCE_DIR}/project/cmake/scripts/${CORE_SYSTEM_NAME}/tools/) + file(GLOB platform_tools ${CORE_SOURCE_DIR}/project/cmake/scripts/${CORE_SYSTEM_NAME}/tools/*.cmake) + foreach(platform_tool ${platform_tools}) + get_filename_component(platform_tool_name ${platform_tool} NAME_WE) + message(STATUS "Processing ${CORE_SYSTEM_NAME} specific tool: ${platform_tool_name}") - # 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 ${ADDON_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 ${ADDON_DEPENDS_PATH}/bin") - endif() - endif() + # include the file + include(${platform_tool}) + endforeach() endif() -- cgit v1.2.3