-
Notifications
You must be signed in to change notification settings - Fork 0
/
lv_conf_checker.py
52 lines (40 loc) · 1.04 KB
/
lv_conf_checker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'''
Generates a chechker file for lv_conf.h from lv_conf_templ.h define all the not defined values
'''
import re
fin = open("lv_conf_templ.h", "r");
fout = open("lv_conf_checker.h", "w");
fout.write(
'/**\n\
* GENERATED FILE, DO NOT EDIT IT!\n\
* @file lv_conf_checker.h\n\
* Make sure all the defines of lv_conf.h have a default value\n\
**/\n\
\n\
#ifndef LV_CONF_CHECKER_H\n\
#define LV_CONF_CHECKER_H\n\
'
)
inlines = fin.read().splitlines();
started = 0
for i in inlines:
if(not started):
if('#define LV_CONF_H' in i):
started = 1
continue
else:
continue
if('/*--END OF LV_CONF_H--*/' in i): break
if(re.search('^ *# *define .*$', i)):
new = re.sub('^ *# *define', '#define ', i)
new = re.sub(' +', ' ', new) #Remove extra white spaces
splitted = new.split(' ')
fout.write('#ifndef ' + splitted[1] + '\n')
fout.write(i + '\n')
fout.write('#endif\n')
else:
fout.write(i + '\n')
fout.write(
'\n\
#endif /*LV_CONF_CHECKER_H*/\n\
')