lv_conf_checker syntax changes
This commit is contained in:
@@ -1,54 +1,56 @@
|
|||||||
'''
|
'''
|
||||||
Generates a chechker file for lv_conf.h from lv_conf_templ.h define all the not defined values
|
Generates a checker file for lv_conf.h from lv_conf_templ.h define all the not defined values
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
fin = open("../lv_conf_template.h", "r");
|
fin = open("../lv_conf_template.h", "r")
|
||||||
fout = open("../src/lv_conf_checker.h", "w");
|
fout = open("../src/lv_conf_checker.h", "w")
|
||||||
|
|
||||||
|
|
||||||
fout.write(
|
fout.write(
|
||||||
'/**\n\
|
'''/**
|
||||||
* GENERATED FILE, DO NOT EDIT IT!\n\
|
* GENERATED FILE, DO NOT EDIT IT!
|
||||||
* @file lv_conf_checker.h\n\
|
* @file lv_conf_checker.h
|
||||||
* Make sure all the defines of lv_conf.h have a default value\n\
|
* Make sure all the defines of lv_conf.h have a default value
|
||||||
**/\n\
|
**/
|
||||||
\n\
|
|
||||||
#ifndef LV_CONF_CHECKER_H\n\
|
|
||||||
#define LV_CONF_CHECKER_H\n\
|
|
||||||
'
|
|
||||||
)
|
|
||||||
|
|
||||||
inlines = fin.read().splitlines();
|
#ifndef LV_CONF_CHECKER_H
|
||||||
|
#define LV_CONF_CHECKER_H
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
|
||||||
started = 0
|
started = 0
|
||||||
|
|
||||||
for i in inlines:
|
for i in fin.read().splitlines():
|
||||||
if(not started):
|
if not started:
|
||||||
if('#define LV_CONF_H' in i):
|
if '#define LV_CONF_H' in i:
|
||||||
started = 1
|
started = 1
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if('/*--END OF LV_CONF_H--*/' in i): break
|
if '/*--END OF LV_CONF_H--*/' in i: break
|
||||||
|
|
||||||
if(re.search('^ *# *define .*$', i)):
|
r = re.search(r'^ *# *define ([^\s]+).*$', i)
|
||||||
new = re.sub('^ *# *define', '#define ', i)
|
if r:
|
||||||
new = re.sub(' +', ' ', new) #Remove extra white spaces
|
fout.write(
|
||||||
splitted = new.split(' ')
|
f'#ifndef {r[1]}\n'
|
||||||
fout.write('#ifndef ' + splitted[1] + '\n')
|
f'{i}\n'
|
||||||
fout.write(i + '\n')
|
'#endif\n'
|
||||||
fout.write('#endif\n')
|
)
|
||||||
elif(re.search('^ *typedef .*;.*$', i)):
|
elif re.search('^ *typedef .*;.*$', i):
|
||||||
continue; #igonre typedefs to avoide redeclaration
|
continue #ignore typedefs to avoide redeclaration
|
||||||
else:
|
else:
|
||||||
fout.write(i + '\n')
|
fout.write(f'{i}\n')
|
||||||
|
|
||||||
|
|
||||||
fout.write(
|
fout.write(
|
||||||
'\n\
|
'''
|
||||||
#endif /*LV_CONF_CHECKER_H*/\n\
|
#endif /*LV_CONF_CHECKER_H*/
|
||||||
')
|
'''
|
||||||
|
)
|
||||||
|
|
||||||
|
fin.close()
|
||||||
|
fout.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user