Skip to content

CI: check the single translation unit sources - #366

Merged
lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:source_check
Sep 15, 2026
Merged

lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:source_check

Conversation

@ainyan03

Copy link
Copy Markdown
Contributor

What

  • Adds .github/scripts/check_inl_sources.py and a SourceCheck workflow that runs it on push and pull request.
  • Adds one line to the maintenance notes at the top of src/M5Unified.cpp pointing at the script.

Why

With the library compiled as a single translation unit, a new *.inl that is never added to the hub silently never gets compiled. The script turns that, and the related bookkeeping mistakes, into CI failures.

What the script checks

  1. Every *.inl under src is reachable from the hub, directly or through another *.inl (BMI270_Class.inl includes BMI270_config.inl). Includes must use the quoted form, name an existing file inside the tree, not repeat within a file, and not form a cycle.
  2. Every *.inl starts with #ifndef M5UNIFIED_IMPLEMENTATION / #error / #endif, so it cannot be included on its own by user code.
  3. No *.c / *.cpp other than the hub exists under src.

The script can also compile each *.inl on its own (--compile); that is not used here because the sources need the target framework headers. The scan is lexical: comments, string literals and line splices are handled as the preprocessor does, #if conditions are not evaluated.

Running it locally

python3 .github/scripts/check_inl_sources.py --hub src/M5Unified.cpp --root src --macro M5UNIFIED_IMPLEMENTATION

Verification

  • SourceCheck, Arduino Build and ESP-IDF Build pass on a fork with this branch.
  • Fault injection in a scratch copy: an orphaned *.inl, a missing guard or #endif, a stray *.cpp, a dangling or duplicated include, an angle-bracket include and directive-looking text inside comments and strings are each reported (or correctly ignored).

Add .github/scripts/check_inl_sources.py and a SourceCheck workflow that
runs it. The library is compiled through src/M5Unified.cpp, and the
script checks that this stays consistent:

- every *.inl under src is reachable from the hub, directly or through
  another *.inl, with quoted includes only, no missing or duplicated
  files, no cycles, and nothing outside the tree
- every *.inl starts with the M5UNIFIED_IMPLEMENTATION guard
- no stray *.c / *.cpp exists under src

The check is lexical: comments, string literals and line splices are
handled as the preprocessor does; #if conditions are not evaluated. The
standalone compile check the script offers is not run here because the
sources need the target framework headers.
@lovyan03
lovyan03 merged commit a528502 into m5stack:develop Sep 15, 2026
28 checks passed
@ainyan03
ainyan03 deleted the source_check branch September 15, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants