2020-06-17 20:49:06 +01:00
|
|
|
#!/usr/bin/env python3
|
2019-10-11 15:03:12 +02:00
|
|
|
|
2018-12-20 00:04:09 +01:00
|
|
|
'''
|
2021-09-23 10:52:31 -07:00
|
|
|
Generates lv_conf_internal.h from lv_conf_template.h to provide default values
|
2018-12-20 00:04:09 +01:00
|
|
|
'''
|
|
|
|
|
2020-06-17 20:49:06 +01:00
|
|
|
import sys
|
2018-12-20 00:01:24 +01:00
|
|
|
import re
|
|
|
|
|
2020-06-17 20:49:06 +01:00
|
|
|
if sys.version_info < (3,6,0):
|
|
|
|
print("Python >=3.6 is required", file=sys.stderr)
|
|
|
|
exit(1)
|
|
|
|
|
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
|
2021-08-07 16:04:17 -04:00
|
|
|
/* clang-format off */
|
2020-02-29 13:35:53 +01:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2021-03-25 00:54:03 +02:00
|
|
|
/* Handle special Kconfig options */
|
|
|
|
#ifndef LV_KCONFIG_IGNORE
|
2021-10-12 09:15:05 -07:00
|
|
|
# include "lv_conf_kconfig.h"
|
|
|
|
# ifdef CONFIG_LV_CONF_SKIP
|
|
|
|
# define LV_CONF_SKIP
|
|
|
|
# endif
|
2020-12-01 08:04:20 -06:00
|
|
|
#endif
|
|
|
|
|
2021-03-15 02:03:27 +08:00
|
|
|
/*If "lv_conf.h" is available from here try to use it later.*/
|
2021-10-12 09:15:05 -07:00
|
|
|
#ifdef __has_include
|
2020-10-26 12:40:05 +01:00
|
|
|
# if __has_include("lv_conf.h")
|
2021-10-12 09:15:05 -07:00
|
|
|
# ifndef LV_CONF_INCLUDE_SIMPLE
|
|
|
|
# define LV_CONF_INCLUDE_SIMPLE
|
|
|
|
# endif
|
2020-10-26 12:40:05 +01:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2020-09-08 14:39:07 +02:00
|
|
|
/*If lv_conf.h is not skipped include it*/
|
2021-10-12 09:15:05 -07:00
|
|
|
#ifndef LV_CONF_SKIP
|
|
|
|
# ifdef LV_CONF_PATH /*If there is a path defined for lv_conf.h use it*/
|
2020-09-08 14:39:07 +02:00
|
|
|
# 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) /*Or simply include lv_conf.h is enabled*/
|
|
|
|
# include "lv_conf.h"
|
|
|
|
# else
|
2021-03-15 02:03:27 +08:00
|
|
|
# include "../../lv_conf.h" /*Else assume lv_conf.h is next to the lvgl folder*/
|
2020-09-08 14:39:07 +02:00
|
|
|
# endif
|
2020-02-29 13:35:53 +01:00
|
|
|
#endif
|
|
|
|
|
2021-11-05 22:41:47 +08:00
|
|
|
#ifdef CONFIG_LV_COLOR_DEPTH
|
|
|
|
# define _LV_KCONFIG_PRESENT
|
|
|
|
#endif
|
2021-04-26 12:20:57 +02:00
|
|
|
|
|
|
|
/*----------------------------------
|
|
|
|
* Start parsing lv_conf_template.h
|
|
|
|
-----------------------------------*/
|
2019-06-27 16:46:54 +02:00
|
|
|
'''
|
|
|
|
)
|
2018-12-20 00:01:24 +01:00
|
|
|
|
|
|
|
started = 0
|
|
|
|
|
2021-11-05 22:41:47 +08:00
|
|
|
for line in fin.read().splitlines():
|
2019-06-27 16:46:54 +02:00
|
|
|
if not started:
|
2021-11-05 22:41:47 +08:00
|
|
|
if '#define LV_CONF_H' in line:
|
2019-06-27 16:46:54 +02:00
|
|
|
started = 1
|
2018-12-20 00:01:24 +01:00
|
|
|
continue
|
|
|
|
else:
|
|
|
|
continue
|
2019-06-27 16:46:54 +02:00
|
|
|
|
2021-11-05 22:41:47 +08:00
|
|
|
if '/*--END OF LV_CONF_H--*/' in line: break
|
2019-06-27 16:46:54 +02:00
|
|
|
|
2021-11-05 22:41:47 +08:00
|
|
|
#Is there a #define in this line?
|
|
|
|
r = re.search(r'^[\s]*#[\s]*define[\s]+([^\s]+).*$', line) # \s means any white space character
|
2021-01-11 07:28:00 -06:00
|
|
|
|
2019-06-27 16:46:54 +02:00
|
|
|
if r:
|
2021-11-05 22:41:47 +08:00
|
|
|
name = r[1]
|
|
|
|
name = re.sub('\(.*?\)', '', name, 1) #remove parentheses from macros. E.g. MY_FUNC(5) -> MY_FUNC
|
|
|
|
|
|
|
|
name_and_value = re.sub('.*# *define', '', line, 1)
|
|
|
|
|
|
|
|
#If the value should be 1 (enabled) by default use a more complex structure for Kconfig checks because
|
|
|
|
#if a not defined CONFIG_... value should be interpreted as 0 and not the LVGL default
|
|
|
|
is_one = re.search(r'.*#.*define +[A-Z0-9_]+ +1[^0-9]*', line)
|
|
|
|
if(is_one):
|
|
|
|
#1. Use the value if already set from lv_conf.h or anything else (i.e. do nothing)
|
|
|
|
#2. In Kconfig environment use the CONFIG_... value if set, else use 0
|
|
|
|
#3. In not Kconfig environment use the LVGL's default value
|
|
|
|
|
|
|
|
fout.write(
|
|
|
|
f'#ifndef {name}\n'
|
|
|
|
f'# ifdef _LV_KCONFIG_PRESENT\n'
|
|
|
|
f'# ifdef CONFIG_{name.upper()}\n'
|
|
|
|
f'# define {name} CONFIG_{name.upper()}\n'
|
|
|
|
f'# else\n'
|
|
|
|
f'# define {name} 0\n'
|
|
|
|
f'# endif\n'
|
|
|
|
f'# else\n'
|
|
|
|
f'# define {name_and_value}\n'
|
|
|
|
f'# endif\n'
|
|
|
|
f'#endif\n'
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
#1. Use the value if already set from lv_conf.h or anything else (i.e. do nothing)
|
|
|
|
#2. Use the Kconfig value if set
|
|
|
|
#3. Use the LVGL's default value
|
|
|
|
|
|
|
|
fout.write(
|
|
|
|
f'#ifndef {name}\n'
|
|
|
|
f'# ifdef CONFIG_{name.upper()}\n'
|
|
|
|
f'# define {name} CONFIG_{name.upper()}\n'
|
|
|
|
f'# else\n'
|
|
|
|
f'# define {name_and_value}\n'
|
|
|
|
f'# endif\n'
|
|
|
|
f'#endif\n'
|
|
|
|
)
|
|
|
|
|
|
|
|
elif re.search('^ *typedef .*;.*$', line):
|
2019-06-27 16:46:54 +02:00
|
|
|
continue #ignore typedefs to avoide redeclaration
|
2018-12-20 00:01:24 +01:00
|
|
|
else:
|
2021-11-05 22:41:47 +08:00
|
|
|
fout.write(f'{line}\n')
|
2019-06-27 16:46:54 +02:00
|
|
|
|
2018-12-20 00:01:24 +01:00
|
|
|
fout.write(
|
2019-06-27 16:46:54 +02:00
|
|
|
'''
|
2020-09-08 14:39:07 +02:00
|
|
|
|
2021-04-26 12:20:57 +02:00
|
|
|
/*----------------------------------
|
|
|
|
* End of parsing lv_conf_template.h
|
|
|
|
-----------------------------------*/
|
2020-09-08 14:39:07 +02:00
|
|
|
|
2021-04-26 12:20:57 +02:00
|
|
|
LV_EXPORT_CONST_INT(LV_DPI_DEF);
|
2020-09-08 14:39:07 +02:00
|
|
|
|
2021-11-05 22:41:47 +08:00
|
|
|
#undef _LV_KCONFIG_PRESENT
|
|
|
|
|
2021-04-26 12:20:57 +02:00
|
|
|
/*If running without lv_conf.h add typdesf with default value*/
|
2021-10-12 09:15:05 -07:00
|
|
|
#ifdef LV_CONF_SKIP
|
|
|
|
# if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /*Disable warnings for Visual Studio*/
|
|
|
|
# define _CRT_SECURE_NO_WARNINGS
|
|
|
|
# endif
|
2021-02-14 14:56:34 +01:00
|
|
|
#endif /*defined(LV_CONF_SKIP)*/
|
2020-09-08 14:39:07 +02:00
|
|
|
|
|
|
|
#endif /*LV_CONF_INTERNAL_H*/
|
2019-06-27 16:46:54 +02:00
|
|
|
'''
|
|
|
|
)
|
|
|
|
|
|
|
|
fin.close()
|
|
|
|
fout.close()
|