diff options
author | Ivan Kravets <me@ikravets.com> | 2018-03-08 12:28:51 (GMT) |
---|---|---|
committer | Ivan Kravets <me@ikravets.com> | 2018-03-08 12:28:51 (GMT) |
commit | 80e62ede63890d52fb7395c7588758bc07f8fba6 (patch) | |
tree | 1ad99301620de8990f0a0b400631d96b798066aa | |
parent | 080d987d57bb3d0fe5a6a5f879cdb8b35cd8c576 (diff) | |
download | SCons-80e62ede63890d52fb7395c7588758bc07f8fba6.zip SCons-80e62ede63890d52fb7395c7588758bc07f8fba6.tar.gz SCons-80e62ede63890d52fb7395c7588758bc07f8fba6.tar.bz2 |
Restore support for "all" option for Conditional PreProcessor
-rw-r--r-- | src/engine/SCons/Scanner/C.py | 5 | ||||
-rw-r--r-- | src/engine/SCons/cpp.py | 14 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py index db7463f..0d18879 100644 --- a/src/engine/SCons/Scanner/C.py +++ b/src/engine/SCons/Scanner/C.py @@ -96,10 +96,11 @@ class SConsCPPScannerWrapper(object): def __init__(self, name, variable): self.name = name self.path = SCons.Scanner.FindPathDirs(variable) - def __call__(self, node, env, path = ()): + def __call__(self, node, env, path = (), all=False): cpp = SConsCPPScanner(current = node.get_dir(), cpppath = path, - dict = dictify_CPPDEFINES(env)) + dict = dictify_CPPDEFINES(env), + all = all) result = cpp(node) for included, includer in cpp.missing: fmt = "No dependency generated for file: %s (included from: %s) -- file not found" diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py index 72018c5..22b7a7b 100644 --- a/src/engine/SCons/cpp.py +++ b/src/engine/SCons/cpp.py @@ -245,7 +245,7 @@ class PreProcessor(object): """ 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=False): global Table cpppath = tuple(cpppath) @@ -263,8 +263,8 @@ class PreProcessor(object): self.cpp_namespace = dict.copy() self.cpp_namespace['__dict__'] = self.cpp_namespace - if all: - self.do_include = self.all_include + # IF all=True, return all found includes without nested parsing + self.all = all # For efficiency, a dispatch table maps each C preprocessor # directive (#if, #define, etc.) to the method that should be @@ -563,6 +563,10 @@ class PreProcessor(object): return self.result.append(include_file) # print include_file, len(self.tuples) + + if self.all: + return + new_tuples = [('scons_current_file', include_file)] + \ self.tupleize(self.read_file(include_file)) + \ [('scons_current_file', self.current_file)] @@ -619,10 +623,6 @@ class PreProcessor(object): return None return (t[0], s[0], s[1:-1]) - def all_include(self, t): - """ - """ - self.result.append(self.resolve_include(t)) class DumbPreProcessor(PreProcessor): """A preprocessor that ignores all #if/#elif/#else/#endif directives |