1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/scripts/lv_conf_internal_gen.py

185 lines
5.3 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
2018-12-20 00:04:09 +01:00
'''
Generates lv_conf_internal.h from lv_conf_template.h to provide default values
2018-12-20 00:04:09 +01:00
'''
import os
import sys
2018-12-20 00:01:24 +01:00
import re
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")
if sys.version_info < (3,6,0):
print("Python >=3.6 is required", file=sys.stderr)
exit(1)
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
/* clang-format off */
2020-02-29 13:35:53 +01:00
#include <stdint.h>
/* Handle special Kconfig options */
#ifndef LV_KCONFIG_IGNORE
#include "lv_conf_kconfig.h"
#ifdef CONFIG_LV_CONF_SKIP
#define LV_CONF_SKIP
#endif
Update Kconfig. (#1917) * Kconfig: Add missing _HEX to LV_COLOR_TRANSP option. * lv_conf_checker: Define LV_CONF_SKIP if CONFIG_LV_CONF_SKIP is defined. * fix(indev): disabled object shouldn't absorb clicks but let the parent to be clicked * Update README.md * fix(arabic): support processing again alraedy processed texts with _lv_txt_ap_proc * fix(textarea): support Arabic letter connections fixes #1888 * Fix #1924: incorrect date on changelog December 1st is two weeks from 7.7.2 release. * Kconfig: Fix LV_CONF_MINIMAL related options. * fix(arabic): support Arabic letter connections fixes #1920 * fix(arabic): support Arabic letter connections in value string property * Update CHANGELOG.md * Update CHANGELOG.md * Kconfig: Add Zephyr specific code. * fix: fix double include in lv_obj.c fix #1926 * Removed trailing semi-colon from macros (#1928) * Removed commented out test definition Removed commented out test definition LV_BUILD_TEST * Remove blank line * Fix comment spelling * Added blank line * Removed trailing semi-colon in macros * fix(indev): in LV_INDEV_TYPE_BUTTON recognize 1 cycle long presses too Fixes https://forum.lvgl.io/t/bug-in-indev-button-proc-misses-buttons-that-are-pressed-for-a-single-callback/3699 * fix(arc): make arc work with encoder fixes https://forum.lvgl.io/t/lv-arc-with-encoder-lv-group/3769 * fix(slider): adjusting the left knob too with encoder https://forum.lvgl.io/t/slider-with-2-knobs-and-encoder-functionality/3770 * fix(arc_draw): remove statments that do nothing fix #1930 * Change LV_DRAW_BUF_MAX_NUM to LV_MEM_BUF_MAX_NUM (#1931) * Update CHANGELOG.md * fix(draw polygon): join adjacent points if they are on the same coordinate * fix(draw polygon): fix memory leak and vertex joining * fix(style): invalidate cache on every PART Inherited properties on parts other than MAIN needs to be recached on property change beacuse they are inherted from MAIN fixes #1933 * fix(anim): fix bounce path * fix(slider): do not let edit left knob in non-range mode * Update ROADMAP.md * Fix hardfault when DCache is disabled with no callback (#1935) * fix(linemeter): fix invalidation when setting new value The old complex but more optimal invalidation was buggy in some cases fixes #1904 * fix(linemeter): fix invalidation when setting new value The old complex but more optimal invalidation was buggy in some cases fixes #1904 * fix(table): add missing invalidation when changeing cell type fixes https://forum.lvgl.io/t/bug-of-table-click-to-change-style/3842 * CMakeLists.txt: Let the user configure whether LV_ATTRIBUTE_FAST_MEM is IRAM_ATTR (#1939) * fix(slider): fix left/right knob control with encoder * fix(img): increase the size of invalidated area in lv_img_set_zoom Becasue of the pivot placement there can be some rounding errors * feat(perf_monitor): add lv_refr_get_fps_avg() * Add 8px and 10px montserrat fonts to build (#1941) * Fix #1942: lv_textarea_set_pwd_mode not changing to bullets Thanks to @fvanroie for investigating. * fix(material): make button pressed color darker (#1940) * simplify touch handling in the Arduino example * Update ROADMAP.md * Update ROADMAP.md * feat(lv_conf_kconfig): add LV_CONF_KCONFIG_EXTERNAL_INCLUDE Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com> Co-authored-by: embeddedt <42941056+embeddedt@users.noreply.github.com> Co-authored-by: xennex22 <25083624+xennex22@users.noreply.github.com> Co-authored-by: incity <610455681@qq.com> Co-authored-by: Andrey <spirit@spirit.re> Co-authored-by: defogprog <22955033+defogprog@users.noreply.github.com>
2020-12-01 08:04:20 -06:00
#endif
/*If "lv_conf.h" is available from here try to use it later.*/
#ifdef __has_include
#if __has_include("lv_conf.h")
#ifndef LV_CONF_INCLUDE_SIMPLE
#define LV_CONF_INCLUDE_SIMPLE
#endif
#endif
#endif
/*If lv_conf.h is not skipped include it*/
#ifndef LV_CONF_SKIP
#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
#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
#ifdef CONFIG_LV_COLOR_DEPTH
#define _LV_KCONFIG_PRESENT
#endif
/*----------------------------------
* Start parsing lv_conf_template.h
-----------------------------------*/
2019-06-27 16:46:54 +02:00
'''
)
2018-12-20 00:01:24 +01:00
started = 0
for line in fin.read().splitlines():
2019-06-27 16:46:54 +02:00
if not started:
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
if '/*--END OF LV_CONF_H--*/' in line: break
2019-06-27 16:46:54 +02:00
#Is there a #define in this line?
r = re.search(r'^([\s]*)#[\s]*(undef|define)[\s]+([^\s]+).*$', line) # \s means any white space character
2019-06-27 16:46:54 +02:00
if r:
indent = r[1]
name = r[3]
name = re.sub('\(.*?\)', '', name, 1) #remove parentheses from macros. E.g. MY_FUNC(5) -> MY_FUNC
line = re.sub('[\s]*', '', 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'#[\s]*define[\s]*[A-Z0-9_]+[\s]+1([\s]*$|[\s]+)', 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'{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'
f'{indent} {line}\n'
f'{indent} #endif\n'
f'{indent}#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'{indent}#ifndef {name}\n'
f'{indent} #ifdef CONFIG_{name.upper()}\n'
f'{indent} #define {name} CONFIG_{name.upper()}\n'
f'{indent} #else\n'
f'{indent} {line}\n'
f'{indent} #endif\n'
f'{indent}#endif\n'
)
elif re.search('^ *typedef .*;.*$', line):
continue #ignore typedefs to avoid redeclaration
2018-12-20 00:01:24 +01:00
else:
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
'''
/*----------------------------------
* End of parsing lv_conf_template.h
-----------------------------------*/
LV_EXPORT_CONST_INT(LV_DPI_DEF);
#undef _LV_KCONFIG_PRESENT
/*Set some defines if a dependency is disabled*/
#if LV_USE_LOG == 0
#define LV_LOG_LEVEL LV_LOG_LEVEL_NONE
#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*/
#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)*/
#endif /*LV_CONF_INTERNAL_H*/
2019-06-27 16:46:54 +02:00
'''
)
fin.close()
fout.close()