"Basic" C Scanner (default, the same behavior as before). Takes into
account the type of bracketing used to include the file, and uses
classic CPP rules for searching for the files based on the bracketing.
"Advanced". Interprets C/C++ Preprocessor conditional syntax (
#ifdef, #if, #else, #elif, #define, etc.). Compatible with
Scons.Node.Node::get_implicit_deps and recursive behavior.
Improvements for SCons C/C++ Pre-Processor:
Handle UNSIGNED LONG and LONG numeric constants in DEC (keep support for HEX)
Thanks, will write tests later. I've been working on this PR since first commit. The code is obsolate according to new SCons.Node API. I see that last time when it was used is 2008 year :)
I carefully retested under dozens different projects with multiple conditional syntax. Here is good project that uses PlatformIO as build system for embedded. They have different examples that depend on external libraries.
PlatformIO builds Dependency Graph on-the-fly and tries to find all dependencies automatically. For example, https://travis-ci.org/platformio/platform-nordicnrf51/jobs/179539573#L281
I use Basic C Scanner in the last stable release. However, there are a few complaints that PlatformIO handles dependencies that are hidden under C macro. That is why I've decided to reanimate this SCons Python-based C Pre Processor. I like this idea and would be glad if I can contribute to this amazing SCons project.
P.S: I can't imagine PlatformIO without SCons. SCons is a heart of PlatformIO Build System. We have high-level API over SCons and allow developers to write own development platforms. For example, development platform for Espressif 8266.
P.S.S: I'm new contributor to SCons Project, please correct me if I do some wrong. Thanks!
In any case, this PR doesn't affect previous SCons releases/projects. I kept default behavior of def CScanner(advanced=False). It means that it should not break existing projects. I use 2 scanners in combination:
Boolean-only arguments tend to muddy APIs, and calling this "advanced" will seem antiquated if-and-when a v3 of this scanner is created. What about creating this as a new class, perhaps CConditionalScanner, CMacroScanner, or CIfdefScanner?
We definitely need some tests here.
Ideally the tests would fail with the current cscanner, and pass with the new.
This will ensure than no changes going forward break the new scanner and also it would serve to highlight the improvements over the old scanner.
SCons does have a formal deprecation cycle. I'd like to stick with that for these kind of changes as well: