cmake: propagating zephyr base to west

West utilizes Zephyr base when invoked out-of-tree in order to determine
west topdir.

This commit ensures that zephyr base when invoking west from CMake is
set to current zephyr base.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2020-02-19 12:01:39 +01:00 committed by Carles Cufí
commit 39cd4c8f52
3 changed files with 10 additions and 6 deletions

View file

@ -38,11 +38,12 @@ else()
# even after output is one line.
message(STATUS "Found west: ${WEST} (found suitable version \"${west_version}\", minimum required is \"${MIN_WEST_VERSION}\")")
execute_process(
COMMAND ${WEST} topdir
OUTPUT_VARIABLE WEST_TOPDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${WEST} topdir
OUTPUT_VARIABLE WEST_TOPDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${ZEPHYR_BASE}
)
endif()
# dtc is an optional dependency. Search for it on PATH and in

View file

@ -21,7 +21,7 @@ endif()
set(KCONFIG_MODULES_FILE ${CMAKE_BINARY_DIR}/Kconfig.modules)
if(WEST)
set(WEST_ARG "--west-path" ${WEST})
set(WEST_ARG "--west-path" ${WEST} "--zephyr-base" ${ZEPHYR_BASE})
endif()
if(WEST OR ZEPHYR_MODULES)

View file

@ -178,10 +178,13 @@ def main():
help='List of extra modules to parse')
parser.add_argument('-w', '--west-path', default='west',
help='Path to west executable')
parser.add_argument('-z', '--zephyr-base',
help='Path to zephyr repository')
args = parser.parse_args()
if args.modules is None:
p = subprocess.Popen([args.west_path, 'list', '--format={posixpath}'],
cwd=args.zephyr_base,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = p.communicate()