1''' 2Generates a checker file for lv_conf.h from lv_conf_templ.h define all the not defined values 3''' 4 5 6import re 7 8fin = open("../lv_conf_template.h", "r") 9fout = open("../src/lv_conf_checker.h", "w") 10 11 12fout.write( 13'''/** 14 * GENERATED FILE, DO NOT EDIT IT! 15 * @file lv_conf_checker.h 16 * Make sure all the defines of lv_conf.h have a default value 17**/ 18 19#ifndef LV_CONF_CHECKER_H 20#define LV_CONF_CHECKER_H 21''' 22) 23 24started = 0 25 26for i in fin.read().splitlines(): 27 if not started: 28 if '#define LV_CONF_H' in i: 29 started = 1 30 continue 31 else: 32 continue 33 34 if '/*--END OF LV_CONF_H--*/' in i: break 35 36 r = re.search(r'^ *# *define ([^\s]+).*$', i) 37 if r: 38 fout.write( 39 f'#ifndef {r[1]}\n' 40 f'{i}\n' 41 '#endif\n' 42 ) 43 elif re.search('^ *typedef .*;.*$', i): 44 continue #ignore typedefs to avoide redeclaration 45 else: 46 fout.write(f'{i}\n') 47 48 49fout.write( 50''' 51#endif /*LV_CONF_CHECKER_H*/ 52''' 53) 54 55fin.close() 56fout.close() 57