diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2008-11-06 20:54:06 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2008-11-06 20:54:06 +0000 |
commit | b806d7a25a444cd098b50960def66c8ea68c54e4 (patch) | |
tree | 39e9a3dafaee3cbd71cc88622fad7cbaee45cf82 | |
parent | 96b936882601287ed63daf4cfabfff96e1046a59 (diff) | |
download | deheader-b806d7a25a444cd098b50960def66c8ea68c54e4.tar.gz deheader-b806d7a25a444cd098b50960def66c8ea68c54e4.tar.bz2 deheader-b806d7a25a444cd098b50960def66c8ea68c54e4.tar.xz deheader-b806d7a25a444cd098b50960def66c8ea68c54e4.zip |
Complain more loudly if the base fiile won't build.
-rwxr-xr-x | deheader | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -46,24 +46,24 @@ def extract_includes(sourcefile, ignores): includes.append(line) return includes -def compile(source, msg=""): +def compile(source, msg="", verbosity=0): (stem, suffix) = os.path.splitext(source) derived = stem + ".o" if os.path.exists(derived): os.remove(derived) command = "make " + derived - if verbose < 2: + if verbosity < 2: command += " >/dev/null 2>&1" start = time.time() status = os.system(command) end = time.time() if status: explain = "failed" - if verbose >= 2: + if verbosity >= 2: explain += " (%d)" % status else: explain = "succeeded" - if verbose: + if verbosity: print "deheader: %s%s %s in %2.2f sec." \ % (sourcefile, msg, explain, end-start) return (status, end - start) @@ -85,7 +85,7 @@ def c_analyze(source, includes): if line != header: ofp.write(line) ofp.close() - (st, t) = compile(sourcefile, " without %s" % trim(header)) + (st, t) = compile(sourcefile, " without %s" % trim(header), verbose) if st == 0: unneeded.append(header) includes.remove(header) @@ -116,9 +116,12 @@ if __name__ == "__main__": verbose += 1 for sourcefile in arguments: - (st, t) = compile(sourcefile) + # Sanity check against broken sourcefiles; we want this to + # complain visibly if the sourcefile won't build at all. + (st, t) = compile(sourcefile, min(1, verbose)) if st != 0: continue + # Now do the analysis includes = extract_includes(sourcefile, ignores) if sourcefile.endswith(".c") or sourcefile.endswith(".cpp"): unneeded = c_analyze(sourcefile, includes) |