From 777e0a1b86589071ee4082453e1c4d1add58b4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Wed, 21 Mar 2018 13:07:16 +0100 Subject: [PATCH] cmake: Support UTF-8 characters in Kconfig values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We are using the CMake command 'file(STRINGS' (which defaults to only decoding ASCII) to read Kconfig configurations. When UTF-8 characters are detected they are treated as newlines. This behaviour has caused issues when users have input UTF-8 characters into Kconfig values. E.g. USB device descriptor strings. This commit adds the flag 'ENCODING "UTF-8"' to the 'file(STRINGS' command so that UTF-8 characters are correctly passed through the build system. Signed-off-by: Sebastian Bøe --- cmake/extensions.cmake | 1 + misc/generated/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/cmake/extensions.cmake b/cmake/extensions.cmake index 7b261df4e16..34dc2aceec0 100644 --- a/cmake/extensions.cmake +++ b/cmake/extensions.cmake @@ -638,6 +638,7 @@ function(import_kconfig config_file) ${config_file} DOT_CONFIG_LIST REGEX "^CONFIG_" + ENCODING "UTF-8" ) foreach (CONFIG ${DOT_CONFIG_LIST}) diff --git a/misc/generated/CMakeLists.txt b/misc/generated/CMakeLists.txt index 7fc7115d169..ecd90b69865 100644 --- a/misc/generated/CMakeLists.txt +++ b/misc/generated/CMakeLists.txt @@ -4,6 +4,7 @@ file(STRINGS ${AUTOCONF_H} CONFIG_LIST REGEX "^#define CONFIG_" + ENCODING "UTF-8" ) foreach (CONFIG ${CONFIG_LIST}) string(REGEX REPLACE "#define (CONFIG_[A-Z|_|0-9]*) (.*)" "GEN_ABSOLUTE_SYM(\\1, \\2)" CONFIG ${CONFIG})