summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-06-12 15:45:30 +0300
committerAndrei Karas <akaras@inbox.ru>2016-06-12 15:45:30 +0300
commitdddfd2606598ac8314dd180bd3ae3f413f4bc169 (patch)
treefb2cc5ce245f096f809599a9a80df4a8e36682e6
parent8b7e074fed4ae0a8d2b3ac31c2db83273c88f719 (diff)
downloaddeheader-dddfd2606598ac8314dd180bd3ae3f413f4bc169.tar.gz
deheader-dddfd2606598ac8314dd180bd3ae3f413f4bc169.tar.bz2
deheader-dddfd2606598ac8314dd180bd3ae3f413f4bc169.tar.xz
deheader-dddfd2606598ac8314dd180bd3ae3f413f4bc169.zip
Compile files for check is preprocessor block enabled or not.
-rwxr-xr-xdeheader20
1 files changed, 13 insertions, 7 deletions
diff --git a/deheader b/deheader
index 35e0ffb..e77dcae 100755
--- a/deheader
+++ b/deheader
@@ -1234,7 +1234,7 @@ class InclusionMap:
def c_source(filename):
"Predicate: return true if the filename appears to be C or C++ source."
return filename.endswith(".c") or filename.endswith(".cpp") or filename.endswith(".cc") or filename.endswith(".h")
- def __init__(self, roots, ignore, excludes, verbosity):
+ def __init__(self, roots, ignore, excludes, verbosity, compiler, defines, maker, showerrs=False, subdir=""):
"Build the initial inclusion map."
self.verbosity = verbosity
self.files = []
@@ -1282,7 +1282,7 @@ class InclusionMap:
cnt = cnt + 1
c = match_preproc(["ifndef", "ifdef", "if"], line)
if c is not False:
- allow_parse_includes = self.check_block(sourcefile, cnt)
+ allow_parse_includes = self.check_block(sourcefile, cnt, compiler, defines, maker, verbosity, showerrs, subdir)
conditions.append((c, allow_parse_includes))
elif match_preproc("else", line) is not False:
allow_parse_includes = not allow_parse_includes
@@ -1327,19 +1327,24 @@ class InclusionMap:
def remember(self, sourcefile, header):
"Undo forgetting of a dependency."
self.depends_on[sourcefile].append(header)
- def check_block(self, sourcefile, cnt):
+ def check_block(self, sourcefile, cnt, compiler, defines, maker, verbosity, showerrs, subdir):
+ tempName = sourcefile + ".cpp"
try:
with open(sourcefile, "r") as r:
- with open(sourcefile + ".tmp", "wt") as w:
+ with open(tempName, "wt") as w:
cnt2 = 0
for line in r:
w.write(line)
if cnt2 == cnt:
w.write("#error deheader\n")
cnt2 = cnt2 + 1
- # here need try compile this file
+ (st, _t) = testcompile(tempName, compiler, defines, maker, "make {0}".format(cnt), verbosity, showerrs=False, subdir=subdir)
+ if st == 0:
+ return False
+ return True
+ #print("st {0} for cnt {1}".format(st, cnt))
finally:
- os.remove(sourcefile + ".tmp")
+ os.remove(tempName)
return False
class SaveForModification:
@@ -1547,7 +1552,8 @@ if __name__ == "__main__":
if not arguments:
arguments = ["."]
- inclusion_map = InclusionMap(arguments, ignore, exclusions, verbose)
+ inclusion_map = InclusionMap(arguments, ignore, exclusions, verbose,
+ compiler, defines, maker, showerrs=False)
summaries = []
for sourcefile in sorted(inclusion_map.depends_on.keys()):
summaries.append(deheader(sourcefile, compiler, defines, maker,