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
|
|
|
'''
|
|
|
|
|
2022-02-22 19:45:33 +01:00
|
|
|
import os
|
2020-06-17 20:49:06 +01:00
|
|
|
import sys
|
2018-12-20 00:01:24 +01:00
|
|
|
import re
|
|
|
|
|
2022-02-22 19:45:33 +01:00
|
|
|
SCRIPT_DIR = os.path.dirname(__file__)
|
|
|
|
LV_CONF_TEMPLATE = os.path.join(SCRIPT_DIR, "..", "lv_conf_template.h")
|
|
|
|
LV_CONF_INTERNAL = os.path.join(SCRIPT_DIR, "..", "src", "lv_conf_internal.h")
|
|
|
|
|
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)
|
|
|
|
|
2022-02-22 19:45:33 +01:00
|
|
|
fin = open(LV_CONF_TEMPLATE)
|
|
|
|
fout = open(LV_CONF_INTERNAL, "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-11-22 02:52:26 -06: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
|
2021-11-22 02:52:26 -06:00
|
|
|
#if __has_include("lv_conf.h")
|
|
|
|
#ifndef LV_CONF_INCLUDE_SIMPLE
|
|
|
|
#define LV_CONF_INCLUDE_SIMPLE
|
|
|
|
#endif
|
|
|
|
#endif
|
2020-10-26 12:40:05 +01:00
|
|
|
#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
|
2021-11-22 02:52:26 -06:00
|
|
|
#ifdef LV_CONF_PATH /*If there is a path defined for lv_conf.h use it*/
|
|
|
|
#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
|
|
|
|
#include "../../lv_conf.h" /*Else assume lv_conf.h is next to the lvgl folder*/
|
|
|
|
#endif
|
2022-02-11 09:25:44 -05:00
|
|
|
#if !defined(LV_CONF_H) && !defined(LV_CONF_SUPPRESS_DEFINE_CHECK)
|
|
|
|
/* #include will sometimes silently fail when __has_include is used */
|
|
|
|
/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80753 */
|
|
|
|
#pragma message("Possible failure to include lv_conf.h, please read the comment in this file if you get errors")
|
|
|
|
#endif
|
2020-02-29 13:35:53 +01:00
|
|
|
#endif
|
|
|
|
|
2021-11-08 07:40:08 -06:00
|
|
|
#ifdef CONFIG_LV_COLOR_DEPTH
|
2021-11-22 02:52:26 -06:00
|
|
|
#define _LV_KCONFIG_PRESENT
|
2021-11-05 22:41:47 +08:00
|
|
|
#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?
|
2022-05-05 02:58:09 +08:00
|
|
|
r = re.search(r'^([\s]*)#[\s]*(undef|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-22 02:52:26 -06:00
|
|
|
indent = r[1]
|
|
|
|
|
2022-05-05 02:58:09 +08:00
|
|
|
name = r[3]
|
2021-11-05 22:41:47 +08:00
|
|
|
name = re.sub('\(.*?\)', '', name, 1) #remove parentheses from macros. E.g. MY_FUNC(5) -> MY_FUNC
|
|
|
|
|
2022-05-05 02:58:09 +08:00
|
|
|
line = re.sub('[\s]*', '', line, 1)
|
2021-11-08 07:40:08 -06:00
|
|
|
|
|
|
|
#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
|
2022-05-05 02:58:09 +08:00
|
|
|
is_one = re.search(r'#[\s]*define[\s]*[A-Z0-9_]+[\s]+1([\s]*$|[\s]+)', line)
|
2022-02-22 19:45:33 +01:00
|
|
|
if is_one:
|
2021-11-05 22:41:47 +08:00
|
|
|
#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
|
2021-11-08 07:40:08 -06:00
|
|
|
|
2021-11-05 22:41:47 +08:00
|
|
|
fout.write(
|
2021-11-22 02:52:26 -06:00
|
|
|
f'{indent}#ifndef {name}\n'
|
|
|
|
f'{indent} #ifdef _LV_KCONFIG_PRESENT\n'
|
|
|
|
f'{indent} #ifdef CONFIG_{name.upper()}\n'
|
|
|
|
f'{indent} #define {name} CONFIG_{name.upper()}\n'
|
|
|
|
f'{indent} #else\n'
|
|
|
|
f'{indent} #define {name} 0\n'
|
|
|
|
f'{indent} #endif\n'
|
|
|
|
f'{indent} #else\n'
|
2022-05-05 02:58:09 +08:00
|
|
|
f'{indent} {line}\n'
|
2021-11-22 02:52:26 -06:00
|
|
|
f'{indent} #endif\n'
|
|
|
|
f'{indent}#endif\n'
|
2021-11-08 07:40:08 -06:00
|
|
|
)
|
2021-11-05 22:41:47 +08:00
|
|
|
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
|
2021-11-08 07:40:08 -06:00
|
|
|
|
2021-11-05 22:41:47 +08:00
|
|
|
fout.write(
|
2021-11-22 02:52:26 -06:00
|
|
|
f'{indent}#ifndef {name}\n'
|
|
|
|
f'{indent} #ifdef CONFIG_{name.upper()}\n'
|
|
|
|
f'{indent} #define {name} CONFIG_{name.upper()}\n'
|
|
|
|
f'{indent} #else\n'
|
2022-05-05 02:58:09 +08:00
|
|
|
f'{indent} {line}\n'
|
2021-11-22 02:52:26 -06:00
|
|
|
f'{indent} #endif\n'
|
|
|
|
f'{indent}#endif\n'
|
2021-11-08 07:40:08 -06:00
|
|
|
)
|
|
|
|
|
2021-11-05 22:41:47 +08:00
|
|
|
elif re.search('^ *typedef .*;.*$', line):
|
2022-01-17 14:10:23 +01:00
|
|
|
continue #ignore typedefs to avoid 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
|
|
|
|
|
2022-01-10 11:16:02 +01:00
|
|
|
|
2022-01-17 14:10:23 +01:00
|
|
|
/*Set some defines if a dependency is disabled*/
|
2022-01-10 11:16:02 +01:00
|
|
|
#if LV_USE_LOG == 0
|
2022-01-12 22:14:49 +08:00
|
|
|
#define LV_LOG_LEVEL LV_LOG_LEVEL_NONE
|
2022-01-10 11:16:02 +01:00
|
|
|
#define LV_LOG_TRACE_MEM 0
|
|
|
|
#define LV_LOG_TRACE_TIMER 0
|
|
|
|
#define LV_LOG_TRACE_INDEV 0
|
|
|
|
#define LV_LOG_TRACE_DISP_REFR 0
|
|
|
|
#define LV_LOG_TRACE_EVENT 0
|
|
|
|
#define LV_LOG_TRACE_OBJ_CREATE 0
|
|
|
|
#define LV_LOG_TRACE_LAYOUT 0
|
|
|
|
#define LV_LOG_TRACE_ANIM 0
|
|
|
|
#endif /*LV_USE_LOG*/
|
|
|
|
|
|
|
|
|
|
|
|
/*If running without lv_conf.h add typedefs with default value*/
|
2021-10-12 09:15:05 -07:00
|
|
|
#ifdef LV_CONF_SKIP
|
2021-11-22 02:52:26 -06:00
|
|
|
#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()
|