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