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:
@@ -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*/
|
||||
|
||||
@@ -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'
|
||||
)
|
||||
|
||||
@@ -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*/
|
||||
|
||||
Reference in New Issue
Block a user