From af9ae5b8949e6f7f93fccd996848b0ef2da03c0d Mon Sep 17 00:00:00 2001 From: Cedric Lescop Date: Thu, 5 Dec 2024 13:36:53 +0100 Subject: [PATCH] cmake: scripts: add 'winpty' support when available Some Python scripts need to access to the underlying OS, like using redirections. These interactions go through TTY interface. On MinGW, these interactions/interfaces are called 'winpty'. => use them when available (harmless on platform *NIX platforms) Signed-off-by: Cedric Lescop --- cmake/modules/FindHostTools.cmake | 6 ++++++ cmake/modules/kconfig.cmake | 1 + 2 files changed, 7 insertions(+) diff --git a/cmake/modules/FindHostTools.cmake b/cmake/modules/FindHostTools.cmake index 1dfce4d3d4a..a1ea6631bf5 100644 --- a/cmake/modules/FindHostTools.cmake +++ b/cmake/modules/FindHostTools.cmake @@ -65,6 +65,12 @@ find_program(BOSSAC bossac) # in the mcuboot repository if that's present in some cases) find_program(IMGTOOL imgtool) +# winpty is an optional dependency +find_program(PTY_INTERFACE winpty) +if("${PTY_INTERFACE}" STREQUAL "PTY_INTERFACE-NOTFOUND") + set(PTY_INTERFACE "") +endif() + # Default to the host system's toolchain if we are targeting a host based target if((${BOARD_DIR} MATCHES "boards\/native") OR ("${ARCH}" STREQUAL "posix") OR ("${BOARD}" STREQUAL "unit_testing")) diff --git a/cmake/modules/kconfig.cmake b/cmake/modules/kconfig.cmake index 02bebbe0851..af8c1e33fa7 100644 --- a/cmake/modules/kconfig.cmake +++ b/cmake/modules/kconfig.cmake @@ -226,6 +226,7 @@ foreach(kconfig_target "SHIELD_AS_LIST=${SHIELD_AS_LIST_ESCAPED}" DTS_POST_CPP=${DTS_POST_CPP} DTS_ROOT_BINDINGS=${DTS_ROOT_BINDINGS} + ${PTY_INTERFACE} ${PYTHON_EXECUTABLE} ${EXTRA_KCONFIG_TARGET_COMMAND_FOR_${kconfig_target}} ${KCONFIG_ROOT}