cmake: Support UTF-8 characters in Kconfig values

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 <sebastian.boe@nordicsemi.no>
This commit is contained in:
Sebastian Bøe 2018-03-21 13:07:16 +01:00 committed by Anas Nashif
parent 64f858874d
commit 777e0a1b86
2 changed files with 2 additions and 0 deletions

View file

@ -638,6 +638,7 @@ function(import_kconfig config_file)
${config_file} ${config_file}
DOT_CONFIG_LIST DOT_CONFIG_LIST
REGEX "^CONFIG_" REGEX "^CONFIG_"
ENCODING "UTF-8"
) )
foreach (CONFIG ${DOT_CONFIG_LIST}) foreach (CONFIG ${DOT_CONFIG_LIST})

View file

@ -4,6 +4,7 @@ file(STRINGS
${AUTOCONF_H} ${AUTOCONF_H}
CONFIG_LIST CONFIG_LIST
REGEX "^#define CONFIG_" REGEX "^#define CONFIG_"
ENCODING "UTF-8"
) )
foreach (CONFIG ${CONFIG_LIST}) foreach (CONFIG ${CONFIG_LIST})
string(REGEX REPLACE "#define (CONFIG_[A-Z|_|0-9]*) (.*)" "GEN_ABSOLUTE_SYM(\\1, \\2)" CONFIG ${CONFIG}) string(REGEX REPLACE "#define (CONFIG_[A-Z|_|0-9]*) (.*)" "GEN_ABSOLUTE_SYM(\\1, \\2)" CONFIG ${CONFIG})