From 6aeed0d3fbb0405217c0118838977d934da38f20 Mon Sep 17 00:00:00 2001 From: Brent Murphy Date: Tue, 28 Apr 2020 20:36:04 +1000 Subject: [cmake] addons_to_build better regex/exact match handling Handles regex matching and exact addon matching as separate lists. This allows to only do regex matches when the exact match has not been found, or an actual regex expression was provided Implements an exclusion match regex to exclude an addon/s from building example usage ADDONS_TO_BUILD='game.libretro.* -game.libretro.mrboom peripheral.joystick' game.libretro.mrboom will not build, but game.libretro and game.libretro.2048 will --- cmake/addons/CMakeLists.txt | 72 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 9 deletions(-) diff --git a/cmake/addons/CMakeLists.txt b/cmake/addons/CMakeLists.txt index 3dccc014b2..c1313d7458 100644 --- a/cmake/addons/CMakeLists.txt +++ b/cmake/addons/CMakeLists.txt @@ -244,26 +244,80 @@ endif() # error either in ADDONS_TO_BUILD or in the directory configuration. set(SUPPORTED_ADDON_FOUND FALSE) +if(NOT ADDONS_TO_BUILD) + set(ADDONS_TO_BUILD "all") +endif() + +if(NOT ADDONS_TO_BUILD STREQUAL "all") + # Exact addon match list + set(REGEX_ADDONS_TO_BUILD ${ADDONS_TO_BUILD}) + set(EXACT_MATCH_ADDON_LIST "") + set(EXCLUDE_ADDONS "") + + foreach(addon ${ADDONS_TO_BUILD}) + set(FOUND_EXCLUSION "") + string(REGEX MATCH "^[-](.*)" FOUND_EXCLUSION "${addon}") + if(NOT FOUND_EXCLUSION STREQUAL "") + list(APPEND EXCLUDE_ADDONS ${CMAKE_MATCH_1}) + list(REMOVE_ITEM REGEX_ADDONS_TO_BUILD "-${CMAKE_MATCH_1}") + else() + foreach(addonrepoitem ${addons}) + if(NOT (addonrepoitem MATCHES platforms.txt)) + # need to strip regex chars, or the filter regex will use + string(REPLACE "*" "" strippedregex ${addon}) + if(${addonrepoitem} MATCHES "^.*\/(${strippedregex}).txt") + list(APPEND EXACT_MATCH_ADDON_LIST ${addon}) + # remove exact matches from addons_to_build + list(REMOVE_ITEM REGEX_ADDONS_TO_BUILD "${addon}") + endif() + endif() + endforeach() + endif() + endforeach() + + message(STATUS "Exclusion list: ${EXCLUDE_ADDONS}") + message(STATUS "Exact Match list: ${EXACT_MATCH_ADDON_LIST}") + message(STATUS "Regex list: ${REGEX_ADDONS_TO_BUILD}") +endif() + foreach(addon ${addons}) if(NOT (addon MATCHES platforms.txt)) file(STRINGS ${addon} def) string(REPLACE " " ";" def ${def}) list(GET def 0 id) - set(ADDON_FOUND FALSE) - # try to find a perfect match - list(FIND ADDONS_TO_BUILD ${id} idx) - if(idx GREATER -1 OR "${ADDONS_TO_BUILD}" STREQUAL "all") + if("${ADDONS_TO_BUILD}" STREQUAL "all") set(ADDON_FOUND TRUE) - # Maybe we have a regex else() - foreach(ADDONLISTITEM ${ADDONS_TO_BUILD}) - if(id MATCHES "${ADDONLISTITEM}") - message(STATUS "Pattern ${ADDONLISTITEM} matches ${id}, building addon") - set(ADDON_FOUND TRUE) + set(ADDON_EXCLUDE FALSE) + set(ADDON_FOUND FALSE) + foreach(exclusion ${EXCLUDE_ADDONS}) + if(id MATCHES "${exclusion}") + set(ADDON_EXCLUDE TRUE) + message(STATUS "Addon ${id} matches exclusion rule -${exclusion}") break() endif() endforeach() + + if(ADDON_EXCLUDE) + continue() + endif() + + list(FIND EXACT_MATCH_ADDON_LIST ${id} idx) + if(idx GREATER -1) + # exact match, so build + message(STATUS "Exact match ${id}, building addon") + set(ADDON_FOUND TRUE) + else() + # regex search + foreach(ADDONLISTITEM ${REGEX_ADDONS_TO_BUILD}) + if(id MATCHES "${ADDONLISTITEM}") + message(STATUS "Pattern ${ADDONLISTITEM} matches ${id}, building addon") + set(ADDON_FOUND TRUE) + break() + endif() + endforeach() + endif() endif() if(ADDON_FOUND) -- cgit v1.2.3 From 6a8a8f768c2b414f80b33da414ad19ca2f33a887 Mon Sep 17 00:00:00 2001 From: Brent Murphy Date: Sun, 26 Apr 2020 16:29:38 +1000 Subject: [docs] Provide further information regarding addon_to_build regex usage --- cmake/addons/README.md | 8 +++++--- docs/README.Android.md | 1 + docs/README.FreeBSD.md | 1 + docs/README.Linux.md | 1 + docs/README.iOS.md | 5 ++--- docs/README.macOS.md | 1 + docs/README.tvOS.md | 1 + 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cmake/addons/README.md b/cmake/addons/README.md index dd222f5cdb..36e78de835 100644 --- a/cmake/addons/README.md +++ b/cmake/addons/README.md @@ -25,9 +25,11 @@ If no add-on definitions could be found, the buildsystem assumes that the bootst ## Buildsystem variables The buildsystem uses the following addon-related variables (which can be passed into it when executing cmake with the -D`=` format) to manipulate the build process: -- `ADDONS_TO_BUILD` has two variations, which are tested in order: - - a quoted, space delimited list of `s` that you want to build (default is *all*) - - a regular expression that every `` is matched against (e.g. `ADDONS_TO_BUILD="pvr.*"`) to build all pvr add-ons +- `ADDONS_TO_BUILD` has four rules for matching a provided space delimited list: + - to build all addons, just use `all` (default is *all*) + - an exact match of an `` that you want to build (e.g. `ADDONS_TO_BUILD="game.libretro"`) + - a regular expression `` is matched against (e.g. `ADDONS_TO_BUILD="pvr.*"`) to build all pvr add-ons + - a regular expression exclusion can be made using `-` (e.g. `ADDONS_TO_BUILD="pvr.* -pvr.dvb"`) to exclude pvr.dvblink and pvr.dvbviewer, but build all other pvr add-ons - `ADDONS_DEFINITION_DIR` points to the directory containing the definitions for the addons to be built - `ADDON_SRC_PREFIX` can be used to override the add-on repository location. It must point to the locally available parent directory of the add-on(s) to build. `` will be appended to this path automatically - `CMAKE_INSTALL_PREFIX` points to the directory where the built add-ons and their additional files (addon.xml, resources, ...) will be installed to (defaults to ``) diff --git a/docs/README.Android.md b/docs/README.Android.md index 5d918d6887..1f8cb47073 100644 --- a/docs/README.Android.md +++ b/docs/README.Android.md @@ -192,6 +192,7 @@ Build a specific group of add-ons: ``` make -j$(getconf _NPROCESSORS_ONLN) -C tools/depends/target/binary-addons ADDONS="pvr.*" ``` +For additional information on regular expression usage for ADDONS_TO_BUILD, view ADDONS_TO_BUILD section located at [Kodi add-ons CMake based buildsystem](../cmake/addons/README.md) **[back to top](#table-of-contents)** diff --git a/docs/README.FreeBSD.md b/docs/README.FreeBSD.md index 75e5985171..53a689d46d 100644 --- a/docs/README.FreeBSD.md +++ b/docs/README.FreeBSD.md @@ -168,6 +168,7 @@ Build a specific group of add-ons: ``` sudo gmake -j$(sysctl hw.ncpu | awk '{print $2}') -C tools/depends/target/binary-addons PREFIX=/usr/local ADDONS="pvr.*" ``` +For additional information on regular expression usage for ADDONS_TO_BUILD, view ADDONS_TO_BUILD section located at [Kodi add-ons CMake based buildsystem](../cmake/addons/README.md) **NOTE:** `PREFIX=/usr/local` should match Kodi's `-DCMAKE_INSTALL_PREFIX=` prefix used in **[section 4.1](#41-configure-build)**. diff --git a/docs/README.Linux.md b/docs/README.Linux.md index e78f7b941e..e7cdf8dd5c 100644 --- a/docs/README.Linux.md +++ b/docs/README.Linux.md @@ -236,6 +236,7 @@ Build a specific group of add-ons: ``` sudo make -j$(getconf _NPROCESSORS_ONLN) -C tools/depends/target/binary-addons PREFIX=/usr/local ADDONS="pvr.*" ``` +For additional information on regular expression usage for ADDONS_TO_BUILD, view ADDONS_TO_BUILD section located here [Kodi add-ons CMake based buildsystem](../cmake/addons/README.md) **NOTE:** `PREFIX=/usr/local` should match Kodi's `-DCMAKE_INSTALL_PREFIX=` prefix used in **[section 4.1](#41-configure-build)**. diff --git a/docs/README.iOS.md b/docs/README.iOS.md index da03618f55..85052b655f 100644 --- a/docs/README.iOS.md +++ b/docs/README.iOS.md @@ -130,6 +130,7 @@ Build a specific group of add-ons: ``` make -j$(getconf _NPROCESSORS_ONLN) -C tools/depends/target/binary-addons ADDONS="pvr.*" ``` +For additional information on regular expression usage for ADDONS_TO_BUILD, view ADDONS_TO_BUILD section located here [Kodi add-ons CMake based buildsystem](../cmake/addons/README.md) ## 5.2. Xcode project building @@ -146,9 +147,7 @@ Generate Xcode project to build a specific group of add-ons: make -C tools/depends/target/cmakebuildsys CMAKE_EXTRA_ARGUMENTS="-DENABLE_XCODE_ADDONBUILD=ON -DADDONS_TO_BUILD='pvr.*'" ``` -**TIP:** When using addontype.* for -DADDONS_TO_BUILD argument, you cannot have multiple -addon types. ie -DADDONS_TO_BUILD='game.libretro.* peripheral.*' is not valid. You will -need to individually list the addons as per the first example for specific addon building. +For additional information on regular expression usage for ADDONS_TO_BUILD, view ADDONS_TO_BUILD section located at [Kodi add-ons CMake based buildsystem](../cmake/addons/README.md) Generate Xcode project to build all add-ons automatically: ```sh diff --git a/docs/README.macOS.md b/docs/README.macOS.md index 1138651018..a8347384ce 100644 --- a/docs/README.macOS.md +++ b/docs/README.macOS.md @@ -131,6 +131,7 @@ OR ``` make -j$(getconf _NPROCESSORS_ONLN) -C tools/depends/target/binary-addons ADDONS="pvr.*" ``` +For additional information on regular expression usage for ADDONS_TO_BUILD, view ADDONS_TO_BUILD section located at [Kodi add-ons CMake based buildsystem](../cmake/addons/README.md) **[back to top](#table-of-contents)** diff --git a/docs/README.tvOS.md b/docs/README.tvOS.md index 2e938cf40d..483b613840 100644 --- a/docs/README.tvOS.md +++ b/docs/README.tvOS.md @@ -161,6 +161,7 @@ Generate Xcode project to build a specific group of add-ons: ``` make -C tools/depends/target/cmakebuildsys CMAKE_EXTRA_ARGUMENTS="-DENABLE_XCODE_ADDONBUILD=ON -DADDONS_TO_BUILD='pvr.*'" ``` +For additional information on regular expression usage for ADDONS_TO_BUILD, view ADDONS_TO_BUILD section located at [Kodi add-ons CMake based buildsystem](../cmake/addons/README.md) Generate Xcode project to build all add-ons automatically: ``` -- cgit v1.2.3