diff options
author | Simon Warta <[email protected]> | 2017-10-19 10:36:15 +0200 |
---|---|---|
committer | Simon Warta <[email protected]> | 2017-10-19 10:45:57 +0200 |
commit | 0bd88aee775cd65cd13e7d2936c36e393235a955 (patch) | |
tree | b167f54d2fe4bf2478e414cf217e446c409a26b5 | |
parent | 4a5b134633a94f11a83afa7feeded90392315790 (diff) |
Only skip includes that have been incuded unconditionally before
-rwxr-xr-x | configure.py | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/configure.py b/configure.py index 5bebd78d1..88a21a6c7 100755 --- a/configure.py +++ b/configure.py @@ -2446,6 +2446,7 @@ class AmalgamationHelper(object): # Only matches at the beginning of the line. By convention, this means that the include # is not wrapped by condition macros + _unconditional_any_include = re.compile(r'^#include <(.*)>') _unconditional_std_include = re.compile(r'^#include <([^/\.]+|stddef.h)>') @staticmethod @@ -2465,6 +2466,14 @@ class AmalgamationHelper(object): return None @staticmethod + def is_unconditional_any_include(cpp_source_line): + match = AmalgamationHelper._unconditional_any_include.search(cpp_source_line) + if match: + return match.group(1) + else: + return None + + @staticmethod def is_unconditional_std_include(cpp_source_line): match = AmalgamationHelper._unconditional_std_include.search(cpp_source_line) if match: @@ -2673,9 +2682,9 @@ class AmalgamationGenerator(object): f.write('#endif\n') # target to include header map - headers_written = {} + unconditional_headers_written = {} for target, _ in amalgamation_sources.items(): - headers_written[target] = included_in_headers.copy() + unconditional_headers_written[target] = included_in_headers.copy() for mod in sorted(self._modules, key=lambda module: module.basename): tgt = self._target_for_module(mod) @@ -2683,17 +2692,17 @@ class AmalgamationGenerator(object): with open(src, 'r', **encoding_kwords) as f: for line in f: if AmalgamationHelper.is_botan_include(line): + # Botan headers are inlined in amalgamation headers continue - header = AmalgamationHelper.is_any_include(line) - if header: - if header in headers_written[tgt]: - continue + if AmalgamationHelper.is_any_include(line) in unconditional_headers_written[tgt]: + # This include (conditional or unconditional) was unconditionally added before + continue - amalgamation_files[tgt].write(line) - headers_written[tgt].add(header) - else: - amalgamation_files[tgt].write(line) + amalgamation_files[tgt].write(line) + unconditional_header = AmalgamationHelper.is_unconditional_any_include(line) + if unconditional_header: + unconditional_headers_written[tgt].add(unconditional_header) for f in amalgamation_files.values(): f.close() |