chore: correct the code format in lv_conf_template.h (#3310)

* chore: correct the code format in lv_conf_template.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

* feat(config): support #undef in lv_conf_template.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2022-05-05 02:58:09 +08:00
committed by GitHub
parent 181bf88ef0
commit 4e7a0b2824
3 changed files with 97 additions and 85 deletions

View File

@@ -55,8 +55,8 @@
#define LV_MEM_ADR 0 /*0: unused*/
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
#if LV_MEM_ADR == 0
//#define LV_MEM_POOL_INCLUDE your_alloc_library /* Uncomment if using an external allocator*/
//#define LV_MEM_POOL_ALLOC your_alloc /* Uncomment if using an external allocator*/
#undef LV_MEM_POOL_INCLUDE
#undef LV_MEM_POOL_ALLOC
#endif
#else /*LV_MEM_CUSTOM*/
@@ -722,11 +722,11 @@
/*Music player demo*/
#define LV_USE_DEMO_MUSIC 0
#if LV_USE_DEMO_MUSIC
# define LV_DEMO_MUSIC_SQUARE 0
# define LV_DEMO_MUSIC_LANDSCAPE 0
# define LV_DEMO_MUSIC_ROUND 0
# define LV_DEMO_MUSIC_LARGE 0
# define LV_DEMO_MUSIC_AUTO_PLAY 0
#define LV_DEMO_MUSIC_SQUARE 0
#define LV_DEMO_MUSIC_LANDSCAPE 0
#define LV_DEMO_MUSIC_ROUND 0
#define LV_DEMO_MUSIC_LARGE 0
#define LV_DEMO_MUSIC_AUTO_PLAY 0
#endif
/*--END OF LV_CONF_H--*/

View File

@@ -92,19 +92,19 @@ for line in fin.read().splitlines():
if '/*--END OF LV_CONF_H--*/' in line: break
#Is there a #define in this line?
r = re.search(r'^([\s]*)#[\s]*define[\s]+([^\s]+).*$', line) # \s means any white space character
r = re.search(r'^([\s]*)#[\s]*(undef|define)[\s]+([^\s]+).*$', line) # \s means any white space character
if r:
indent = r[1]
name = r[2]
name = r[3]
name = re.sub('\(.*?\)', '', name, 1) #remove parentheses from macros. E.g. MY_FUNC(5) -> MY_FUNC
name_and_value = re.sub('[\s]*#[\s]*define', '', line, 1)
line = re.sub('[\s]*', '', line, 1)
#If the value should be 1 (enabled) by default use a more complex structure for Kconfig checks because
#if a not defined CONFIG_... value should be interpreted as 0 and not the LVGL default
is_one = re.search(r'[\s]*#[\s]*define[\s]*[A-Z0-9_]+[\s]+1([\s]*$|[\s]+)', line)
is_one = re.search(r'#[\s]*define[\s]*[A-Z0-9_]+[\s]+1([\s]*$|[\s]+)', line)
if is_one:
#1. Use the value if already set from lv_conf.h or anything else (i.e. do nothing)
#2. In Kconfig environment use the CONFIG_... value if set, else use 0
@@ -119,7 +119,7 @@ for line in fin.read().splitlines():
f'{indent} #define {name} 0\n'
f'{indent} #endif\n'
f'{indent} #else\n'
f'{indent} #define{name_and_value}\n'
f'{indent} {line}\n'
f'{indent} #endif\n'
f'{indent}#endif\n'
)
@@ -133,7 +133,7 @@ for line in fin.read().splitlines():
f'{indent} #ifdef CONFIG_{name.upper()}\n'
f'{indent} #define {name} CONFIG_{name.upper()}\n'
f'{indent} #else\n'
f'{indent} #define{name_and_value}\n'
f'{indent} {line}\n'
f'{indent} #endif\n'
f'{indent}#endif\n'
)

View File

@@ -141,8 +141,20 @@
#endif
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
#if LV_MEM_ADR == 0
//#define LV_MEM_POOL_INCLUDE your_alloc_library /* Uncomment if using an external allocator*/
//#define LV_MEM_POOL_ALLOC your_alloc /* Uncomment if using an external allocator*/
#ifndef LV_MEM_POOL_INCLUDE
#ifdef CONFIG_LV_MEM_POOL_INCLUDE
#define LV_MEM_POOL_INCLUDE CONFIG_LV_MEM_POOL_INCLUDE
#else
#undef LV_MEM_POOL_INCLUDE
#endif
#endif
#ifndef LV_MEM_POOL_ALLOC
#ifdef CONFIG_LV_MEM_POOL_ALLOC
#define LV_MEM_POOL_ALLOC CONFIG_LV_MEM_POOL_ALLOC
#else
#undef LV_MEM_POOL_ALLOC
#endif
#endif
#endif
#else /*LV_MEM_CUSTOM*/
@@ -2308,41 +2320,41 @@
#endif
#endif
#if LV_USE_DEMO_MUSIC
#ifndef LV_DEMO_MUSIC_SQUARE
#ifndef LV_DEMO_MUSIC_SQUARE
#ifdef CONFIG_LV_DEMO_MUSIC_SQUARE
#define LV_DEMO_MUSIC_SQUARE CONFIG_LV_DEMO_MUSIC_SQUARE
#else
#define LV_DEMO_MUSIC_SQUARE 0
#endif
#endif
#ifndef LV_DEMO_MUSIC_LANDSCAPE
#endif
#ifndef LV_DEMO_MUSIC_LANDSCAPE
#ifdef CONFIG_LV_DEMO_MUSIC_LANDSCAPE
#define LV_DEMO_MUSIC_LANDSCAPE CONFIG_LV_DEMO_MUSIC_LANDSCAPE
#else
#define LV_DEMO_MUSIC_LANDSCAPE 0
#endif
#endif
#ifndef LV_DEMO_MUSIC_ROUND
#endif
#ifndef LV_DEMO_MUSIC_ROUND
#ifdef CONFIG_LV_DEMO_MUSIC_ROUND
#define LV_DEMO_MUSIC_ROUND CONFIG_LV_DEMO_MUSIC_ROUND
#else
#define LV_DEMO_MUSIC_ROUND 0
#endif
#endif
#ifndef LV_DEMO_MUSIC_LARGE
#endif
#ifndef LV_DEMO_MUSIC_LARGE
#ifdef CONFIG_LV_DEMO_MUSIC_LARGE
#define LV_DEMO_MUSIC_LARGE CONFIG_LV_DEMO_MUSIC_LARGE
#else
#define LV_DEMO_MUSIC_LARGE 0
#endif
#endif
#ifndef LV_DEMO_MUSIC_AUTO_PLAY
#endif
#ifndef LV_DEMO_MUSIC_AUTO_PLAY
#ifdef CONFIG_LV_DEMO_MUSIC_AUTO_PLAY
#define LV_DEMO_MUSIC_AUTO_PLAY CONFIG_LV_DEMO_MUSIC_AUTO_PLAY
#else
#define LV_DEMO_MUSIC_AUTO_PLAY 0
#endif
#endif
#endif
#endif