|
4 | 4 | # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause |
5 | 5 | # |
6 | 6 |
|
| 7 | +# Global SNIPPET/SB_SNIPPET is applied to every sysbuild image. Some addon |
| 8 | +# snippets target the application only and need a different MCUboot counterpart. |
| 9 | +# This hook remaps those pairs on the mcuboot image so builds can pass a single |
| 10 | +# -DSNIPPET=<app_snippet>. Extend the list below as <app_snippet> <mcuboot_snippet>. |
| 11 | +function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake) |
| 12 | + if(NOT SB_CONFIG_BOOTLOADER_MCUBOOT) |
| 13 | + return() |
| 14 | + endif() |
| 15 | + |
| 16 | + zephyr_get(SB_SNIPPET) |
| 17 | + if(SB_SNIPPET) |
| 18 | + set(global_snippets ${SB_SNIPPET}) |
| 19 | + else() |
| 20 | + zephyr_get(SNIPPET) |
| 21 | + set(global_snippets ${SNIPPET}) |
| 22 | + endif() |
| 23 | + |
| 24 | + # Extend this list as needed. |
| 25 | + set(app_mcuboot_snippet_pairs |
| 26 | + matter_fota_ext_flash matter_fota_mcuboot_ext_flash |
| 27 | + ) |
| 28 | + |
| 29 | + set(mcuboot_snippets ${global_snippets}) |
| 30 | + set(remapped FALSE) |
| 31 | + list(LENGTH app_mcuboot_snippet_pairs pair_count) |
| 32 | + math(EXPR last_pair_idx "${pair_count} - 2") |
| 33 | + foreach(idx RANGE 0 ${last_pair_idx} 2) |
| 34 | + list(GET app_mcuboot_snippet_pairs ${idx} app_snippet) |
| 35 | + math(EXPR mcuboot_idx "${idx} + 1") |
| 36 | + list(GET app_mcuboot_snippet_pairs ${mcuboot_idx} mcuboot_snippet) |
| 37 | + |
| 38 | + if(app_snippet IN_LIST global_snippets) |
| 39 | + set(remapped TRUE) |
| 40 | + list(REMOVE_ITEM mcuboot_snippets ${app_snippet}) |
| 41 | + if(NOT mcuboot_snippet IN_LIST mcuboot_snippets) |
| 42 | + list(APPEND mcuboot_snippets ${mcuboot_snippet}) |
| 43 | + endif() |
| 44 | + endif() |
| 45 | + endforeach() |
| 46 | + |
| 47 | + if(remapped) |
| 48 | + set(mcuboot_SNIPPET ${mcuboot_snippets} CACHE STRING "" FORCE) |
| 49 | + endif() |
| 50 | +endfunction() |
| 51 | + |
7 | 52 | function(${SYSBUILD_CURRENT_MODULE_NAME}_post_cmake) |
8 | 53 | sysbuild_get(CONFIG_ZIGBEE_ADD_ON IMAGE ${DEFAULT_IMAGE} VAR CONFIG_ZIGBEE_ADD_ON KCONFIG) |
9 | 54 | sysbuild_get(CONFIG_ZIGBEE_FOTA IMAGE ${DEFAULT_IMAGE} VAR CONFIG_ZIGBEE_FOTA KCONFIG) |
|
0 commit comments