mirror of
https://github.com/lvgl/lvgl.git
synced 2026-06-01 16:58:33 +08:00
chore(conf): ensure the template and generated file conform the coding style (#2823)
* fix(conf): ensure the template and generated file conform the coding style and remove lv_conf_internal.h from the excluding list of code-format.cfg Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> * fix(conf): regenerate lv_conf_internal.h Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
@@ -23,7 +23,6 @@
|
|||||||
--suffix=none
|
--suffix=none
|
||||||
--preserve-date
|
--preserve-date
|
||||||
--formatted
|
--formatted
|
||||||
--exclude=lv_conf_internal.h
|
|
||||||
--exclude=../src/font/lv_font_montserrat_12.c
|
--exclude=../src/font/lv_font_montserrat_12.c
|
||||||
--exclude=../src/font/lv_font_montserrat_14.c
|
--exclude=../src/font/lv_font_montserrat_14.c
|
||||||
--exclude=../src/font/lv_font_montserrat_16.c
|
--exclude=../src/font/lv_font_montserrat_16.c
|
||||||
|
|||||||
@@ -82,10 +82,12 @@ for line in fin.read().splitlines():
|
|||||||
if '/*--END OF LV_CONF_H--*/' in line: break
|
if '/*--END OF LV_CONF_H--*/' in line: break
|
||||||
|
|
||||||
#Is there a #define in this line?
|
#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]*define[\s]+([^\s]+).*$', line) # \s means any white space character
|
||||||
|
|
||||||
if r:
|
if r:
|
||||||
name = r[1]
|
indent = r[1]
|
||||||
|
|
||||||
|
name = r[2]
|
||||||
name = re.sub('\(.*?\)', '', name, 1) #remove parentheses from macros. E.g. MY_FUNC(5) -> MY_FUNC
|
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)
|
name_and_value = re.sub('[\s]*#[\s]*define', '', line, 1)
|
||||||
@@ -99,17 +101,17 @@ for line in fin.read().splitlines():
|
|||||||
#3. In not Kconfig environment use the LVGL's default value
|
#3. In not Kconfig environment use the LVGL's default value
|
||||||
|
|
||||||
fout.write(
|
fout.write(
|
||||||
f'#ifndef {name}\n'
|
f'{indent}#ifndef {name}\n'
|
||||||
f'# ifdef _LV_KCONFIG_PRESENT\n'
|
f'{indent} #ifdef _LV_KCONFIG_PRESENT\n'
|
||||||
f'# ifdef CONFIG_{name.upper()}\n'
|
f'{indent} #ifdef CONFIG_{name.upper()}\n'
|
||||||
f'# define {name} CONFIG_{name.upper()}\n'
|
f'{indent} #define {name} CONFIG_{name.upper()}\n'
|
||||||
f'# else\n'
|
f'{indent} #else\n'
|
||||||
f'# define {name} 0\n'
|
f'{indent} #define {name} 0\n'
|
||||||
f'# endif\n'
|
f'{indent} #endif\n'
|
||||||
f'# else\n'
|
f'{indent} #else\n'
|
||||||
f'# define{name_and_value}\n'
|
f'{indent} #define{name_and_value}\n'
|
||||||
f'# endif\n'
|
f'{indent} #endif\n'
|
||||||
f'#endif\n'
|
f'{indent}#endif\n'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
#1. Use the value if already set from lv_conf.h or anything else (i.e. do nothing)
|
#1. Use the value if already set from lv_conf.h or anything else (i.e. do nothing)
|
||||||
@@ -117,13 +119,13 @@ for line in fin.read().splitlines():
|
|||||||
#3. Use the LVGL's default value
|
#3. Use the LVGL's default value
|
||||||
|
|
||||||
fout.write(
|
fout.write(
|
||||||
f'#ifndef {name}\n'
|
f'{indent}#ifndef {name}\n'
|
||||||
f'# ifdef CONFIG_{name.upper()}\n'
|
f'{indent} #ifdef CONFIG_{name.upper()}\n'
|
||||||
f'# define {name} CONFIG_{name.upper()}\n'
|
f'{indent} #define {name} CONFIG_{name.upper()}\n'
|
||||||
f'# else\n'
|
f'{indent} #else\n'
|
||||||
f'# define{name_and_value}\n'
|
f'{indent} #define{name_and_value}\n'
|
||||||
f'# endif\n'
|
f'{indent} #endif\n'
|
||||||
f'#endif\n'
|
f'{indent}#endif\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
elif re.search('^ *typedef .*;.*$', line):
|
elif re.search('^ *typedef .*;.*$', line):
|
||||||
|
|||||||
Reference in New Issue
Block a user