diff options
| author | hathach <[email protected]> | 2026-02-10 19:06:31 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2026-02-10 19:06:31 +0700 |
| commit | 4b8f476d52ab0bb518b851ba22323658fb978768 (patch) | |
| tree | 6cca4e393ebe33a0a46928ca666c5cb21d1ae41f | |
| parent | e416a81a50483dde140e3bfdc1be8657d44f560e (diff) | |
add membrowse target to family support for enhanced memory analysis
| -rw-r--r-- | hw/bsp/family_support.cmake | 38 | ||||
| -rw-r--r-- | hw/bsp/rp2040/family.cmake | 3 |
2 files changed, 40 insertions, 1 deletions
diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake index ad9a4f94d..335b56c72 100644 --- a/hw/bsp/family_support.cmake +++ b/hw/bsp/family_support.cmake @@ -267,6 +267,43 @@ function(family_add_linkermap TARGET) VERBATIM) endfunction() +# Add membrowse target (installed with pip install membrowse) +function(family_add_membrowse TARGET) + find_program(MEMBROWSE_EXE membrowse) + if (MEMBROWSE_EXE STREQUAL MEMBROWSE_EXE-NOTFOUND) + # force anyway, bash login shell will find it from pip install path + set(MEMBROWSE_EXE membrowse) + endif () + + set(OPTION "") + if (DEFINED MEMBROWSE_OPTION) + string(APPEND OPTION " ${MEMBROWSE_OPTION}") + endif () + + # For Ninja generator, extract all linker scripts from Ninja commands and pass them to membrowse. + if (CMAKE_GENERATOR MATCHES "Ninja") + set(MEMBROWSE_CMD + "ld_scripts=\"$(${CMAKE_MAKE_PROGRAM} -C ${CMAKE_BINARY_DIR} -t commands ${TARGET} | grep -oP '(?<=-Wl,--script=)[A-Za-z0-9_./-]+\\.ld' | xargs)\"; \ +${MEMBROWSE_EXE} report ${OPTION} $<TARGET_FILE:${TARGET}> \"$ld_scripts\"") + + add_custom_target(${TARGET}-membrowse + DEPENDS ${TARGET} + COMMAND bash -lc "${MEMBROWSE_CMD}" + VERBATIM + ) + + add_custom_target(${TARGET}-membrowse-upload + DEPENDS ${TARGET} + COMMAND bash -lc "${MEMBROWSE_CMD} --upload --github --target-name ${BOARD}-${TARGET} --api-key $ENV{MEMBROWSE_API_KEY}" + VERBATIM + ) + + set_property(TARGET ${TARGET}-membrowse PROPERTY FOLDER ${TARGET}) + set_property(TARGET ${TARGET}-membrowse-upload PROPERTY FOLDER ${TARGET}) + endif () +endfunction() + + #------------------------------------------------------------- # Common Target Configure # Most families use these settings except rp2040 and espressif @@ -380,6 +417,7 @@ function(family_configure_common TARGET RTOS) # Analyze size with bloaty and linkermap family_add_bloaty(${TARGET}) family_add_linkermap(${TARGET}) + family_add_membrowse(${TARGET}) endif () # run size after build diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index e617ab3ca..82d0034a1 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -250,9 +250,10 @@ function(family_configure_target TARGET RTOS) family_flash_openocd(${TARGET}) family_flash_jlink(${TARGET}) - # Generate linkermap target and post build. LINKERMAP_OPTION can be set with -D to change default options + # Generate linkermap target and post build. LINKERMAP_OPTION can be set with -D to change default options family_add_bloaty(${TARGET}) family_add_linkermap(${TARGET}) + family_add_membrowse(${TARGET}) endfunction() |
