From f44ecaa4f27e7538ddcad66d40e543bffa2d2d86 Mon Sep 17 00:00:00 2001 From: manuel Date: Sun, 4 Jun 2017 16:57:49 +0200 Subject: sync with upstream --- cmake/addons/CMakeLists.txt | 439 +++++++++++++++++++++ cmake/addons/README.md | 65 +++ cmake/addons/addons/pvr.dvbviewer/platforms.txt | 1 + .../addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt | 1 + cmake/addons/bootstrap/Bootstrap.cmake | 39 ++ cmake/addons/bootstrap/CMakeLists.txt | 93 +++++ cmake/addons/bootstrap/README.md | 48 +++ .../bootstrap/repositories/binary-addons.txt | 1 + cmake/addons/depends/CMakeLists.txt | 41 ++ cmake/addons/depends/README | 61 +++ cmake/addons/depends/common/kodi-platform/deps.txt | 2 + .../depends/common/kodi-platform/kodi-platform.txt | 1 + .../depends/common/p8-platform/p8-platform.txt | 1 + cmake/addons/depends/common/tinyxml/CMakeLists.txt | 22 ++ cmake/addons/depends/common/tinyxml/tinyxml.txt | 1 + cmake/addons/depends/windows/CMakeLists.txt | 52 +++ cmake/addons/depends/windows/Install.cmake | 24 ++ cmake/addons/depends/windows/README | 19 + .../depends/windows/cmake/mingw/CMakeLists.txt | 37 ++ .../windows/cmake/mingw/MinGWConfig.cmake.in | 3 + .../windows/cmake/mingw/Toolchain_mingw32.cmake.in | 17 + cmake/addons/depends/windows/cmake/mingw/mingw.txt | 1 + .../depends/windows/cmake/mingw/mingw32-cmd.bat.in | 6 + .../depends/windows/cmake/mingw/noinstall.txt | 0 .../depends/windows/cmake/msys/CMakeLists.txt | 5 + cmake/addons/depends/windows/cmake/msys/msys.txt | 1 + .../depends/windows/cmake/msys/noinstall.txt | 0 cmake/addons/depends/windows/prebuilt/README | 21 + 28 files changed, 1002 insertions(+) create mode 100644 cmake/addons/CMakeLists.txt create mode 100644 cmake/addons/README.md create mode 100644 cmake/addons/addons/pvr.dvbviewer/platforms.txt create mode 100644 cmake/addons/addons/pvr.dvbviewer/pvr.dvbviewer.txt create mode 100644 cmake/addons/bootstrap/Bootstrap.cmake create mode 100644 cmake/addons/bootstrap/CMakeLists.txt create mode 100644 cmake/addons/bootstrap/README.md create mode 100644 cmake/addons/bootstrap/repositories/binary-addons.txt create mode 100644 cmake/addons/depends/CMakeLists.txt create mode 100644 cmake/addons/depends/README create mode 100644 cmake/addons/depends/common/kodi-platform/deps.txt create mode 100644 cmake/addons/depends/common/kodi-platform/kodi-platform.txt create mode 100644 cmake/addons/depends/common/p8-platform/p8-platform.txt create mode 100644 cmake/addons/depends/common/tinyxml/CMakeLists.txt create mode 100644 cmake/addons/depends/common/tinyxml/tinyxml.txt create mode 100644 cmake/addons/depends/windows/CMakeLists.txt create mode 100644 cmake/addons/depends/windows/Install.cmake create mode 100644 cmake/addons/depends/windows/README create mode 100644 cmake/addons/depends/windows/cmake/mingw/CMakeLists.txt create mode 100644 cmake/addons/depends/windows/cmake/mingw/MinGWConfig.cmake.in create mode 100644 cmake/addons/depends/windows/cmake/mingw/Toolchain_mingw32.cmake.in create mode 100644 cmake/addons/depends/windows/cmake/mingw/mingw.txt create mode 100644 cmake/addons/depends/windows/cmake/mingw/mingw32-cmd.bat.in create mode 100644 cmake/addons/depends/windows/cmake/mingw/noinstall.txt create mode 100644 cmake/addons/depends/windows/cmake/msys/CMakeLists.txt create mode 100644 cmake/addons/depends/windows/cmake/msys/msys.txt create mode 100644 cmake/addons/depends/windows/cmake/msys/noinstall.txt create mode 100644 cmake/addons/depends/windows/prebuilt/README (limited to 'cmake/addons') diff --git a/cmake/addons/CMakeLists.txt b/cmake/addons/CMakeLists.txt new file mode 100644 index 0000000..a6ea149 --- /dev/null +++ b/cmake/addons/CMakeLists.txt @@ -0,0 +1,439 @@ +cmake_minimum_required(VERSION 3.1) +project(kodi-addons) + +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) + +option(ADDON_TARBALL_CACHING "Cache downloaded addon source tarballs?" ON) +if(ADDON_TARBALL_CACHING) + message(STATUS "Addon source tarball caching is enabled") +else() + message(STATUS "Addon source tarball caching is disabled") +endif() + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +if(NOT CORE_SYSTEM_NAME) + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(CORE_SYSTEM_NAME "osx") + else() + string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME) + endif() +endif() + +include(ExternalProject) + +### setup all the necessary paths +if(APP_ROOT) + set(CORE_SOURCE_DIR ${APP_ROOT}) + unset(APP_ROOT) + message(WARNING "APP_ROOT is deprecated. Please use CORE_SOURCE_DIR instead.") +endif() +if(NOT CORE_SOURCE_DIR) + set(CORE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../..) +else() + file(TO_CMAKE_PATH "${CORE_SOURCE_DIR}" CORE_SOURCE_DIR) +endif() +get_filename_component(CORE_SOURCE_DIR "${CORE_SOURCE_DIR}" ABSOLUTE) + +if(NOT BUILD_DIR) + set(BUILD_DIR "${CMAKE_BINARY_DIR}/build") +else() + file(TO_CMAKE_PATH "${BUILD_DIR}" BUILD_DIR) +endif() +get_filename_component(BUILD_DIR "${BUILD_DIR}" ABSOLUTE) + +if(NOT ADDON_DEPENDS_PATH) + set(ADDON_DEPENDS_PATH "${BUILD_DIR}/depends") +else() + file(TO_CMAKE_PATH "${ADDON_DEPENDS_PATH}" ADDON_DEPENDS_PATH) +endif() +get_filename_component(ADDON_DEPENDS_PATH "${ADDON_DEPENDS_PATH}" ABSOLUTE) + +if(NOT PLATFORM_DIR) + set(PLATFORM_DIR ${CORE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}) + file(TO_CMAKE_PATH "${PLATFORM_DIR}" PLATFORM_DIR) +endif() + +# make sure CMAKE_PREFIX_PATH is set +if(NOT CMAKE_PREFIX_PATH) + set(CMAKE_PREFIX_PATH "${ADDON_DEPENDS_PATH}") +else() + file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH) + list(APPEND CMAKE_PREFIX_PATH "${ADDON_DEPENDS_PATH}") +endif() + +# check for autoconf stuff to pass on +if(AUTOCONF_FILES) + string(REPLACE " " ";" AUTOCONF_FILES ${AUTOCONF_FILES}) + set(CROSS_AUTOCONF "yes") +endif() + +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) + set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/output/addons") +endif() +list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}) + +set(BUILD_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} + -DCMAKE_INSTALL_PREFIX:PATH= + -DPACKAGE_CONFIG_PATH=${ADDON_DEPENDS_PATH}/lib/pkgconfig + -DADDON_DEPENDS_PATH=${ADDON_DEPENDS_PATH} + -DOVERRIDE_PATHS=${OVERRIDE_PATHS} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_USER_MAKE_RULES_OVERRIDE=${CMAKE_USER_MAKE_RULES_OVERRIDE} + -DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX=${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX} + -DCORE_SYSTEM_NAME=${CORE_SYSTEM_NAME} + -DBUILD_SHARED_LIBS=1 + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}) + +if(MSVC) + # move cmake specific targets to a CMakePredefinedTargets folder in Visual Studio + set_property(GLOBAL PROPERTY USE_FOLDERS ON) +endif() + +option(PACKAGE_ZIP "Prepare built addons for packaging" OFF) +if(PACKAGE_ZIP) + # needed for project installing + list(APPEND BUILD_ARGS -DPACKAGE_ZIP=ON) + + # figure out where to store the packaged ZIP archives + if(NOT PACKAGE_DIR) + set(PACKAGE_DIR "${BUILD_DIR}/zips") + else() + file(TO_CMAKE_PATH "${PACKAGE_DIR}" PACKAGE_DIR) + endif() + list(APPEND BUILD_ARGS -DPACKAGE_DIR=${PACKAGE_DIR}) + + message(STATUS "ZIP packaging enabled (destination: ${PACKAGE_DIR})") +endif() + +if(CMAKE_TOOLCHAIN_FILE) + list(APPEND BUILD_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + message(STATUS "Toolchain specified") + message(STATUS ${BUILD_ARGS}) +endif() + +if(NOT ADDONS_TO_BUILD) + set(ADDONS_TO_BUILD "all") +else() + string(STRIP "${ADDONS_TO_BUILD}" ADDONS_TO_BUILD) + message(STATUS "Building following addons: ${ADDONS_TO_BUILD}") + string(REPLACE " " ";" ADDONS_TO_BUILD ${ADDONS_TO_BUILD}) +endif() + +if(NOT ADDONS_DEFINITION_DIR) + set(ADDONS_DEFINITION_DIR ${PROJECT_SOURCE_DIR}/addons) +else() + file(TO_CMAKE_PATH "${ADDONS_DEFINITION_DIR}" ADDONS_DEFINITION_DIR) +endif() +get_filename_component(ADDONS_DEFINITION_DIR "${ADDONS_DEFINITION_DIR}" ABSOLUTE) + +if(ADDON_SRC_PREFIX) + if(NOT IS_ABSOLUTE ${ADDON_SRC_PREFIX}) + get_filename_component(ADDON_SRC_PREFIX "${CMAKE_BINARY_DIR}/${ADDON_SRC_PREFIX}" ABSOLUTE) + endif() + message(STATUS "Overriding addon source directory prefix: ${ADDON_SRC_PREFIX}") +endif() + +if(NOT APP_LIB_DIR) + set(APP_LIB_DIR "${ADDON_DEPENDS_PATH}/lib/kodi") +else() + file(TO_CMAKE_PATH "${APP_LIB_DIR}" APP_LIB_DIR) +endif() + +set(APP_PREFIX "${CMAKE_INSTALL_PREFIX}") + +# check for platform specific stuff +if(EXISTS ${PLATFORM_DIR}/defines.txt) + file(STRINGS ${PLATFORM_DIR}/defines.txt platformdefines) + + if(NOT ARCH_DEFINES AND platformdefines) + set(ARCH_DEFINES ${platformdefines}) + endif() +endif() + +# include check_target_platform() function +include(${CORE_SOURCE_DIR}/cmake/scripts/common/CheckTargetPlatform.cmake) + +set(ADDON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) +if(NOT WIN32) + # check install permissions + check_install_permissions(${CMAKE_INSTALL_PREFIX} can_write) + if(NOT ${can_write} AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(NEED_SUDO TRUE) + set(ADDON_INSTALL_DIR ${CMAKE_BINARY_DIR}/.install) + list(APPEND BUILD_ARGS -DOVERRIDE_PATHS=ON) + message(STATUS "NEED_SUDO: ${NEED_SUDO} (no write permission for ${CMAKE_INSTALL_PREFIX})") + endif() +endif() + +### prepare the build environment for the binary addons +# copy the PrepareEnv.cmake script to the depends path so that we can include it +file(COPY ${CORE_SOURCE_DIR}/cmake/scripts/common/PrepareEnv.cmake DESTINATION ${APP_LIB_DIR}) + +# add the location of PrepareEnv.cmake to CMAKE_MODULE_PATH so that it is found +list(APPEND CMAKE_MODULE_PATH ${APP_LIB_DIR}) + +# include PrepareEnv.cmake which contains the logic to install the addon header bindings etc +include(PrepareEnv) + +### add the depends subdirectory for any general dependencies +message(STATUS "\n-- ---- Preparing general dependencies ----") +add_subdirectory(depends) + +# add a custom target "package-addons" which will package and install all addons +add_custom_target(package-addons) + +### get and build all the binary addons +# look for all the addons to be built +file(GLOB_RECURSE addons ${ADDONS_DEFINITION_DIR}/*.txt) + +#if there are no addons assume that bootstrapping hasn't happened yet +if(NOT addons) + message(STATUS "Bootstrapping all default repositories as no addons were found...") + set(BOOTSTRAP_BUILD_DIR "${BUILD_DIR}/bootstrap") + + # make sure that the bootstraps build addon exists + if(NOT EXISTS ${BOOTSTRAP_BUILD_DIR}) + file(MAKE_DIRECTORY ${BOOTSTRAP_BUILD_DIR}) + endif() + + string(REPLACE ";" " " ADDONS_TO_BUILD_STR "${ADDONS_TO_BUILD}") + # generate the bootstrap buildsystem + execute_process(COMMAND ${CMAKE_COMMAND} ${PROJECT_SOURCE_DIR}/bootstrap + -DCMAKE_INSTALL_PREFIX:PATH=${ADDONS_DEFINITION_DIR} + -DBUILD_DIR:PATH=${BOOTSTRAP_BUILD_DIR} + -DADDONS_TO_BUILD:STRING=${ADDONS_TO_BUILD_STR} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + WORKING_DIRECTORY ${BOOTSTRAP_BUILD_DIR}) + + # execute the generated bootstrap buildsystem + execute_process(COMMAND ${CMAKE_COMMAND} --build ${BOOTSTRAP_BUILD_DIR} + WORKING_DIRECTORY ${BOOTSTRAP_BUILD_DIR}) + + # now look for all the addons to be built again + file(GLOB_RECURSE addons ${ADDONS_DEFINITION_DIR}/*.txt) + + if(NOT addons) + message(FATAL_ERROR "No addons available to be built") + endif() +endif() + +# Track if at least one addon has been found. Everything else is likely an +# error either in ADDONS_TO_BUILD or in the directory configuration. +set(SUPPORTED_ADDON_FOUND FALSE) + +foreach(addon ${addons}) + if(NOT (addon MATCHES platforms.txt)) + file(STRINGS ${addon} def) + string(REPLACE " " ";" def ${def}) + list(GET def 0 id) + + set(ADDON_FOUND FALSE) + # try to find a perfect match + list(FIND ADDONS_TO_BUILD ${id} idx) + if(idx GREATER -1 OR "${ADDONS_TO_BUILD}" STREQUAL "all") + set(ADDON_FOUND TRUE) + # Maybe we have a regex + elseif(id MATCHES "${ADDONS_TO_BUILD}") + message(STATUS "Pattern ${ADDONS_TO_BUILD} matches ${id}, building addon") + set(ADDON_FOUND TRUE) + endif() + + if(ADDON_FOUND) + message(STATUS "\n-- ---- Configuring addon ${addon} ----") + set(SUPPORTED_ADDON_FOUND TRUE) + + get_filename_component(dir ${addon} DIRECTORY) + + # check if the addon has a platforms.txt + set(platform_found FALSE) + check_target_platform(${dir} ${CORE_SYSTEM_NAME} platform_found) + + if(${platform_found}) + # make sure the output directory is clean + file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/${id}/") + + # get the URL and revision of the addon + list(LENGTH def deflength) + list(GET def 1 url) + + set(archive_name ${id}) + if(ADDON_SRC_PREFIX) + set(SOURCE_DIR ${ADDON_SRC_PREFIX}/${id}) + set(archive_name "") + else() + set(SOURCE_DIR "") + endif() + + # if there is a 3rd parameter in the file, we consider it a git revision + if(deflength GREATER 2 AND "${SOURCE_DIR}" STREQUAL "") + list(GET def 2 revision) + + # we need access to a git executable + find_package(Git REQUIRED) + + # resolve revision to git hash + execute_process(COMMAND ${GIT_EXECUTABLE} ls-remote ${url} ${revision} OUTPUT_VARIABLE revision_hash) + # git ls-remote only works on branches and tag names but not on revisions + if(NOT "${revision_hash}" STREQUAL "") + string(REPLACE "\t" ";" revision_list ${revision_hash}) + list(GET revision_list 0 revision_hash) + message(STATUS "${id}: git branch/tag ${revision} resolved to hash: ${revision_hash}") + set(revision ${revision_hash}) + endif() + + # Note: downloading specific revisions via http in the format below is probably github specific + # if we ever use other repositories, this might need adapting + set(url ${url}/archive/${revision}.tar.gz) + set(archive_name ${archive_name}-${revision}) + elseif("${SOURCE_DIR}" STREQUAL "") + # check if the URL starts with file:// + string(REGEX MATCH "^file://.*$" local_url "${url}") + + #if not we assume this to be a local directory + if(local_url) + # this is not an archive + set(archive_name "") + + # remove the file:// protocol from the URL + string(REPLACE "file://" "" SOURCE_DIR "${url}") + + # on win32 we may have to remove another leading / + if(WIN32) + # check if the path is a local path + string(REGEX MATCH "^/.*$" local_path "${SOURCE_DIR}") + if(local_path) + string(SUBSTRING "${SOURCE_DIR}" 1 -1 SOURCE_DIR) + endif() + endif() + endif() + endif() + + # download the addon if necessary + if(NOT "${archive_name}" STREQUAL "") + # download and extract the addon + if(NOT ADDON_TARBALL_CACHING OR NOT EXISTS ${BUILD_DIR}/download/${archive_name}.tar.gz) + # cleanup any of the previously downloaded archives of this addon + file(GLOB archives "${BUILD_DIR}/download/${id}*.tar.gz") + if(archives) + message(STATUS "Removing old archives of ${id}: ${archives}") + file(REMOVE ${archives}) + endif() + + # download the addon + file(DOWNLOAD "${url}" "${BUILD_DIR}/download/${archive_name}.tar.gz" STATUS dlstatus LOG dllog SHOW_PROGRESS) + list(GET dlstatus 0 retcode) + if(NOT ${retcode} EQUAL 0) + file(REMOVE ${BUILD_DIR}/download/${archive_name}.tar.gz) + message(STATUS "ERROR downloading ${url} - status: ${dlstatus} log: ${dllog}") + # add a dummy target for addons to get it in addons failure file + list(APPEND ALL_ADDONS_BUILDING ${id}) + add_custom_target(${id} COMMAND ${CMAKE_COMMAND} -E echo "IGNORED ${id} - download failed" COMMAND exit 1) + continue() + endif() + endif() + + # remove any previously extracted version of the addon + file(REMOVE_RECURSE "${BUILD_DIR}/${id}") + + # extract the addon from the archive + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${BUILD_DIR}/download/${archive_name}.tar.gz + WORKING_DIRECTORY ${BUILD_DIR}) + file(GLOB extract_dir "${BUILD_DIR}/${archive_name}*") + if(extract_dir STREQUAL "") + message(FATAL_ERROR "${id}: error extracting ${BUILD_DIR}/download/${archive_name}.tar.gz") + else() + file(RENAME "${extract_dir}" "${BUILD_DIR}/${id}") + endif() + + set(SOURCE_DIR ${BUILD_DIR}/${id}) + endif() + + if(NOT "${SOURCE_DIR}" STREQUAL "" AND EXISTS ${SOURCE_DIR}) + # create a list of addons we are building + list(APPEND ALL_ADDONS_BUILDING ${id}) + + # setup the buildsystem for the addon + externalproject_add(${id} + SOURCE_DIR ${SOURCE_DIR} + INSTALL_DIR ${ADDON_INSTALL_DIR} + CMAKE_ARGS ${BUILD_ARGS}) + + # add a custom step to the external project between the configure and the build step which will always + # be executed and therefore forces a re-build of all changed files + externalproject_add_step(${id} forcebuild + COMMAND ${CMAKE_COMMAND} -E echo "Force build of ${id}" + DEPENDEES configure + DEPENDERS build + ALWAYS 1) + + # add "kodi-platform" as a dependency to every addon + add_dependencies(${id} kodi-platform) + + set(${id}_DEPENDS_DIR ${SOURCE_DIR}/depends) + + if(EXISTS ${${id}_DEPENDS_DIR}) + include(${CORE_SOURCE_DIR}/cmake/scripts/common/HandleDepends.cmake) + add_addon_depends(${id} ${${id}_DEPENDS_DIR}) + if(${id}_DEPS AND NOT "${${id}_DEPS}" STREQUAL "") + message(STATUS "${id} DEPENDENCIES: ${${id}_DEPS}") + add_dependencies(${id} ${${id}_DEPS}) + endif() + endif() + + if(CROSS_AUTOCONF AND AUTOCONF_FILES) + if(EXISTS ${SOURCE_DIR}/bootstrap/autoreconf.txt) + file(STRINGS ${SOURCE_DIR}/bootstrap/autoreconf.txt conf_dirs) + foreach(conf_dir ${conf_dirs}) + foreach(afile ${AUTOCONF_FILES}) + message(STATUS "copying ${afile} to ${SOURCE_DIR}/${conf_dir}") + file(COPY ${afile} DESTINATION ${SOURCE_DIR}/${conf_dir}) + endforeach() + endforeach() + endif() + endif() + + # create a forwarding target to the addon-package target + add_custom_target(package-${id} + COMMAND ${CMAKE_COMMAND} --build ${id}-prefix/src/${id}-build --target addon-package + DEPENDS ${id}) + add_dependencies(package-addons package-${id}) + + else() + message(FATAL_ERROR "${id}: invalid or missing addon source directory at ${SOURCE_DIR}") + endif() + else() + # add a dummy target for addons that are unsupported on this platform + add_custom_target(${id} COMMAND ${CMAKE_COMMAND} -E echo "IGNORED ${id} - not supported on ${CORE_SYSTEM_NAME}\n") + endif() + endif() + endif() +endforeach() +message(STATUS "") + +if(NEED_SUDO) + add_custom_target(sudo-install + COMMAND ${CMAKE_COMMAND} -E echo "sudo rights needed to install to ${CMAKE_INSTALL_PREFIX}\n" + COMMAND sudo ${CMAKE_COMMAND} -E copy_directory ${ADDON_INSTALL_DIR}/ ${CMAKE_INSTALL_PREFIX}/ + COMMAND sudo -k) + + foreach(_id ${ALL_ADDONS_BUILDING}) + add_dependencies(sudo-install ${_id}) + endforeach() + message(WARNING "sudo rights needed to install to ${CMAKE_INSTALL_PREFIX}") + message(STATUS "\nplease type \"make sudo-install\"\n\n") +endif() + +if(NOT SUPPORTED_ADDON_FOUND) + message(FATAL_ERROR "${ADDONS_TO_BUILD} did not match any of the supported addons. \ + A list of supported addons can be viewed by building the 'supported_addons' target. \ + Addon definitions are loaded from ADDONS_DEFINITION_DIR (${ADDONS_DEFINITION_DIR}).") +endif() + +# add custom target "supported_addons" that returns all addons that are supported on this platform +string(REPLACE ";" " " ALL_ADDONS_BUILDING "${ALL_ADDONS_BUILDING}") +add_custom_target(supported_addons COMMAND ${CMAKE_COMMAND} -E echo "ALL_ADDONS_BUILDING: ${ALL_ADDONS_BUILDING}" VERBATIM) +add_custom_target(need-sudo COMMAND ${CMAKE_COMMAND} -E echo ${NEED_SUDO} VERBATIM) diff --git a/cmake/addons/README.md b/cmake/addons/README.md new file mode 100644 index 0000000..6470ee1 --- /dev/null +++ b/cmake/addons/README.md @@ -0,0 +1,65 @@ +![Kodi logo](https://raw.githubusercontent.com/xbmc/xbmc-forum/master/xbmc/images/logo-sbs-black.png) +# Kodi add-ons CMake based buildsystem +This directory contains the cmake-based buildsystem for Kodi add-ons. It looks into the directory pointed to by the *ADDONS_DEFINITION_DIR* option (which defaults to the *addons* sub-directory) and parses all *.txt files recursively. Each add-on must have its own `.txt` file in a separate sub-directory that must follow one of the defined formats: + + - ` ` + - ` ` + - ` ` + +where +- `` must be identical to the add-on's ID as defined in the add-on's addon.xml +- `` must be the URL of the git repository containing the add-on +- `` must be a valid git tag/branch/commit in the add-on's git repository which will be used for the build +- `` must be the URL to a .tar.gz tarball containing the add-on +- `` must be a *file://* based path to the directory containing the add-on + +## Reserved filenames +- **platforms.txt** + +List of platforms to build an add-on for (or *all*). Negating platforms is supported using a leading exclamation mark, e.g. *!windows*. + +Available platforms are: linux, windows, osx, ios, android, rbpi and freebsd. + +#### Attention +If no add-on definitions could be found, the buildsystem assumes that the bootstrapping of the add-on definition repositories hasn't been performed yet and automatically executes the add-on bootstrapping buildsystem located in the *bootstrap* sub-directory with the default settings (i.e. *all* add-ons from all pre-defined add-on definition repositories are bootstrapped into the directory pointed to by the *ADDONS_DEFINITION_DIR* option). + +## Buildsystem variables +The buildsystem uses the following variables (which can be passed into it when executing cmake with the -D`=` format) to manipulate the build process: +- `ADDONS_TO_BUILD` has two variations, which are tested in order: + - a quoted, space delimited list of `s` that you want to build (default is *all*) + - a regular expression that every `` is matched against (e.g. `ADDONS_TO_BUILD="pvr.*"`) to build all pvr add-ons +- `ADDONS_DEFINITION_DIR` points to the directory containing the definitions for the addons to be built +- `ADDON_SRC_PREFIX` can be used to override the add-on repository location. It must point to the locally available parent directory of the add-on(s) to build. `` will be appended to this path automatically +- `CMAKE_BUILD_TYPE` specifies the type of the build. This can be either *Debug* or *Release* (default is *Release*) +- `CMAKE_INSTALL_PREFIX` points to the directory where the built add-ons and their additional files (addon.xml, resources, ...) will be installed to (defaults to ``) +- `CMAKE_TOOLCHAIN_FILE` can be used to pass a toolchain file into the add-on builds +- `ADDON_DEPENDS_PATH` points to the directory containing the *include* and *lib* directories of the add-ons' dependencies. +- `CORE_SOURCE_DIR` points to the root directory of the project (default is the absolute representation of ../../.. starting from this directory) +- `BUILD_DIR` points to the directory where the add-ons and their dependencies will be downloaded and built +- `PACKAGE_ZIP=ON` means that the add-ons will be 'packaged' into a common folder, rather than being placed in `/lib/kodi/addons` and `/share/kodi/addons` +- `PACKAGE_DIR` points to the directory where the ZIP archived add-ons will be stored after they have been packaged (defaults to `/zips`) +- `ARCH_DEFINES` specifies the platform-specific C/C++ preprocessor defines (defaults to empty) +- `ADDON_TARBALL_CACHING` specifies whether downloaded add-on source tarballs should be cached or not (defaults to *ON*) + +## Deprecated buildsystem variables +Buildsystem will print a warning if you use any of the below-listed variables. For now they still work but you should adapt your workflow to the new variables. +- `APP_ROOT` - Use `CORE_SOURCE_DIR` instead + +## Building +The buildsystem makes some assumptions about the environment which must be met by whoever uses it: +- Any dependencies of the add-ons must already be built and their include and library files must be present in the path pointed to by `` (in *include* and *lib* sub-directories) + +To trigger the cmake-based buildsystem the following command must be executed with `` set to this directory (absolute or relative) allowing for in-source and out-of-source builds + +`cmake -G ` + +CMake supports multiple generators. See [here] (https://cmake.org/cmake/help/v3.1/manual/cmake-generators.7.html) for a list. + +In case of additional options the call might look like this: + +cmake `` [-G ``] \ + -DCMAKE_BUILD_TYPE=Release \ + -DCORE_SOURCE_DIR="``" \ + -DARCH_DEFINES="-DTARGET_LINUX" \ + -DADDON_DEPENDS_PATH=`` \ + -DCMAKE_INSTALL_PREFIX="` + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + -P ${PROJECT_SOURCE_DIR}/Bootstrap.cmake + ) +endfunction() + +# look for all addons repository definitions +set(REPOSITORY_TO_BUILD_FOUND OFF) +file(GLOB repos repositories/*.txt) +foreach(repo ${repos}) + file(STRINGS ${repo} repo_definition) + string(REPLACE " " ";" repo_definition ${repo_definition}) + list(GET repo_definition 0 repo_id) + + list(FIND REPOSITORY_TO_BUILD ${repo_id} idx) + if(idx GREATER -1 OR REPOSITORY_TO_BUILD STREQUAL "all") + set(REPOSITORY_TO_BUILD_FOUND ON) + + # get the URL of the repository + list(GET repo_definition 1 repo_url) + + # get the revision of the repository if not provided as an argument + if(NOT REPOSITORY_REVISION) + list(GET repo_definition 2 repo_revision) + else() + set(repo_revision "${REPOSITORY_REVISION}") + endif() + + bootstrap_repo(${repo_id} ${repo_url} ${repo_revision}) + endif() +endforeach() + +# if we have been asked to bootstrap a specific repository (not the default one) and +# it couldn't be found in the predefined repository definitions we assume that it's a +# URL to a specific repository +if(NOT REPOSITORY_TO_BUILD_DEFAULT AND NOT REPOSITORY_TO_BUILD_FOUND) + # default to the master branch if no revision has been provided + if(NOT REPOSITORY_REVISION) + set(REPOSITORY_REVISION "master") + endif() + + bootstrap_repo(binary-addons-custom ${REPOSITORY_TO_BUILD} ${REPOSITORY_REVISION}) +endif() diff --git a/cmake/addons/bootstrap/README.md b/cmake/addons/bootstrap/README.md new file mode 100644 index 0000000..b886b5b --- /dev/null +++ b/cmake/addons/bootstrap/README.md @@ -0,0 +1,48 @@ +# KODI ADDON DEFINITIONS BOOTSTRAPPING +This directory contains the cmake-based buildsystem for addon definitions +bootstrapping which downloads the addon definitions from one or more addon +definitions repositories. These addon definitions are then used by the addon +buildsystem to figure out which addons and which versions to build. It looks +into the "repositories" sub-directory and parses all *.txt files recursively. +Each addon definitions repository must have its own .txt file which +must follow the following defined format: +``` + +``` +where +* `` is the identification of the repository. +* `` must be the URL of the git repository containing the addon + definitions +* `` must be a valid git tag/branch/commit in the addon + definitions repository's git repository which will be used for the build + +The buildsystem uses the following variables (which can be passed into it when +executing cmake with the `-D=` option): +* `CMAKE_INSTALL_PREFIX` points to the directory where the downloaded addon +definitions will be installed to (defaults to `../addons`). +* `BUILD_DIR` points to the directory where the addon definitions repositories +will be downloaded to. +* `REPOSITORY_TO_BUILD` specifies a single addon definitions repository to be +downloaded and processed (defaults to `"all"`). +* `REPOSITORY_REVISION` specifies the git revision in the addon definitions +repository which will be used for the build. This option is only valid in +combination with the `REPOSITORY_TO_BUILD` option (defaults to the git +revision specified in the repository's definition file). +* `ADDONS_TO_BUILD` is a quoted, space delimited list of ``s that +should be bootstrapped (default is `"all"`). + +To trigger the cmake-based buildsystem the following command must be executed +with being the path to this directory (absolute or relative, allowing for +in-source and out-of-source builds). +``` +cmake -G +``` + +cmake supports multiple generators, see +http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators for a list. + +In case of additional options the call might look like this +``` +cmake [-G ] \ + -DCMAKE_INSTALL_PREFIX="" +``` \ No newline at end of file diff --git a/cmake/addons/bootstrap/repositories/binary-addons.txt b/cmake/addons/bootstrap/repositories/binary-addons.txt new file mode 100644 index 0000000..8674f06 --- /dev/null +++ b/cmake/addons/bootstrap/repositories/binary-addons.txt @@ -0,0 +1 @@ +binary-addons https://github.com/xbmc/repo-binary-addons.git master \ No newline at end of file diff --git a/cmake/addons/depends/CMakeLists.txt b/cmake/addons/depends/CMakeLists.txt new file mode 100644 index 0000000..831e0ed --- /dev/null +++ b/cmake/addons/depends/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.1) +project(kodi-addons-depends) + +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +if(NOT CORE_SYSTEM_NAME) + string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME) +endif() + +include(ExternalProject) + +if(NOT ADDON_DEPENDS_PATH) + set(ADDON_DEPENDS_PATH ${PROJECT_SOURCE_DIR}/../build/depends) +else() + file(TO_CMAKE_PATH "${ADDON_DEPENDS_PATH}" ADDON_DEPENDS_PATH) +endif() +get_filename_component(ADDON_DEPENDS_PATH "${ADDON_DEPENDS_PATH}" ABSOLUTE) +list(APPEND CMAKE_PREFIX_PATH ${ADDON_DEPENDS_PATH}) + +if(NOT BUILD_DIR) + set(BUILD_DIR "${CMAKE_BINARY_DIR}/build") +else() + file(TO_CMAKE_PATH "${BUILD_DIR}" BUILD_DIR) +endif() +get_filename_component(BUILD_DIR "${BUILD_DIR}" ABSOLUTE) + +## use add_addon_depends to handle the cmake based dependencies +include(${CORE_SOURCE_DIR}/cmake/scripts/common/HandleDepends.cmake) +add_addon_depends(depends "${PROJECT_SOURCE_DIR}") + +## if there's a platform-specific sub-directory containing a CMakeLists.txt, add it to the build as well +if(EXISTS ${PROJECT_SOURCE_DIR}/${CORE_SYSTEM_NAME}/CMakeLists.txt) + message(STATUS "Processing ${CORE_SYSTEM_NAME}") + add_subdirectory(${CORE_SYSTEM_NAME}) +else() + message(STATUS "No platform specific file ${PROJECT_SOURCE_DIR}/${CORE_SYSTEM_NAME}/CMakeLists.txt found") +endif() diff --git a/cmake/addons/depends/README b/cmake/addons/depends/README new file mode 100644 index 0000000..584a167 --- /dev/null +++ b/cmake/addons/depends/README @@ -0,0 +1,61 @@ +KODI ADDON DEPENDENCIES +======================= +This directory contains the cmake-based buildsystem for addon dependencies. It +looks into the "common" and the "/cmake" sub-directories and parses +all *.txt files recursively. Each dependency must have its own .txt +file (either in the main sub-directory or in a separate subdirectory of the main +subdirectory) which must follow one of the defined formats: + * an empty file means that no extra downloads are necessary + * + * + * +where + * must be identical to the filename + * must be the URL to an archive that is downloaded and extracted. + * must be the URL of the git repository containing the + dependency. + * must be a valid git tag/branch/commit in the dependency's git + repository which will be used for the build. + +Reserved filenames (for additional information on how to build a dependency) +are: + * CMakeLists.txt: build instructions for the dependency + * install.txt: instructions on how to install the dependency's built files + * noinstall.txt: no installation step required (content is ignored) + * flags.txt: additional build flags + * deps.txt: whitespace separated list of dependencies of this dependency + +The buildsystem uses the following variables (which can be passed into it when +executing cmake with the -D= option) to e.g. access +specific paths: + * CMAKE_BUILD_TYPE specifies the type of the build. This can be either "Debug" + or "Release" (default is "Release"). + * CMAKE_TOOLCHAIN_FILE can be used to pass a toolchain file into the add-on + builds. + * CORE_SYSTEM_NAME is the name of the platform (e.g. "linux" or "android") in + lower-case (defaults to lowercase(CMAKE_SYSTEM_NAME)). + * CORE_SOURCE_DIR points to the root directory of the project (default is the + absolute representation of ../../.. starting from this directory). + * ADDON_DEPENDS_PATH points to the directory where the built dependencies + (their include and library file) will be installed to. + * ARCH_DEFINES specifies the platform-specific C/C++ preprocessor defines + (defaults to empty). + * DEPENDS_TO_BUILD is a quoted, space delimited list of s that + you want to build (default is "all"). + +To trigger the cmake-based buildsystem the following command must be executed +with being the path to this directory (absolute or relative, allowing for +in-source and out-of-source builds). + + cmake -G + +cmake supports multiple generators, see +http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators for a list. + +In case of additional options the call might look like this + + cmake [-G ] \ + -DCMAKE_BUILD_TYPE=Release \ + -DCORE_SOURCE_DIR="" \ + -DARCH_DEFINES="-DTARGET_LINUX" \ + -DCMAKE_INSTALL_PREFIX=" being the path to this directory (absolute or relative, allowing for +in-source and out-of-source builds). + + cmake [-G ] + +cmake supports multiple generators, see +http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators for a list. +For win32 builds one of the "Visual Studio XX" or the "NMake Makefiles" +generators is preferred. For the "NMake Makefiles" generator to work the above +command must be called from an environment prepared for VC++ builds (see +http://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx). diff --git a/cmake/addons/depends/windows/cmake/mingw/CMakeLists.txt b/cmake/addons/depends/windows/cmake/mingw/CMakeLists.txt new file mode 100644 index 0000000..02d9724 --- /dev/null +++ b/cmake/addons/depends/windows/cmake/mingw/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.1) +project(mingw) + +function(generate_mingw32_wrapper cmd) + set(CMD ${cmd}) + configure_file(${PROJECT_SOURCE_DIR}/mingw32-cmd.bat.in ${MINGW_PATH}/bin/${CMD}.bat @ONLY) +endfunction() + +get_filename_component(CORE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../../../../.. REALPATH) + +set(MSYS_PATH "${CORE_SOURCE_DIR}/project/BuildDependencies/msys64") +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(MINGW_PATH "${MSYS_PATH}/mingw32") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(MINGW_PATH "${MSYS_PATH}/mingw64") +endif() + +# configure the MinGW toolchain file +configure_file(${PROJECT_SOURCE_DIR}/Toolchain_mingw32.cmake.in ${CMAKE_INSTALL_PREFIX}/Toolchain_mingw32.cmake @ONLY) + +# configure MinGWConfig.cmake +configure_file(${PROJECT_SOURCE_DIR}/MinGWConfig.cmake.in ${CMAKE_INSTALL_PREFIX}/MinGWConfig.cmake) + +# TODO: MinGW GCC 5.3.0-1 comes without cc.exe, Remove this once package is bumped to 5.3.0-p2 +# See https://github.com/Alexpux/MINGW-packages/pull/1034 +if(NOT EXISTS ${MINGW_PATH}/bin/cc.exe) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${MINGW_PATH}/bin/gcc.exe ${MINGW_PATH}/bin/cc.exe) +endif() + +# configure the MinGW wrapper batch scripts +generate_mingw32_wrapper("make") +generate_mingw32_wrapper("gcc") +generate_mingw32_wrapper("cc") +generate_mingw32_wrapper("g++") +generate_mingw32_wrapper("ar") +generate_mingw32_wrapper("ld") +generate_mingw32_wrapper("windres") diff --git a/cmake/addons/depends/windows/cmake/mingw/MinGWConfig.cmake.in b/cmake/addons/depends/windows/cmake/mingw/MinGWConfig.cmake.in new file mode 100644 index 0000000..2d6baa7 --- /dev/null +++ b/cmake/addons/depends/windows/cmake/mingw/MinGWConfig.cmake.in @@ -0,0 +1,3 @@ +set(MINGW_INCLUDE_DIRS @MINGW_PATH@/include) +set(MINGW_MAKE @MINGW_PATH@/bin/make.bat -j$ENV{NUMBER_OF_PROCESSORS}) +set(MINGW_FOUND 1) diff --git a/cmake/addons/depends/windows/cmake/mingw/Toolchain_mingw32.cmake.in b/cmake/addons/depends/windows/cmake/mingw/Toolchain_mingw32.cmake.in new file mode 100644 index 0000000..01d281d --- /dev/null +++ b/cmake/addons/depends/windows/cmake/mingw/Toolchain_mingw32.cmake.in @@ -0,0 +1,17 @@ +set(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_SYSTEM_NAME Windows) + +set(CMAKE_FIND_ROOT_PATH @CMAKE_FIND_ROOT_PATH@ @CMAKE_INSTALL_PREFIX@ @MSYS_PATH@ @MINGW_PATH@) + +# specify the cross compiler +set(CMAKE_C_COMPILER @MINGW_PATH@/bin/gcc.bat) +set(CMAKE_CXX_COMPILER @MINGW_PATH@/bin/g++.bat) +set(CMAKE_AR @MINGW_PATH@/bin/ar.bat CACHE FILEPATH "Archiver") +set(CMAKE_LINKER @MINGW_PATH@/bin/ld.bat CACHE FILEPATH "Linker") +SET(CMAKE_RC_COMPILER @MINGW_PATH@/bin/windres.bat) + +# search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/addons/depends/windows/cmake/mingw/mingw.txt b/cmake/addons/depends/windows/cmake/mingw/mingw.txt new file mode 100644 index 0000000..90aa6ae --- /dev/null +++ b/cmake/addons/depends/windows/cmake/mingw/mingw.txt @@ -0,0 +1 @@ +mingw diff --git a/cmake/addons/depends/windows/cmake/mingw/mingw32-cmd.bat.in b/cmake/addons/depends/windows/cmake/mingw/mingw32-cmd.bat.in new file mode 100644 index 0000000..44a0ea2 --- /dev/null +++ b/cmake/addons/depends/windows/cmake/mingw/mingw32-cmd.bat.in @@ -0,0 +1,6 @@ +@ECHO OFF +SETLOCAL + +SET PATH=@MINGW_PATH@/bin;@MSYS_PATH@/usr/bin;%PATH% +@CMD@.exe %* + diff --git a/cmake/addons/depends/windows/cmake/mingw/noinstall.txt b/cmake/addons/depends/windows/cmake/mingw/noinstall.txt new file mode 100644 index 0000000..e69de29 diff --git a/cmake/addons/depends/windows/cmake/msys/CMakeLists.txt b/cmake/addons/depends/windows/cmake/msys/CMakeLists.txt new file mode 100644 index 0000000..1c0536e --- /dev/null +++ b/cmake/addons/depends/windows/cmake/msys/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.1) +project(msys LANGUAGES NONE) + +# This is an empty dummy dependency because a lot of game addons depend on it. +# After they got fixed, this can be removed. diff --git a/cmake/addons/depends/windows/cmake/msys/msys.txt b/cmake/addons/depends/windows/cmake/msys/msys.txt new file mode 100644 index 0000000..00de9c2 --- /dev/null +++ b/cmake/addons/depends/windows/cmake/msys/msys.txt @@ -0,0 +1 @@ +msys diff --git a/cmake/addons/depends/windows/cmake/msys/noinstall.txt b/cmake/addons/depends/windows/cmake/msys/noinstall.txt new file mode 100644 index 0000000..e69de29 diff --git a/cmake/addons/depends/windows/prebuilt/README b/cmake/addons/depends/windows/prebuilt/README new file mode 100644 index 0000000..a0c70d6 --- /dev/null +++ b/cmake/addons/depends/windows/prebuilt/README @@ -0,0 +1,21 @@ +KODI WIN32 PREBUILT ADDON DEPENDENCIES +====================================== +This directory contains a file or sub-directory for every prebuilt dependency +used by one of the addons being built. There are two different modes supported. +Both include a file named .txt which must follow the defined format + + +If the archive, which the points at, contains + * only the necessary files and in the proper directory structure (i.e. an + "include" and a "lib" directory) then the file must be put into this + directory and nothing else is needed. + * unnecessary files and/or does not follow the defined directory structure + (i.e. an "include" and a "lib" directory) then the file must be put into a + sub-directory named . Furthermore an additional file called + "install.txt" must be placed in that sub-directory. install.txt contains a + line for every path/directory/file with a destination where it must be copied + to. It must follow the defined format + [] + where must be an existing file, directory or a path containing + wildcards, and the optional must be existing + directories. -- cgit v1.2.3