blob: 66b7e3d16c9ff96e43d3442c90027f9e241c393b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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=<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()
|