CI: check the single translation unit sources - #366
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
.github/scripts/check_inl_sources.pyand aSourceCheckworkflow that runs it on push and pull request.src/M5Unified.cpppointing at the script.Why
With the library compiled as a single translation unit, a new
*.inlthat 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
*.inlundersrcis reachable from the hub, directly or through another*.inl(BMI270_Class.inlincludesBMI270_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.*.inlstarts with#ifndef M5UNIFIED_IMPLEMENTATION/#error/#endif, so it cannot be included on its own by user code.*.c/*.cppother than the hub exists undersrc.The script can also compile each
*.inlon 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,#ifconditions are not evaluated.Running it locally
Verification
*.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).