ci(lv_templ): fix filename template mismatches and add CI (#8326)

This commit is contained in:
Liam Howatt
2025-06-19 11:42:41 +02:00
committed by GitHub
parent edceb1cb1f
commit 1ef1d23342
103 changed files with 384 additions and 156 deletions
+28
View File
@@ -0,0 +1,28 @@
name: Compare file templates with file names
on:
push:
pull_request:
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#concurrency
# Ensure that only one commit will be running tests at a time on each PR
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
template-check:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Compare file templates with file names
run: python scripts/lv_templ_check.py --fix
- name: Check that repository is clean
run: git diff --exit-code >/dev/null 2>&1 || (echo "Please fix template issues using scripts/lv_templ_check.py"; false)
+10
View File
@@ -32,6 +32,16 @@ repos:
tests/test_images
)
types_or: ["c", "header"]
# If a file seems to match lv_templ.c/lv_templ.h, ensure that the parts
# that depend on the file name are correct.
- id: template-check
name: Comparing file templates with file names
entry: python scripts/lv_templ_check.py --fix --quiet
stages: [ commit ]
language: system
pass_filenames: false
verbose: true
types_or: ["c", "header"]
- repo: https://github.com/crate-ci/typos
rev: v1.16.20
hooks:
+1 -1
View File
@@ -76,4 +76,4 @@ void lv_demos_show_help(void);
} /* extern "C" */
#endif
#endif /*LV_DEMO_H*/
#endif /*LV_DEMOS_H*/
+5 -5
View File
@@ -1,13 +1,13 @@
/**
* @file lv_conf.h
* @file lv_conf_cmsis.h
* Configuration file for v9.3.0
*/
/* clang-format off */
#if 1 /* Set this to "1" to enable content */
#ifndef LV_CONF_H
#define LV_CONF_H
#ifndef LV_CONF_CMSIS_H
#define LV_CONF_CMSIS_H
#if defined(_RTE_)
#include "RTE_Components.h"
@@ -1243,7 +1243,7 @@
#define LV_DEMO_MUSIC_LARGE 0
#define LV_DEMO_MUSIC_AUTO_PLAY 0
#endif
#if LV_USE_DEMO_BENCHMARK
/** Use fonts where bitmaps are aligned 16 byte and has Nx16 byte stride */
#define LV_DEMO_BENCHMARK_ALIGNED_FONTS 0
@@ -1257,6 +1257,6 @@
/*--END OF LV_CONF_H--*/
#endif /*LV_CONF_H*/
#endif /*LV_CONF_CMSIS_H*/
#endif /*End of "Content enable"*/
@@ -3,8 +3,8 @@
*
*/
#ifndef LV_EX_GET_STARTED_H
#define LV_EX_GET_STARTED_H
#ifndef LV_EXAMPLE_GET_STARTED_H
#define LV_EXAMPLE_GET_STARTED_H
#ifdef __cplusplus
extern "C" {
@@ -38,4 +38,4 @@ void lv_example_get_started_4(void);
} /*extern "C"*/
#endif
#endif /*LV_EX_GET_STARTED_H*/
#endif /*LV_EXAMPLE_GET_STARTED_H*/
+3 -3
View File
@@ -3,8 +3,8 @@
*
*/
#ifndef LV_EXAMPLE_PNG_H
#define LV_EXAMPLE_PNG_H
#ifndef LV_EXAMPLE_LODEPNG_H
#define LV_EXAMPLE_LODEPNG_H
#ifdef __cplusplus
extern "C" {
@@ -35,4 +35,4 @@ void lv_example_lodepng_1(void);
} /*extern "C"*/
#endif
#endif /*LV_EXAMPLE_PNG_H*/
#endif /*LV_EXAMPLE_LODEPNG_H*/
@@ -3,8 +3,8 @@
*
*/
#ifndef LV_EX_FILE_EXPLORER_H
#define LV_EX_FILE_EXPLORER_H
#ifndef LV_EXAMPLE_FILE_EXPLORER_H
#define LV_EXAMPLE_FILE_EXPLORER_H
#ifdef __cplusplus
extern "C" {
@@ -37,4 +37,4 @@ void lv_example_file_explorer_3(void);
} /*extern "C"*/
#endif
#endif /*LV_EX_FILE_EXPLORER_H*/
#endif /*LV_EXAMPLE_FILE_EXPLORER_H*/
@@ -37,4 +37,4 @@ void lv_example_font_manager_3(void);
} /*extern "C"*/
#endif
#endif /*LV_EXAMPLE_MONKEY_H*/
#endif /*LV_EXAMPLE_FONT_MANAGER_H*/
@@ -34,4 +34,4 @@ void lv_example_fragment_2(void);
} /*extern "C"*/
#endif
#endif /*LV_EXAMPLE_fragment_H*/
#endif /*LV_EXAMPLE_FRAGMENT_H*/
+3 -3
View File
@@ -3,8 +3,8 @@
*
*/
#ifndef LV_EX_IME_PINYIN_H
#define LV_EX_IME_PINYIN_H
#ifndef LV_EXAMPLE_IME_PINYIN_H
#define LV_EXAMPLE_IME_PINYIN_H
#ifdef __cplusplus
extern "C" {
@@ -36,4 +36,4 @@ void lv_example_ime_pinyin_2(void);
} /*extern "C"*/
#endif
#endif /*LV_EX_IME_PINYIN_H*/
#endif /*LV_EXAMPLE_IME_PINYIN_H*/
@@ -3,8 +3,8 @@
*
*/
#ifndef LV_EX_SNAPSHOT_H
#define LV_EX_SNAPSHOT_H
#ifndef LV_EXAMPLE_SNAPSHOT_H
#define LV_EXAMPLE_SNAPSHOT_H
#ifdef __cplusplus
extern "C" {
@@ -35,4 +35,4 @@ void lv_example_snapshot_1(void);
} /*extern "C"*/
#endif
#endif /*LV_EX_GET_STARTED_H*/
#endif /*LV_EXAMPLE_SNAPSHOT_H*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_port_disp_templ.c
* @file lv_port_disp_template.c
*
*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_port_fs_templ.c
* @file lv_port_fs_template.c
*
*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_port_indev_templ.c
* @file lv_port_indev_template.c
*
*/
+1 -1
View File
@@ -175,4 +175,4 @@ void lv_example_win_1(void);
} /*extern "C"*/
#endif
#endif /*LV_EX_WIDGETS_H*/
#endif /*LV_EXAMPLE_WIDGETS_H*/
+3 -3
View File
@@ -3,12 +3,12 @@
* The current version of LVGL
*/
#ifndef LVGL_VERSION_H
#define LVGL_VERSION_H
#ifndef LV_VERSION_H
#define LV_VERSION_H
#define LVGL_VERSION_MAJOR 9
#define LVGL_VERSION_MINOR 3
#define LVGL_VERSION_PATCH 0
#define LVGL_VERSION_INFO ""
#endif /* LVGL_VERSION_H */
#endif /* LV_VERSION_H */
+190
View File
@@ -0,0 +1,190 @@
import re
import argparse
import os
import traceback
ignored_file_prefixes = {
"lv_conf_template.h",
"lv_conf_cmsis.h",
"lv_test_perf_conf.h",
"lv_font_"
}
ignored_top_dirs = {
".git",
"docs"
}
h_filename_pattern = re.compile(r"lv_[\w.]*\.h")
h_pattern = re.compile(
r"\s*/\*\*.+?"
r"@file +(\S*).+?"
r"\*/\s+?#ifndef +(\w+_H)\s+#define +(\w+_H).+"
r"#endif */\* *([^*]+?) *\*/\s*",
flags=re.DOTALL
)
c_filename_pattern = re.compile(r"lv_[\w.]*\.c")
c_pattern = re.compile(
r"\s*/\*\*.+?"
r"@file +(\S*)",
flags=re.DOTALL
)
file_comment_help_f = """\
'{0}' should have at the top:
/**
* @file {1}
*
*/
instead, has:
/**
* @file {2}
*
*/
"""
guard_help_f = """\
'{0}' should have include guards like:
#ifndef {1}
#define {1}
...
#endif /*{1}*/
instead, has:
#ifndef {2}
#define {3}
...
#endif /*{4}*/
"""
# regex, arg parsing and other stuff skipped here.
def ignore_file(basename):
result = False
for pattern in ignored_file_prefixes:
if basename.startswith(pattern):
result = True
break
return result
def ignore_dir(path):
result = False
for top_dir in ignored_top_dirs:
sub_path = os.path.join('lvgl', top_dir)
if sub_path in path:
result = True
break
return result
def debug(*args_, **kwargs):
if args.verbose:
print(*args_, **kwargs)
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("--fix", action="store_true", help="fix incorrect files")
arg_parser.add_argument("-q", "--quiet", action="store_true", help="don't print mismatch info")
arg_parser.add_argument("-v", "--verbose", action="store_true", help="print debug info")
args = arg_parser.parse_args()
cfg_project_dir = '..'
base_dir = os.path.abspath(os.path.dirname(__file__))
project_dir = os.path.abspath(os.path.join(base_dir, cfg_project_dir))
debug(f'ignore dirs [{ignored_top_dirs}]')
ok = True
for root, dirs, basenames in os.walk(project_dir):
if ignore_dir(root):
continue
debug(f'root [{root}]')
for basename in basenames:
if ignore_file(basename):
continue
file_ok = True
a_file_was_processed = False
path = os.path.join(root, basename)
# -------------------------------------------------------------
# H File?
# -------------------------------------------------------------
if h_filename_pattern.fullmatch(basename):
a_file_was_processed = True
debug(f'Opening H file [{path}]')
try:
with open(path, 'rb') as f:
cont = f.read().decode('utf-8')
except:
print(f'Error attempting UTF-8 decode on [{path}].')
traceback.print_exc()
continue
m = h_pattern.fullmatch(cont)
if m is not None:
debug(' Match.')
if m[1] != basename:
file_ok = False
if not args.quiet:
print(file_comment_help_f.format(path, basename, m[1]))
guard_name = f"LV_{basename[3:-2].upper()}_H"
if any(m[i] != guard_name for i in range(2, 4+1)):
file_ok = False
if not args.quiet:
print(guard_help_f.format(path, guard_name, m[2], m[3], m[4]))
replacements = (basename, guard_name, guard_name, guard_name)
else:
debug(f' No match with regex [{h_pattern.pattern}].')
# -------------------------------------------------------------
# C File?
# -------------------------------------------------------------
elif c_filename_pattern.fullmatch(basename):
a_file_was_processed = True
debug(f'Opening C file [{path}]')
try:
with open(path, 'rb') as f:
cont = f.read().decode('utf-8')
except:
print(f'Error attempting UTF-8 decode on [{path}].')
traceback.print_exc()
continue
m = c_pattern.match(cont)
if m is not None:
debug(' Match.')
if m[1] != basename:
file_ok = False
if not args.quiet:
print(file_comment_help_f.format(path, basename, m[1]))
replacements = (basename, )
else:
debug(f' No match with regex [{c_pattern.pattern}].')
if a_file_was_processed:
if not file_ok:
debug(f'NOT OK [{path}]')
ok = False
if args.fix:
for i in reversed(range(0, len(replacements))):
span = m.regs[i + 1]
repl = replacements[i]
cont = cont[:span[0]] + repl + cont[span[1]:]
with open(path, "w") as f:
f.write(cont)
else:
debug(f'OK [{path}]')
if not ok:
exit(1)
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_obj_id.c
* @file lv_obj_id_builtin.c
*
*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_obj_id.c
* @file lv_obj_property.c
*
*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_disp.c
* @file lv_display.c
*
*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_draw_dma2d_image.c
* @file lv_draw_dma2d_img.c
*
*/
+2 -2
View File
@@ -1,5 +1,5 @@
/**
* @file lv_ppa_private.h
* @file lv_draw_ppa_private.h
*
*/
@@ -182,4 +182,4 @@ static inline ppa_srm_color_mode_t lv_color_format_to_ppa_srm(lv_color_format_t
} /*extern "C"*/
#endif
#endif /* LV_PPA_PRIVATE_H */
#endif /* LV_DRAW_PPA_PRIVATE_H */
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_draw_img.c
* @file lv_draw_image.c
*
*/
+1 -1
View File
@@ -25,7 +25,7 @@
*/
/**
* @file lv_draw_nema_gfx_fill.c
* @file lv_draw_nema_gfx_border.c
*
*/
+1 -1
View File
@@ -25,7 +25,7 @@
*/
/**
* @file lv_draw_nema_gfx_fill.c
* @file lv_draw_nema_gfx_img.c
*
*/
+1 -1
View File
@@ -25,7 +25,7 @@
*/
/**
* @file lv_draw_nema_gfx_fill.c
* @file lv_draw_nema_gfx_label.c
*
*/
+1 -1
View File
@@ -25,7 +25,7 @@
*/
/**
* @file lv_draw_nema_gfx_fill.c
* @file lv_draw_nema_gfx_layer.c
*
*/
+1 -1
View File
@@ -25,7 +25,7 @@
*/
/**
* @file lv_draw_nema_gfx_fill.c
* @file lv_draw_nema_gfx_line.c
*
*/
@@ -1,5 +1,5 @@
/**
* @file lv_draw_nema_gfx_hal.c
* @file lv_draw_nema_gfx_stm32_hal.c
*
* Global functions that implement some HAL functionality
* which Nema will call directly.
@@ -25,7 +25,7 @@
*/
/**
* @file lv_draw_nema_gfx_fill.c
* @file lv_draw_nema_gfx_triangle.c
*
*/
+1 -1
View File
@@ -25,7 +25,7 @@
*/
/**
* @file lv_draw_nema_gfx.h
* @file lv_draw_nema_gfx_utils.h
*
*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_draw_vglite_blend.c
* @file lv_draw_vglite_img.c
*
*/
+1 -1
View File
@@ -103,4 +103,4 @@ void lv_draw_dave2d_transform(lv_draw_task_t * t, const lv_area_t * dest_area, c
} /*extern "C"*/
#endif
#endif /*LV_USE_DRAW_DAVE2D*/
#endif /*LV_DRAW_DAVE2D_H*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_draw_sw_blend_al88.c
* @file lv_draw_sw_blend_to_al88.c
*
*/
@@ -1,5 +1,5 @@
/**
* @file lv_draw_sw_blend.c
* @file lv_draw_sw_blend_to_argb8888.c
*
*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_draw_sw_blend_l8.c
* @file lv_draw_sw_blend_to_l8.c
*
*/
@@ -42,4 +42,4 @@ void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_blend_image_to_rgb565_swapped(lv_dra
} /*extern "C"*/
#endif
#endif /*LV_DRAW_SW_BLEND_TO_RGB565_H*/
#endif /*LV_DRAW_SW_BLEND_TO_RGB565_SWAPPED_H*/
+1 -1
View File
@@ -144,4 +144,4 @@ void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_sw_grad_conical_get_line(lv_grad_dsc_t
} /*extern "C"*/
#endif
#endif /*LV_DRAW_GRADIENT_H*/
#endif /*LV_DRAW_SW_GRAD_H*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_draw_img.c
* @file lv_draw_sw_vector.c
*
*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_vg_lite_draw.c
* @file lv_draw_vg_lite.c
*
*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_draw_vg_lite_rect.c
* @file lv_draw_vg_lite_mask_rect.c
*
*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_vg_lite_math.h
* @file lv_vg_lite_math.c
*
*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file vg_lite_utils.c
* @file lv_vg_lite_utils.c
*
*/
+1 -1
View File
@@ -303,4 +303,4 @@ static inline void lv_vg_lite_blit_rect(vg_lite_buffer_t * target,
} /*extern "C"*/
#endif
#endif /*VG_LITE_UTILS_H*/
#endif /*LV_VG_LITE_UTILS_H*/
@@ -3,8 +3,8 @@
* Driver for NXP's ELCD
*/
#ifndef LV_NXP_ELCDIF_DRIVER_H
#define LV_NXP_ELCDIF_DRIVER_H
#ifndef LV_NXP_ELCDIF_H
#define LV_NXP_ELCDIF_H
#include "../../../lvgl.h"
#include "../../../display/lv_display.h"
@@ -81,4 +81,4 @@ void lv_nxp_display_elcdif_event_handler(const lv_display_t * disp);
#endif /*LV_USE_NXP_ELCDIF*/
#endif /* LV_NXP_ELCDIF_DRIVER_H */
#endif /* LV_NXP_ELCDIF_H */
+2 -2
View File
@@ -55,10 +55,10 @@ uint32_t lv_xkb_process_key(lv_xkb_t * dsc, uint32_t scancode, bool down);
* MACROS
**********************/
#endif /* LV_LIBINPUT_XKB */
#endif /* defined(LV_LIBINPUT_XKB) && LV_LIBINPUT_XKB */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* defined(LV_LIBINPUT_XKB) && LV_LIBINPUT_XKB */
#endif /* LV_XKB_H */
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_nuttx_entry.h
* @file lv_nuttx_entry.c
*
*/
+1 -1
View File
@@ -40,4 +40,4 @@ lv_indev_t * lv_sdl_mousewheel_create(void);
} /* extern "C" */
#endif
#endif /* LV_DEV_SDL_MOUSEWHEEL_H */
#endif /* LV_SDL_MOUSEWHEEL_H */
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_sdl_window.h
* @file lv_sdl_window.c
*
*/
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @file lv_uefi_indev.c
* @file lv_uefi_indev_keyboard.c
*
*/

Some files were not shown because too many files have changed in this diff Show More