summaryrefslogtreecommitdiffstats
path: root/project/cmake/addons
diff options
context:
space:
mode:
Diffstat (limited to 'project/cmake/addons')
-rw-r--r--project/cmake/addons/CMakeLists.txt155
-rw-r--r--project/cmake/addons/README12
2 files changed, 108 insertions, 59 deletions
diff --git a/project/cmake/addons/CMakeLists.txt b/project/cmake/addons/CMakeLists.txt
index 0afc622..83f424a 100644
--- a/project/cmake/addons/CMakeLists.txt
+++ b/project/cmake/addons/CMakeLists.txt
@@ -73,6 +73,11 @@ set(BUILD_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
73 -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} 73 -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
74 -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}) 74 -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS})
75 75
76if(MSVC)
77 # move cmake specific targets to a CMakePredefinedTargets folder in Visual Studio
78 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
79endif()
80
76if(PACKAGE_ZIP) 81if(PACKAGE_ZIP)
77 # needed for project installing 82 # needed for project installing
78 list(APPEND BUILD_ARGS -DPACKAGE_ZIP=1) 83 list(APPEND BUILD_ARGS -DPACKAGE_ZIP=1)
@@ -92,6 +97,10 @@ else()
92 separate_arguments(ADDONS_TO_BUILD) 97 separate_arguments(ADDONS_TO_BUILD)
93endif() 98endif()
94 99
100if(ADDON_SRC_PREFIX)
101 message(STATUS "Overriding addon source directory prefix: ${ADDON_SRC_PREFIX}")
102endif()
103
95if(NOT KODI_LIB_DIR) 104if(NOT KODI_LIB_DIR)
96 set(KODI_LIB_DIR "${DEPENDS_PATH}/lib/kodi") 105 set(KODI_LIB_DIR "${DEPENDS_PATH}/lib/kodi")
97else() 106else()
@@ -160,85 +169,117 @@ foreach(addon ${addons})
160 list(GET def 1 url) 169 list(GET def 1 url)
161 170
162 set(archive_name ${id}) 171 set(archive_name ${id})
172 if(ADDON_SRC_PREFIX)
173 set(SOURCE_DIR ${ADDON_SRC_PREFIX}/${id})
174 set(archive_name "")
175 else()
176 set(SOURCE_DIR "")
177 endif()
163 178
164 # if there is a 3rd parameter in the file, we consider it a git revision 179 # if there is a 3rd parameter in the file, we consider it a git revision
165 if(deflength GREATER 2) 180 if(deflength GREATER 2 AND "${SOURCE_DIR}" STREQUAL "")
166 list(GET def 2 revision) 181 list(GET def 2 revision)
167 182
168 # Note: downloading specific revisions via http in the format below is probably github specific 183 # Note: downloading specific revisions via http in the format below is probably github specific
169 # if we ever use other repositories, this might need adapting 184 # if we ever use other repositories, this might need adapting
170 set(url ${url}/archive/${revision}.tar.gz) 185 set(url ${url}/archive/${revision}.tar.gz)
171 set(archive_name ${archive_name}-${revision}) 186 set(archive_name ${archive_name}-${revision})
187 elseif("${SOURCE_DIR}" STREQUAL "")
188 # check if the URL starts with file://
189 string(REGEX MATCH "^file://.*$" local_url "${url}")
190
191 #if not we assume this to be a local directory
192 if(local_url)
193 # this is not an archive
194 set(archive_name "")
195
196 # remove the file:// protocol from the URL
197 string(REPLACE "file://" "" SOURCE_DIR "${url}")
198
199 # on win32 we may have to remove another leading /
200 if(WIN32)
201 # check if the path is a local path
202 string(REGEX MATCH "^/.*$" local_path "${SOURCE_DIR}")
203 if(local_path)
204 string(SUBSTRING "${SOURCE_DIR}" 1 -1 SOURCE_DIR)
205 endif()
206 endif()
207 endif()
172 endif() 208 endif()
173 209
174 # download and extract the addon 210 # download the addon if necessary
175 if(NOT EXISTS ${BUILD_DIR}/download/${archive_name}.tar.gz) 211 if(NOT "${archive_name}" STREQUAL "")
176 # cleanup any of the previously downloaded archives of this addon 212 # download and extract the addon
177 file(GLOB archives "${BUILD_DIR}/download/${id}*.tar.gz") 213 if(NOT EXISTS ${BUILD_DIR}/download/${archive_name}.tar.gz)
178 if(archives) 214 # cleanup any of the previously downloaded archives of this addon
179 message(STATUS "Removing old archives of ${id}: ${archives}") 215 file(GLOB archives "${BUILD_DIR}/download/${id}*.tar.gz")
180 file(REMOVE ${archives}) 216 if(archives)
217 message(STATUS "Removing old archives of ${id}: ${archives}")
218 file(REMOVE ${archives})
219 endif()
220
221 # download the addon
222 file(DOWNLOAD "${url}" "${BUILD_DIR}/download/${archive_name}.tar.gz" STATUS dlstatus LOG dllog SHOW_PROGRESS)
223 list(GET dlstatus 0 retcode)
224 if(NOT ${retcode} EQUAL 0)
225 message(FATAL_ERROR "ERROR downloading ${url} - status: ${dlstatus} log: ${dllog}")
226 endif()
181 endif() 227 endif()
182 228
183 # download the addon 229 # remove any previously extracted version of the addon
184 file(DOWNLOAD "${url}" "${BUILD_DIR}/download/${archive_name}.tar.gz" STATUS dlstatus LOG dllog SHOW_PROGRESS) 230 if(EXISTS "${BUILD_DIR}/${id}")
185 list(GET dlstatus 0 retcode) 231 file(REMOVE_RECURSE "${BUILD_DIR}/${id}")
186 if(NOT ${retcode} EQUAL 0)
187 message(FATAL_ERROR "ERROR downloading ${url} - status: ${dlstatus} log: ${dllog}")
188 endif() 232 endif()
189 endif()
190 233
191 # remove any previously extracted version of the addon 234 # extract the addon from the archive
192 if(EXISTS "${BUILD_DIR}/${id}") 235 execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${BUILD_DIR}/download/${archive_name}.tar.gz
193 file(REMOVE_RECURSE "${BUILD_DIR}/${id}") 236 WORKING_DIRECTORY ${BUILD_DIR})
237 file(GLOB extract_dir "${BUILD_DIR}/${archive_name}*")
238 if(extract_dir STREQUAL "")
239 message(FATAL_ERROR "${id}: error extracting ${BUILD_DIR}/download/${archive_name}.tar.gz")
240 else()
241 file(RENAME "${extract_dir}" "${BUILD_DIR}/${id}")
242 endif()
243
244 set(SOURCE_DIR ${BUILD_DIR}/${id})
194 endif() 245 endif()
195 246
196 # extract the addon from the archive 247 if(NOT "${SOURCE_DIR}" STREQUAL "" AND EXISTS ${SOURCE_DIR})
197 execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzvf ${BUILD_DIR}/download/${archive_name}.tar.gz 248 # setup the buildsystem for the addon
198 WORKING_DIRECTORY ${BUILD_DIR}) 249 externalproject_add(${id}
199 file(GLOB extract_dir "${BUILD_DIR}/${archive_name}*") 250 SOURCE_DIR ${SOURCE_DIR}
200 if(extract_dir STREQUAL "") 251 INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
201 message(FATAL_ERROR "Error extracting ${BUILD_DIR}/download/${archive_name}.tar.gz") 252 CMAKE_ARGS ${BUILD_ARGS})
253
254 # add a custom step to the external project between the configure and the build step which will always
255 # be executed and therefore forces a re-build of all changed files
256 externalproject_add_step(${id} forcebuild
257 COMMAND ${CMAKE_COMMAND} -E echo "Force build of ${id}"
258 DEPENDEES configure
259 DEPENDERS build
260 ALWAYS 1)
261
262 # add "kodi-platform" as a dependency to every addon
263 add_dependencies(${id} kodi-platform)
264
265 set(${id}_DEPENDS_DIR ${SOURCE_DIR}/depends)
266
267 if(EXISTS ${${id}_DEPENDS_DIR})
268 include(${APP_ROOT}/project/cmake/scripts/common/handle-depends.cmake)
269 add_addon_depends(${id} ${${id}_DEPENDS_DIR})
270 if(${id}_DEPS AND NOT "${${id}_DEPS}" STREQUAL "")
271 message(STATUS "${id} DEPENDENCIES: ${${id}_DEPS}")
272 add_dependencies(${id} ${${id}_DEPS})
273 endif()
274 endif()
202 else() 275 else()
203 file(RENAME "${extract_dir}" "${BUILD_DIR}/${id}") 276 message(FATAL_ERROR "${id}: invalid or missing addon source directory at ${SOURCE_DIR}")
204 endif() 277 endif()
205
206 list(APPEND downloaded_addons ${id})
207
208 endif() 278 endif()
209 endif() 279 endif()
210 endif() 280 endif()
211endforeach() 281endforeach()
212 282
213foreach(id ${downloaded_addons})
214 externalproject_add(${id}
215 SOURCE_DIR ${BUILD_DIR}/${id}
216 INSTALL_DIR ${ADDON_INSTALL_DIR}
217 CMAKE_ARGS ${BUILD_ARGS})
218
219 # add a custom step to the external project between the configure and the build step which will always
220 # be executed and therefore forces a re-build of all changed files
221 externalproject_add_step(${id} forcebuild
222 COMMAND ${CMAKE_COMMAND} -E echo "Force build of ${id}"
223 DEPENDEES configure
224 DEPENDERS build
225 ALWAYS 1)
226
227 # add "kodi-platform" as a dependency to every addon
228 add_dependencies(${id} kodi-platform)
229
230 set(${id}_DEPENDS_DIR ${BUILD_DIR}/${id}/depends)
231
232 if(EXISTS ${${id}_DEPENDS_DIR})
233 include(${APP_ROOT}/project/cmake/scripts/common/handle-depends.cmake)
234 add_addon_depends(${id} ${${id}_DEPENDS_DIR})
235 if (${id}_DEPS AND NOT "${${id}_DEPS}" STREQUAL "")
236 message(STATUS "${id} DEPENDENCIES: ${${id}_DEPS}")
237 add_dependencies(${id} ${${id}_DEPS})
238 endif()
239 endif()
240endforeach()
241
242if(NEED_SUDO) 283if(NEED_SUDO)
243 add_custom_target(install 284 add_custom_target(install
244 COMMAND ${CMAKE_COMMAND} -E echo "\n\n" 285 COMMAND ${CMAKE_COMMAND} -E echo "\n\n"
diff --git a/project/cmake/addons/README b/project/cmake/addons/README
index c66e668..b901bb7 100644
--- a/project/cmake/addons/README
+++ b/project/cmake/addons/README
@@ -3,14 +3,19 @@ KODI ADDONS
3This directory contains the cmake-based buildsystem for addons. It looks into 3This directory contains the cmake-based buildsystem for addons. It looks into
4the "addons" sub-directory and parses all *.txt files recursively. Each addon 4the "addons" sub-directory and parses all *.txt files recursively. Each addon
5must have its own <addon-id>.txt file in a separate sub-directory which must 5must have its own <addon-id>.txt file in a separate sub-directory which must
6follow the defined format: 6follow one of the defined format:
7 <addon-id> <git-url> <git-revision> 7 <addon-id> <git-url> <git-revision>
8 <addon-id> <tarball-url>
9 <addon-id> <file://path>
8where 10where
9 * <addon-id> must be identical to the addon's ID as defined in the addon's 11 * <addon-id> must be identical to the addon's ID as defined in the addon's
10 addon.xml 12 addon.xml
11 * <git-url> must be the URL of the git repository containing the addon. 13 * <git-url> must be the URL of the git repository containing the addon
12 * <git-revision> must be a valid git tag/branch/commit in the addon's git 14 * <git-revision> must be a valid git tag/branch/commit in the addon's git
13 repository which will be used for the build. 15 repository which will be used for the build.
16 * <tarball-url> must be the URL to a .tar.gz tarball containing the addon
17 * <file://path> must be a file:// based path to the directory containing the
18 addon
14 19
15Reserved filenames (for additional information on how to build an addon) 20Reserved filenames (for additional information on how to build an addon)
16are: 21are:
@@ -24,6 +29,9 @@ executing cmake with the -D<variable-name>=<value> option) to e.g. access
24specific paths: 29specific paths:
25 * ADDONS_TO_BUILD is a quoted, space delimited list of <addon-id>s that 30 * ADDONS_TO_BUILD is a quoted, space delimited list of <addon-id>s that
26 you want to build (default is "all"). 31 you want to build (default is "all").
32 * ADDON_SRC_PREFIX can be used to override the addon repository location.
33 It must point to the locally available parent directory of the addon(s) to build
34 <addon-id> will be appended to this path automatically
27 * CMAKE_BUILD_TYPE specifies the type of the build. This can be either "Debug" 35 * CMAKE_BUILD_TYPE specifies the type of the build. This can be either "Debug"
28 or "Release" (default is "Release"). 36 or "Release" (default is "Release").
29 * CMAKE_INSTALL_PREFIX points to the directory where the built addons and their 37 * CMAKE_INSTALL_PREFIX points to the directory where the built addons and their