2019-10-11 15:03:12 +02:00
|
|
|
#!/usr/bin/env python3.6
|
|
|
|
|
2018-12-20 00:04:09 +01:00
|
|
|
'''
|
2019-06-27 16:46:54 +02:00
|
|
|
Generates a checker file for lv_conf.h from lv_conf_templ.h define all the not defined values
|
2018-12-20 00:04:09 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
|
2018-12-20 00:01:24 +01:00
|
|
|
import re
|
|
|
|
|
2019-06-27 16:46:54 +02:00
|
|
|
fin = open("../lv_conf_template.h", "r")
|
2020-02-29 13:35:53 +01:00
|
|
|
fout = open("../src/lv_conf_internal.h", "w")
|
2018-12-20 00:01:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
fout.write(
|
2019-06-27 16:46:54 +02:00
|
|
|
'''/**
|
|
|
|
* GENERATED FILE, DO NOT EDIT IT!
|
2020-02-29 13:35:53 +01:00
|
|
|
* @file lv_conf_internal.h
|
2019-06-27 16:46:54 +02:00
|
|
|
* Make sure all the defines of lv_conf.h have a default value
|
|
|
|
**/
|
|
|
|
|
2020-02-29 13:35:53 +01:00
|
|
|
#ifndef LV_CONF_INTERNAL_H
|
|
|
|
#define LV_CONF_INTERNAL_H
|
|
|
|
/* clang-format off */
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#if defined(LV_CONF_PATH)
|
|
|
|
#define __LV_TO_STR_AUX(x) #x
|
|
|
|
#define __LV_TO_STR(x) __LV_TO_STR_AUX(x)
|
|
|
|
#include __LV_TO_STR(LV_CONF_PATH)
|
|
|
|
#undef __LV_TO_STR_AUX
|
|
|
|
#undef __LV_TO_STR
|
|
|
|
#elif defined(LV_CONF_INCLUDE_SIMPLE)
|
|
|
|
#include "lv_conf.h"
|
|
|
|
#else
|
|
|
|
#include "../../lv_conf.h"
|
|
|
|
#endif
|
|
|
|
|
2019-06-27 16:46:54 +02:00
|
|
|
'''
|
|
|
|
)
|
2018-12-20 00:01:24 +01:00
|
|
|
|
|
|
|
started = 0
|
|
|
|
|
2019-06-27 16:46:54 +02:00
|
|
|
for i in fin.read().splitlines():
|
|
|
|
if not started:
|
|
|
|
if '#define LV_CONF_H' in i:
|
|
|
|
started = 1
|
2018-12-20 00:01:24 +01:00
|
|
|
continue
|
|
|
|
else:
|
|
|
|
continue
|
2019-06-27 16:46:54 +02:00
|
|
|
|
|
|
|
if '/*--END OF LV_CONF_H--*/' in i: break
|
|
|
|
|
|
|
|
r = re.search(r'^ *# *define ([^\s]+).*$', i)
|
2019-10-11 15:03:12 +02:00
|
|
|
|
2019-06-27 16:46:54 +02:00
|
|
|
if r:
|
2019-10-11 15:03:12 +02:00
|
|
|
line = re.sub('\(.*?\)', '', r[1], 1) #remove parentheses from macros
|
2019-06-27 16:46:54 +02:00
|
|
|
fout.write(
|
2019-10-11 15:03:12 +02:00
|
|
|
f'#ifndef {line}\n'
|
2019-06-27 16:46:54 +02:00
|
|
|
f'{i}\n'
|
|
|
|
'#endif\n'
|
|
|
|
)
|
|
|
|
elif re.search('^ *typedef .*;.*$', i):
|
|
|
|
continue #ignore typedefs to avoide redeclaration
|
2018-12-20 00:01:24 +01:00
|
|
|
else:
|
2019-06-27 16:46:54 +02:00
|
|
|
fout.write(f'{i}\n')
|
|
|
|
|
|
|
|
|
2018-12-20 00:01:24 +01:00
|
|
|
fout.write(
|
2019-06-27 16:46:54 +02:00
|
|
|
'''
|
|
|
|
#endif /*LV_CONF_CHECKER_H*/
|
|
|
|
'''
|
|
|
|
)
|
|
|
|
|
|
|
|
fin.close()
|
|
|
|
fout.close()
|