diff options
Diffstat (limited to 'project/cmake/addons/bootstrap')
| -rw-r--r-- | project/cmake/addons/bootstrap/CMakeLists.txt | 95 | ||||
| -rw-r--r-- | project/cmake/addons/bootstrap/README.md | 48 | ||||
| -rw-r--r-- | project/cmake/addons/bootstrap/bootstrap.cmake | 38 | ||||
| -rw-r--r-- | project/cmake/addons/bootstrap/repositories/binary-addons.txt | 1 |
4 files changed, 182 insertions, 0 deletions
diff --git a/project/cmake/addons/bootstrap/CMakeLists.txt b/project/cmake/addons/bootstrap/CMakeLists.txt new file mode 100644 index 0000000..86950b8 --- /dev/null +++ b/project/cmake/addons/bootstrap/CMakeLists.txt | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | project(kodi-addons-bootstrap) | ||
| 2 | |||
| 3 | cmake_minimum_required(VERSION 2.8) | ||
| 4 | |||
| 5 | list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) | ||
| 6 | |||
| 7 | # make sure CMAKE_INSTALL_PREFIX is properly set | ||
| 8 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) | ||
| 9 | set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/../addons") | ||
| 10 | endif() | ||
| 11 | list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}) | ||
| 12 | |||
| 13 | # figure out where the build directory is located | ||
| 14 | if(NOT BUILD_DIR) | ||
| 15 | set(BUILD_DIR "${CMAKE_BINARY_DIR}/build") | ||
| 16 | else() | ||
| 17 | file(TO_CMAKE_PATH "${BUILD_DIR}" BUILD_DIR) | ||
| 18 | endif() | ||
| 19 | get_filename_component(BUILD_DIR "${BUILD_DIR}" ABSOLUTE) | ||
| 20 | |||
| 21 | # make sure that the repositories to build have been specified | ||
| 22 | if(NOT REPOSITORY_TO_BUILD) | ||
| 23 | set(REPOSITORY_TO_BUILD_DEFAULT ON) | ||
| 24 | set(REPOSITORY_TO_BUILD "all") | ||
| 25 | set(REPOSITORY_REVISION "") | ||
| 26 | message(STATUS "Bootstrapping all repositories") | ||
| 27 | else() | ||
| 28 | set(REPOSITORY_TO_BUILD_DEFAULT OFF) | ||
| 29 | message(STATUS "Bootstrapping following repository: ${REPOSITORY_TO_BUILD}") | ||
| 30 | endif() | ||
| 31 | |||
| 32 | # figure out which addons to bootstrap (defaults to all) | ||
| 33 | if(NOT ADDONS_TO_BUILD) | ||
| 34 | set(ADDONS_TO_BUILD "all") | ||
| 35 | message(STATUS "Bootstrapping all addons") | ||
| 36 | else() | ||
| 37 | message(STATUS "Bootstrapping following addons: ${ADDONS_TO_BUILD}") | ||
| 38 | endif() | ||
| 39 | |||
| 40 | include(ExternalProject) | ||
| 41 | |||
| 42 | function(bootstrap_repo repo_id repo_url repo_revision) | ||
| 43 | message(STATUS "Bootstrapping addons from ${repo_id} (${repo_url} ${repo_revision})...") | ||
| 44 | externalproject_add(${repo_id} | ||
| 45 | GIT_REPOSITORY ${repo_url} | ||
| 46 | GIT_TAG ${repo_revision} | ||
| 47 | PREFIX ${BUILD_DIR}/${repo_id} | ||
| 48 | CONFIGURE_COMMAND "" | ||
| 49 | BUILD_COMMAND "" | ||
| 50 | INSTALL_COMMAND ${CMAKE_COMMAND} | ||
| 51 | -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} | ||
| 52 | -DPROJECT_SOURCE_DIR=<SOURCE_DIR> | ||
| 53 | -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} | ||
| 54 | -DADDONS_TO_BUILD=${ADDONS_TO_BUILD} | ||
| 55 | -P ${PROJECT_SOURCE_DIR}/bootstrap.cmake | ||
| 56 | ) | ||
| 57 | endfunction() | ||
| 58 | |||
| 59 | # look for all addons repository definitions | ||
| 60 | set(REPOSITORY_TO_BUILD_FOUND OFF) | ||
| 61 | file(GLOB repos repositories/*.txt) | ||
| 62 | foreach(repo ${repos}) | ||
| 63 | file(STRINGS ${repo} repo_definition) | ||
| 64 | separate_arguments(repo_definition) | ||
| 65 | list(GET repo_definition 0 repo_id) | ||
| 66 | |||
| 67 | list(FIND REPOSITORY_TO_BUILD ${repo_id} idx) | ||
| 68 | if(idx GREATER -1 OR REPOSITORY_TO_BUILD STREQUAL "all") | ||
| 69 | set(REPOSITORY_TO_BUILD_FOUND ON) | ||
| 70 | |||
| 71 | # get the URL of the repository | ||
| 72 | list(GET repo_definition 1 repo_url) | ||
| 73 | |||
| 74 | # get the revision of the repository if not provided as an argument | ||
| 75 | if(NOT REPOSITORY_REVISION) | ||
| 76 | list(GET repo_definition 2 repo_revision) | ||
| 77 | else() | ||
| 78 | set(repo_revision "${REPOSITORY_REVISION}") | ||
| 79 | endif() | ||
| 80 | |||
| 81 | bootstrap_repo(${repo_id} ${repo_url} ${repo_revision}) | ||
| 82 | endif() | ||
| 83 | endforeach() | ||
| 84 | |||
| 85 | # if we have been asked to bootstrap a specific repository (not the default one) and | ||
| 86 | # it couldn't be found in the predefined repository definitions we assume that it's a | ||
| 87 | # URL to a specific repository | ||
| 88 | if(NOT REPOSITORY_TO_BUILD_DEFAULT AND NOT REPOSITORY_TO_BUILD_FOUND) | ||
| 89 | # default to the master branch if no revision has been provided | ||
| 90 | if(NOT REPOSITORY_REVISION) | ||
| 91 | set(REPOSITORY_REVISION "master") | ||
| 92 | endif() | ||
| 93 | |||
| 94 | bootstrap_repo(binary-addons-custom ${REPOSITORY_TO_BUILD} ${REPOSITORY_REVISION}) | ||
| 95 | endif() | ||
diff --git a/project/cmake/addons/bootstrap/README.md b/project/cmake/addons/bootstrap/README.md new file mode 100644 index 0000000..b886b5b --- /dev/null +++ b/project/cmake/addons/bootstrap/README.md | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | # KODI ADDON DEFINITIONS BOOTSTRAPPING | ||
| 2 | This directory contains the cmake-based buildsystem for addon definitions | ||
| 3 | bootstrapping which downloads the addon definitions from one or more addon | ||
| 4 | definitions repositories. These addon definitions are then used by the addon | ||
| 5 | buildsystem to figure out which addons and which versions to build. It looks | ||
| 6 | into the "repositories" sub-directory and parses all *.txt files recursively. | ||
| 7 | Each addon definitions repository must have its own <repository>.txt file which | ||
| 8 | must follow the following defined format: | ||
| 9 | ``` | ||
| 10 | <repository> <git-url> <git-revision> | ||
| 11 | ``` | ||
| 12 | where | ||
| 13 | * `<repository>` is the identification of the repository. | ||
| 14 | * `<git-url>` must be the URL of the git repository containing the addon | ||
| 15 | definitions | ||
| 16 | * `<git-revision>` must be a valid git tag/branch/commit in the addon | ||
| 17 | definitions repository's git repository which will be used for the build | ||
| 18 | |||
| 19 | The buildsystem uses the following variables (which can be passed into it when | ||
| 20 | executing cmake with the `-D<variable-name>=<value>` option): | ||
| 21 | * `CMAKE_INSTALL_PREFIX` points to the directory where the downloaded addon | ||
| 22 | definitions will be installed to (defaults to `../addons`). | ||
| 23 | * `BUILD_DIR` points to the directory where the addon definitions repositories | ||
| 24 | will be downloaded to. | ||
| 25 | * `REPOSITORY_TO_BUILD` specifies a single addon definitions repository to be | ||
| 26 | downloaded and processed (defaults to `"all"`). | ||
| 27 | * `REPOSITORY_REVISION` specifies the git revision in the addon definitions | ||
| 28 | repository which will be used for the build. This option is only valid in | ||
| 29 | combination with the `REPOSITORY_TO_BUILD` option (defaults to the git | ||
| 30 | revision specified in the repository's definition file). | ||
| 31 | * `ADDONS_TO_BUILD` is a quoted, space delimited list of `<addon-id>`s that | ||
| 32 | should be bootstrapped (default is `"all"`). | ||
| 33 | |||
| 34 | To trigger the cmake-based buildsystem the following command must be executed | ||
| 35 | with <path> being the path to this directory (absolute or relative, allowing for | ||
| 36 | in-source and out-of-source builds). | ||
| 37 | ``` | ||
| 38 | cmake <path> -G <generator> | ||
| 39 | ``` | ||
| 40 | |||
| 41 | cmake supports multiple generators, see | ||
| 42 | http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators for a list. | ||
| 43 | |||
| 44 | In case of additional options the call might look like this | ||
| 45 | ``` | ||
| 46 | cmake <path> [-G <generator>] \ | ||
| 47 | -DCMAKE_INSTALL_PREFIX="<path-to-install-directory>" | ||
| 48 | ``` \ No newline at end of file | ||
diff --git a/project/cmake/addons/bootstrap/bootstrap.cmake b/project/cmake/addons/bootstrap/bootstrap.cmake new file mode 100644 index 0000000..c78910c --- /dev/null +++ b/project/cmake/addons/bootstrap/bootstrap.cmake | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) | ||
| 2 | |||
| 3 | # make sure that the installation location has been specified | ||
| 4 | if(NOT CMAKE_INSTALL_PREFIX) | ||
| 5 | message(FATAL_ERROR "CMAKE_INSTALL_PREFIX has not been specified") | ||
| 6 | endif() | ||
| 7 | |||
| 8 | # figure out which addons to bootstrap (defaults to all) | ||
| 9 | if(NOT ADDONS_TO_BUILD) | ||
| 10 | set(ADDONS_TO_BUILD "all") | ||
| 11 | else() | ||
| 12 | separate_arguments(ADDONS_TO_BUILD) | ||
| 13 | endif() | ||
| 14 | |||
| 15 | # find all addon definitions and go through them | ||
| 16 | file(GLOB_RECURSE ADDON_DEFINITIONS ${PROJECT_SOURCE_DIR}/*.txt) | ||
| 17 | foreach(ADDON_DEFINITION_FILE ${ADDON_DEFINITIONS}) | ||
| 18 | # ignore platforms.txt | ||
| 19 | if(NOT (ADDON_DEFINITION_FILE MATCHES platforms.txt)) | ||
| 20 | # read the addon definition file | ||
| 21 | file(STRINGS ${ADDON_DEFINITION_FILE} ADDON_DEFINITION) | ||
| 22 | separate_arguments(ADDON_DEFINITION) | ||
| 23 | |||
| 24 | # extract the addon definition's identifier | ||
| 25 | list(GET ADDON_DEFINITION 0 ADDON_ID) | ||
| 26 | |||
| 27 | # check if the addon definition should be built | ||
| 28 | list(FIND ADDONS_TO_BUILD ${ADDON_ID} ADDONS_TO_BUILD_IDX) | ||
| 29 | if(ADDONS_TO_BUILD_IDX GREATER -1 OR "${ADDONS_TO_BUILD}" STREQUAL "all") | ||
| 30 | # get the path to the addon definition directory | ||
| 31 | get_filename_component(ADDON_DEFINITION_DIR ${ADDON_DEFINITION_FILE} PATH) | ||
| 32 | |||
| 33 | # install the addon definition | ||
| 34 | message(STATUS "Bootstrapping ${ADDON_ID} addon...") | ||
| 35 | file(INSTALL ${ADDON_DEFINITION_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}) | ||
| 36 | endif() | ||
| 37 | endif() | ||
| 38 | endforeach() | ||
diff --git a/project/cmake/addons/bootstrap/repositories/binary-addons.txt b/project/cmake/addons/bootstrap/repositories/binary-addons.txt new file mode 100644 index 0000000..8674f06 --- /dev/null +++ b/project/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 | |||
