Use C compiler to help scan for header dependencies
This issue was originally created at: 2010-04-01 16:36:16.
This issue was reported by: witkamp.
witkamp said at 2010-04-01 16:36:16
The current scanner implementation uses some partial macro expansion. This is not good enough especially when using the C preproccessor for configuration.
For example:
#define HEADER "foo.h"
#include HEADER
The current scanner does not detect "foo.h" as a dependency, and you can imagine more sophisticated macros will not work as well.
This is not that big of a problem until someone tried to build variants. Because the scanner does not find the dependency, it is not copied to the variant_dir and the build fails.
Suggested Solution:
Why not run the compiler in preprocessor only mode and scan that output? This guarantees scons will generate correct dependencies.
gregnoel said at 2010-04-30 17:08:38
Bug party triage. The experimental C/C++ scanner will do this, but its use is undocumented. Steven to document how to use it.
The ParseDepends function caters for this exact use case. I suggest closing this as "fixed".
ParseDepends above is a work around.
Pull request #3053 implements a fuller scanner which should handle the above fully.
Updating the set of related issues. Yes, the CConditionalScanner handles the specific case stated here.
Since not every compilation system would behave the same way trying to use "the preprocessor" to detect header dependencies, it would be hard to do what this issue requests in a portable way. Recommend rejecting (wontfix) this one.
Updating the set of related issues. Yes, the
CConditionalScannerhandles the specific case stated here.Since not every compilation system would behave the same way trying to use "the preprocessor" to detect header dependencies, it would be hard to do what this issue requests in a portable way. Recommend rejecting (wontfix) this one.
Which C compilers wouldn't handle this?
I have no idea how you invoke msvc to spit out header dependencies, I'm not saying it can't.
I have no idea how you invoke msvc to spit out header dependencies, I'm not saying it can't.
/showIncludes but it goes to stdout while running the compiler.
Ah, ok. I see a new option, /sourceDependencies, which is much more sophisticated and writes a json file (which must be given as the option-argument). That was introduced, according to an MS blog post, with VS 2019 version 16.7.