Implicit deps resolution: add #embed and fix #include followed by a comment - #4889
Implicit deps resolution: add #embed and fix #include followed by a comment#4889vassilit wants to merge 1 commit into
Conversation
The C scanners recognised only #include and C++ #import, so a change to a resource named by #embed did not mark the embedding source out of date. Both scanners now track the resource. A quoted name is looked up relative to the including file, a bracketed name in $CPPPATH: - CScanner's regex captures the directive keyword, through a new private _ClassicCPPEmbed subclass which drops the keyword again when computing the sort key, so result ordering is unchanged. ClassicCPP itself keeps its documented three-group contract, which IDL, SWIG and RC rely on. - SCons/cpp.py, which backs the opt-in CConditionalScanner, gains the keyword in its directive table plus a do_embed handler, and honours #embed in the conditional-branch wiring of start_handling_includes and stop_handling_includes. The resource itself is deliberately not scanned: its contents are embedded as data (possibly binary) rather than preprocessed. Resolved resources are tagged on the node and filtered out by recurse_nodes(). Also fixes resolve_include() assuming the closing delimiter is the last character of the line, which turned `#embed "d.bin" limit(4)` into the filename `d.bin" limit(4`, and likewise mangled an #include carrying a trailing comment. Signed-off-by: Vassili Tchersky <vt+git@vbcy.org> Assisted-by: Claude Opus 5
|
Thanks for your attention. There are some issues already on missing support for features introduced in newer C++ standards (and C standards too, for that matter)... see for example #4517 and #4518. Aren't there feature test macros for |
Are you referring to __has_embed ? I use it as a feature test as well, like here. |
Yes. What happens if you use |
It fails, with |
Both a small bug-fix and a new feature.
Tested manually on rmlint:
Before this PR:
#include "header.h"in code.c, modify header.h, code.c get rebuilt.#include "header.h" /* useful header */in code.c, modify header.h, code.c do not get rebuilt.#embed "py.py"in code.c, modify py.py, code.c do not get rebuilt.After:
#include "header.h"in code.c, modify header.h, code.c get rebuilt.#include "header.h" /* useful header */in code.c, modify header.h, code.c do get rebuilt.#embed "py.py"in code.c, modify py.py, code.c do get rebuilt.Contributor Checklist:
CHANGES.txtandRELEASE.txt(and read theREADME.rst).