Repository navigation
New conditional C Scanner; Improvements for virtual C Pre-Processor - #3053
Conversation
|
Thanks for migrating this pull request over to Github. |
* master: (270 commits) Update and add show option to cache config attempt fixing tests failing due to binary mode use absolute python path in sheabangs remove unnecessary sheabangs from scripts generated by end-to-end tests Correct sheabangs in code snippets under test/ Update CHANGES.txt Fix GH Issue SCons#3225 Flatten() doesn't handle dictionary views produces by py3 dict().{items(), values(), keys()} Add testcase to demonstrate specifying dict.values() on py3 fails. as it returns a dict_values object and not a list PEP8 Update CHANGES.txt Fix logic which populates JAVAINCLUDES when javac is not found. Restore checks in some java tests to skip test if no javac and/or jar found Additional fixes for SWIG tests Add blurb on Java fixes to CHANGES.txt Updated docs post updating Java tool xml file Add JAVAINCLUDES information Reordered and revised some text. Also added note about adding new info in order of contributors last name. Allow to override build date with SOURCE_DATE_EPOCH Get a little smarter about finding the scons engine. fix Value node tests to expect a string and not bytes remove editor junk ...
…ional-scanner * 'master' of https://github.com/SCons/scons: (71 commits) Add Textfile/Substfile to default. add logic to remove bad xsltproc from appveyor ci machines if it's present. This is just to fix bogus failures for docbook/basic/*/*_cmd.py Remove delete of file. It's causing appveyor to die even though the command shouldn't issue an error code if xsltproc.exe is not there Modify changes.txt since this is a py3.5+ only issue. Fix cpp scanner regex logic to treat ifndef. Previously it was not properly differentiating between if, ifdef, and ifndef refine get_env_bool() docstrings Explicitly remove xsltproc.exe from git install. Somehow it's still there after update git install s/get_bool_envvar/get_os_env_bool/ Fix duplicated items in src/CHANGES.txt Change test for str(node1) is str(node2) to use ==. Expecting that the strings would have the same id() is not reasonable. Expecting their values are equal is. Resolve comments from @garyo to clarify new code. Clarify and simplify logic in Node.get_binfo() Fix typos Fix docstring on FileBuildInfo per comment from @dirkbaechle Add test with MD5-timestamp decider and Repository usage fix whitespace issues cleanup travis.xml file add note about saxon-xslt version 5.5 needing xsl and source file argument order swapped switch from izip to zip. no izip in py3 Revisit caching of filename -> csig map and invalidate when reasonable ...
There was a problem hiding this comment.
Looks like you dropped this in the merge..
|
I'd suggest adding an env variable like CC_SCANNER which defaults to current scanner, but can be assigned to your new one. That way we're not changing default behavior. For docs you'd just had to add info on that new variable and the possible values. Also add a wiki page? Tests would reset the CC_SCANNER to this more complete one and then run same tests as the current c scanner. |
…ional-scanner # Conflicts: # src/engine/SCons/cpp.py
|
I'd love to merge this in as an optional scanner. If you can change this to be a second optional C/C++ scanner. Then I can merge it. |
|
Thanks!
|
|
@ivankravets - no, by depth I mean how that changing the C/C++ scanner is a nontrivial change. So if I merge this it will or will not modify the existing C/C++ scanner? |
|
I didn't touch original CScanner. You can compare 2 files:
If someone would like to use a new scanner, he needs |
| keyword, quote, fname = t | ||
| result = SCons.Node.FS.find_file(fname, self.searchpath[quote]) | ||
| if not result: | ||
| paths = tuple(self._known_paths) + self.searchpath[quote] |
There was a problem hiding this comment.
you do have modifications to current C scanner here right?
|
I've just isolated CConditionalScanner from an original scanner. Indeed, there is a bug in I don't know if it is good if SConsCPPScanner will return the correct found items. Do you mean that it can break existing projects? |
|
I'd rather you break that out into a separate pull request. |
|
I already separated, see scons/src/engine/SCons/Scanner/C.py Line 128 in fe2680d |
|
You have both changes in this PR right? I'm asking if you can split them into a separate PR for the new scanner and one for the fix to the existing. |
|
No, I reverted back all my changes to the original scanner and duplicated it with modifications for the conditional preprocessor. |
| [r'//.*', ''], | ||
| [r'(0x[0-9A-Fa-f]*)[UL]+', '\\1'], | ||
| [r'defined\s+(\w+)', '"\\1" in __dict__'], | ||
| [r'defined\s*\((\w+)\)', '"\\1" in __dict__'], |
| The main workhorse class for handling C pre-processing. | ||
| """ | ||
| def __init__(self, current=os.curdir, cpppath=(), dict={}, all=0): | ||
| def __init__(self, current=os.curdir, cpppath=(), dict={}, all=0, depth=-1): |
| # Max depth of nested includes: | ||
| # -1 = unlimited | ||
| # 0 - disabled nesting | ||
| # >0 - number of allowed nested includes |
|
Can you hop on discord #devel channel? |
Extracted from PR SCons#3053 (Ivan Kravets) to make an isolated submission: * Handle UNSIGNED LONG and LONG numeric constants in DEC (keep support for HEX) * Skip unrecognized directives, such as `#if( defined ...)` * Ignore `#include DYNAMIC_INCLUDE` directive that depends on a dynamic macro which is not located in a state TABLE. * Cleanup CPP expressions before evaluating (strip comments, carriage returns) Signed-off-by: Mats Wichmann <[email protected]>
|
Sorry for my confusion on this PR. |
|
@bdbaddog Thanks for the merge!!! I'm so proud of this contribution!
Sorry, it looks like I missed this comment :(((( |
|
Just a little curious...
Do these changes affect that decision in any way? |
|
This commit should not affest |
|
No, I didn't mean you broke it; it's been this way (intentionally skipped) for a while. I wondered if enough scanning is available now that it could maybe be enabled for this scanner? |
|
Yes, it makes sense. There are some examples in src/engine/SCons/cppTests.py We have been using it for ~4 years in production. Maybe our use case will help someone https://github.com/platformio/platformio-core/blob/develop/platformio/builder/tools/piolib.py#L97 In @platformio we thing called "Library Dependency Finder. So, thanks to the SCons and this Conditional Scanner, we actually automatically resolve all dependencies based on |

Hi all!
I've finally found a time to make a PR with conditional C Scanner which we use 2 years in production for @platformio. This PR is continue of a work on https://bitbucket.org/scons/scons/pull-requests/380/improvements-for-scons-c-c-pre-processor/diff
I made it maximum compatible with existing API, I even didn't touch original tests. The only incoming data for tests were extended to show that new changes don't break previous behaviour and provide a new conditional C Scanner.
Documentation? This is very complex question for me. I didn't check this item in a list below because I don't know where these changes should be reflected in documentation.
A default classic C Scanner is hardcoded here. Should we make additional option for SCons command which will allow to switch between Scanners?
Nevertheless, new conditional Scanner is a good addition for developers who create an own high level wrapper around SCons. We do this in PlatformIO and use
CConditionalScannerto build a library dependency tree before calling SCons builder.I'm ready for any corrections and any comments are welcome.
Changes
SCons.Scanner.C.CConditionalScanner())which interprets C/C Preprocessor conditional syntax (#ifdef, #if, #else,
#elif, #define, etc.)
#if( defined ...)#include DYNAMIC_INCLUDEdirective that depends on a dynamicmacro which is not located in a state TABLE.
Contributor Checklist:
master/src/CHANGES.txtdirectory (and read theREADME.txtin that directory)