From 18ae8507b7741affac057cee6efe326a12a1a925 Mon Sep 17 00:00:00 2001 From: Pavel Fedin Date: Sat, 10 Jun 2023 00:00:05 +0300 Subject: [PATCH 1/3] tooks/kconfig: Win32 build New MSYS2/MinGW is a pure Windows environment due to ABI differences on 64 bits. Therefore UNIX calls are not available when building for mingw target. Avoid creating UNAME_RELEASE symbol, which is taken from current Linux kernel version. Anyways this isn't important for this SDK. Signed-off-by: Pavel Fedin --- tools/kconfig/symbol.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/kconfig/symbol.c b/tools/kconfig/symbol.c index 25cf0c2c0..ae689feca 100644 --- a/tools/kconfig/symbol.c +++ b/tools/kconfig/symbol.c @@ -7,7 +7,9 @@ #include #include #include +#ifndef _WIN32 #include +#endif #include "lkc.h" @@ -44,6 +46,7 @@ static void sym_add_default(struct symbol *sym, const char *def) void sym_init(void) { +#ifndef _WIN32 struct symbol *sym; struct utsname uts; static bool inited = false; @@ -58,6 +61,7 @@ void sym_init(void) sym->type = S_STRING; sym->flags |= SYMBOL_AUTO; sym_add_default(sym, uts.release); +#endif } enum symbol_type sym_get_type(struct symbol *sym) From d387ad1eeb839ea6efcd1aece692607e98a53eec Mon Sep 17 00:00:00 2001 From: Pavel Fedin Date: Sat, 10 Jun 2023 23:52:04 +0300 Subject: [PATCH 2/3] kconfig/lxdialog: Windows-specific Esc key handling On native Windows ncurses Esc key is reported immediately on first press. Adjust on_key_esc() to work correctly in this scenario Signed-off-by: Pavel Fedin --- tools/kconfig/lxdialog/util.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/kconfig/lxdialog/util.c b/tools/kconfig/lxdialog/util.c index f7abdeb92..5aecd2716 100644 --- a/tools/kconfig/lxdialog/util.c +++ b/tools/kconfig/lxdialog/util.c @@ -566,6 +566,17 @@ int on_key_esc(WINDOW *win) nodelay(win, TRUE); keypad(win, FALSE); key = wgetch(win); +#ifdef WIN32 + /* + * On Windowa ncurses uses terminal driver, which reads keys directly + * from Windows API, so it doesn't have to recognize ESC sequences and + * buffer the first ESC as a consequence. ESC is emitted instantly to + * an application, so second nodelay read will return ERR. + * Yes, there's no need to press Esc twice. + */ + if (key == ERR) + return KEY_ESC; +#endif key2 = wgetch(win); do { key3 = wgetch(win); From fa71bc7d21868d54ea41584e00d4c43e0bd96b66 Mon Sep 17 00:00:00 2001 From: Pavel Fedin Date: Wed, 14 Jun 2023 23:56:40 +0300 Subject: [PATCH 3/3] kconfig/confdata.c: Explicitly erase old sdkconfig.old On Windows rename() does not overwrite existing file but errors out. Handle that by explicitly erasing what should be erased. Saving configuration now works. Signed-off-by: Pavel Fedin --- tools/kconfig/confdata.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/kconfig/confdata.c b/tools/kconfig/confdata.c index 70f6ab7fc..e6a7c7785 100644 --- a/tools/kconfig/confdata.c +++ b/tools/kconfig/confdata.c @@ -819,6 +819,10 @@ int conf_write(const char *name) if (*tmpname) { strcat(dirname, basename); strcat(dirname, ".old"); +#ifdef WIN32 + // On Windows rename() fails if a file exists + unlink(dirname); +#endif rename(newname, dirname); if (rename(tmpname, newname)) return 1;