mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
chore(Kconfig): add version info to Kconfig file to check mismatch (#6789)
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
parent
57b799f4fc
commit
8dea3225ff
10
Kconfig
10
Kconfig
@ -1536,6 +1536,16 @@ menu "LVGL configuration"
|
||||
int "Font manager name max length"
|
||||
depends on LV_USE_FONT_MANAGER
|
||||
default 32
|
||||
|
||||
config LVGL_VERSION_MAJOR
|
||||
int
|
||||
default 9 # LVGL_VERSION_MAJOR
|
||||
config LVGL_VERSION_MINOR
|
||||
int
|
||||
default 2 # LVGL_VERSION_MINOR
|
||||
config LVGL_VERSION_PATCH
|
||||
int
|
||||
default 0 # LVGL_VERSION_PATCH
|
||||
endmenu
|
||||
|
||||
menu "Devices"
|
||||
|
@ -122,6 +122,35 @@ class CmakeReplacer(MacroReplacer):
|
||||
def getReplacement(self, val: str):
|
||||
return r'\g<1>' + val + r'\g<3>'
|
||||
|
||||
class KconfigReplacer(RepoFileVersionReplacer):
|
||||
"""Replace version info in Kconfig file"""
|
||||
|
||||
def __init__(self, relative_path_segments: List[str]):
|
||||
super().__init__(relative_path_segments, 3)
|
||||
|
||||
def applyVersionToLine(self, line: str, version: Version):
|
||||
targets = {
|
||||
'LVGL_VERSION_MAJOR': version.major,
|
||||
'LVGL_VERSION_MINOR': version.minor,
|
||||
'LVGL_VERSION_PATCH': version.patch,
|
||||
}
|
||||
|
||||
for key, val in targets.items():
|
||||
pattern = self.getPattern(key)
|
||||
repl = self.getReplacement(val)
|
||||
replaced, n = re.subn(pattern, repl, line)
|
||||
if n > 0:
|
||||
return replaced
|
||||
|
||||
return None
|
||||
def getPattern(self, key: str):
|
||||
# Match the version fields in Kconfig file
|
||||
return rf'(^\s+default\s+)(\d+) # ({key})'
|
||||
|
||||
def getReplacement(self, val: str):
|
||||
# Replace the version value
|
||||
return r'\g<1>' + val + r' # \g<3>'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = get_arg()
|
||||
@ -133,6 +162,7 @@ if __name__ == '__main__':
|
||||
MacroReplacer(['lv_version.h']),
|
||||
CmakeReplacer(['env_support', 'cmake', 'version.cmake']),
|
||||
PrefixReplacer(['lv_conf_template.h'], 'Configuration file for v'),
|
||||
KconfigReplacer(['Kconfig']),
|
||||
]
|
||||
|
||||
if version.is_release:
|
||||
|
@ -18,6 +18,16 @@ extern "C" {
|
||||
|
||||
# ifdef __NuttX__
|
||||
# include <nuttx/config.h>
|
||||
/*
|
||||
* Make sure version number in Kconfig file is correctly set.
|
||||
* Mismatch can happen when user manually copy lvgl/Kconfig file to their project, like what NuttX does.
|
||||
*/
|
||||
# include "../lv_version.h"
|
||||
|
||||
# if CONFIG_LVGL_VERSION_MAJOR != LVGL_VERSION_MAJOR || CONFIG_LVGL_VERSION_MINOR != LVGL_VERSION_MINOR \
|
||||
|| CONFIG_LVGL_VERSION_PATCH != LVGL_VERSION_PATCH
|
||||
# warning "Version mismatch between Kconfig and lvgl/lv_version.h"
|
||||
# endif
|
||||
# elif defined(__RTTHREAD__)
|
||||
# define LV_CONF_INCLUDE_SIMPLE
|
||||
# include <lv_rt_thread_conf.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user