cmake: strip paths in build output based on Kconfig option
Add CONFIG_BUILD_OUTPUT_STRIP_PATHS to allow keeping absolute paths in the build output. This can be helpful for IDEs to detect links in a console output and jump to the code location (e.g. when running tests in native_posix locally). Debuggers usually have a path mapping feature to ensure the files are still found. Signed-off-by: Martin Jäger <martin@libre.solar>
This commit is contained in:
parent
d6dfacc9c6
commit
a0ffaa763c
2 changed files with 23 additions and 8 deletions
|
@ -442,14 +442,15 @@ zephyr_cc_option_ifdef(CONFIG_STACK_USAGE -fstack-usage)
|
||||||
# application code. This saves some memory, stops leaking user locations
|
# application code. This saves some memory, stops leaking user locations
|
||||||
# in binaries, makes failure logs more deterministic and most
|
# in binaries, makes failure logs more deterministic and most
|
||||||
# importantly makes builds more deterministic
|
# importantly makes builds more deterministic
|
||||||
|
if(CONFIG_BUILD_OUTPUT_STRIP_PATHS)
|
||||||
# If several match then the last one wins. This matters for instances
|
# If several match then the last one wins. This matters for instances
|
||||||
# like tests/ and samples/: they're inside all of them! Then let's
|
# like tests/ and samples/: they're inside all of them! Then let's
|
||||||
# strip as little as possible.
|
# strip as little as possible.
|
||||||
zephyr_cc_option(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=CMAKE_SOURCE_DIR)
|
zephyr_cc_option(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=CMAKE_SOURCE_DIR)
|
||||||
zephyr_cc_option(-fmacro-prefix-map=${ZEPHYR_BASE}=ZEPHYR_BASE)
|
zephyr_cc_option(-fmacro-prefix-map=${ZEPHYR_BASE}=ZEPHYR_BASE)
|
||||||
if(WEST_TOPDIR)
|
if(WEST_TOPDIR)
|
||||||
zephyr_cc_option(-fmacro-prefix-map=${WEST_TOPDIR}=WEST_TOPDIR)
|
zephyr_cc_option(-fmacro-prefix-map=${WEST_TOPDIR}=WEST_TOPDIR)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# TODO: Archiver arguments
|
# TODO: Archiver arguments
|
||||||
|
|
|
@ -684,6 +684,20 @@ config BUILD_OUTPUT_META_STATE_PROPAGATE
|
||||||
defined when `west update` was run the last time (`manifest-rev`).
|
defined when `west update` was run the last time (`manifest-rev`).
|
||||||
The off state is only present if a west workspace is found.
|
The off state is only present if a west workspace is found.
|
||||||
|
|
||||||
|
config BUILD_OUTPUT_STRIP_PATHS
|
||||||
|
bool "Strip absolute paths from binaries"
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
If the compiler supports it, strip the ${ZEPHYR_BASE} prefix from the
|
||||||
|
__FILE__ macro used in __ASSERT*, in the
|
||||||
|
.noinit."/home/joe/zephyr/fu/bar.c" section names and in any
|
||||||
|
application code.
|
||||||
|
This saves some memory, stops leaking user locations in binaries, makes
|
||||||
|
failure logs more deterministic and most importantly makes builds more
|
||||||
|
deterministic.
|
||||||
|
Debuggers usually have a path mapping feature to ensure the files are
|
||||||
|
still found.
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
config DEPRECATED
|
config DEPRECATED
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue