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/bootstrap/Bootstrap.cmake | 39 +++++++++ cmake/addons/bootstrap/CMakeLists.txt | 93 ++++++++++++++++++++++ cmake/addons/bootstrap/README.md | 48 +++++++++++ .../bootstrap/repositories/binary-addons.txt | 1 + 4 files changed, 181 insertions(+) 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 (limited to 'cmake/addons/bootstrap') diff --git a/cmake/addons/bootstrap/Bootstrap.cmake b/cmake/addons/bootstrap/Bootstrap.cmake new file mode 100644 index 0000000..5d20302 --- /dev/null +++ b/cmake/addons/bootstrap/Bootstrap.cmake @@ -0,0 +1,39 @@ +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) + +# make sure that the installation location has been specified +if(NOT CMAKE_INSTALL_PREFIX) + message(FATAL_ERROR "CMAKE_INSTALL_PREFIX has not been specified") +endif() + +# figure out which addons to bootstrap (defaults to all) +if(NOT ADDONS_TO_BUILD) + set(ADDONS_TO_BUILD "all") +else() + string(STRIP "${ADDONS_TO_BUILD}" ADDONS_TO_BUILD) + message(STATUS "Bootstrapping following addons: ${ADDONS_TO_BUILD}") + string(REPLACE " " ";" ADDONS_TO_BUILD ${ADDONS_TO_BUILD}) +endif() + +# find all addon definitions and go through them +file(GLOB_RECURSE ADDON_DEFINITIONS ${PROJECT_SOURCE_DIR}/*.txt) +foreach(ADDON_DEFINITION_FILE ${ADDON_DEFINITIONS}) + # ignore platforms.txt + if(NOT (ADDON_DEFINITION_FILE MATCHES platforms.txt)) + # read the addon definition file + file(STRINGS ${ADDON_DEFINITION_FILE} ADDON_DEFINITION) + string(REPLACE " " ";" ADDON_DEFINITION ${ADDON_DEFINITION}) + + # extract the addon definition's identifier + list(GET ADDON_DEFINITION 0 ADDON_ID) + + # check if the addon definition should be built + if(ADDON_ID MATCHES "^${ADDONS_TO_BUILD}" OR ADDONS_TO_BUILD STREQUAL all) + # get the path to the addon definition directory + get_filename_component(ADDON_DEFINITION_DIR ${ADDON_DEFINITION_FILE} DIRECTORY) + + # install the addon definition + message(STATUS "Bootstrapping ${ADDON_ID} addon...") + file(INSTALL ${ADDON_DEFINITION_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}) + endif() + endif() +endforeach() diff --git a/cmake/addons/bootstrap/CMakeLists.txt b/cmake/addons/bootstrap/CMakeLists.txt new file mode 100644 index 0000000..66b7e3d --- /dev/null +++ b/cmake/addons/bootstrap/CMakeLists.txt @@ -0,0 +1,93 @@ +cmake_minimum_required(VERSION 3.1) +project(kodi-addons-bootstrap) + +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) + +# make sure CMAKE_INSTALL_PREFIX is properly set +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) + set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/../addons") +endif() +list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}) + +# figure out where the build directory is located +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) + +# make sure that the repositories to build have been specified +if(NOT REPOSITORY_TO_BUILD) + set(REPOSITORY_TO_BUILD_DEFAULT ON) + set(REPOSITORY_TO_BUILD "all") + set(REPOSITORY_REVISION "") + message(STATUS "Bootstrapping all repositories") +else() + set(REPOSITORY_TO_BUILD_DEFAULT OFF) + message(STATUS "Bootstrapping following repository: ${REPOSITORY_TO_BUILD}") +endif() + +# figure out which addons to bootstrap (defaults to all) +if(NOT ADDONS_TO_BUILD) + set(ADDONS_TO_BUILD "all") + message(STATUS "Bootstrapping all addons") +else() + message(STATUS "Bootstrapping following addons: ${ADDONS_TO_BUILD}") +endif() + +include(ExternalProject) + +function(bootstrap_repo repo_id repo_url repo_revision) + message(STATUS "Bootstrapping addons from ${repo_id} (${repo_url} ${repo_revision})...") + externalproject_add(${repo_id} + GIT_REPOSITORY ${repo_url} + GIT_TAG ${repo_revision} + PREFIX ${BUILD_DIR}/${repo_id} + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} + -DPROJECT_SOURCE_DIR= + -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 -- cgit v1.2.3