diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-12-09 13:22:35 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-12-09 13:22:35 -0500 |
commit | 9b2713b52510743a4a277055c418d29fed5d8ca1 (patch) | |
tree | f0ddc72d6a228e3cefb1dfb8181ffa8691c98815 | |
parent | e59590bbfaff0fc973236eb5f069bc1e157106a5 (diff) | |
download | deheader-9b2713b52510743a4a277055c418d29fed5d8ca1.tar.gz deheader-9b2713b52510743a4a277055c418d29fed5d8ca1.tar.bz2 deheader-9b2713b52510743a4a277055c418d29fed5d8ca1.tar.xz deheader-9b2713b52510743a4a277055c418d29fed5d8ca1.zip |
Logic for requirement rules is working.
-rwxr-xr-x | deheader | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -35,13 +35,13 @@ COMMAND_DEBUG = 3 version = "0.2" # Difference in various compiler implementations and OSes mean that for cross- -# platform compatibility you sometimes wabt to leave "unneeded" headers alone +# platform compatibility you sometimes want to leave "unneeded" headers alone # because they're required in order to satify dependencies on other platforms. # We list those here. Home port is Linux; these are mostly extracted from # observing compiles on BSD systems. requirements = map(lambda (r, h): (re.compile(r), h), ( - (r"umask\s*\(", ["<sys/stat.h>", "<sys/types.h>"]), - (r"<sys/socket.h>", ["<sys/stat.h>"]), + (r"umask", "<sys/stat.h>|<sys/types.h>"), + (r"<sys/socket.h>", "<sys/stat.h>|<sys/types.h>"), )) class Baton: @@ -123,11 +123,13 @@ class InclusionMap: includes.append(line) elif verbose > 1: print "deheader: ignoring %s (conditional inclusion)" % name - for (r, h) in requirements: - if r.search(line): - requires += line + for (r, h) in requirements: + if r.search(line): + if verbosity >= PROGRESS_DEBUG: + print "%s has requires %s from %s" % (sourcefile, h, r.pattern) + requires.append(h) self.depends_on[sourcefile] = includes - self.requires[sourcefile] = requires + self.requires[sourcefile] = re.compile("|".join(requires)) def forget(self, sourcefile, header): "Forget a header dependency." self.depends_on[sourcefile].remove(header) @@ -208,7 +210,11 @@ def c_analyze(sourcefile, maker, includes, requires, verbosity): for header in includes: if verbosity == BATON_DEBUG: baton.twirl() - if header in requires: + #if requires.pattern: + # print "%s: checking %s against %s" % (sourcefile, `header`, `requires.pattern`) + if requires.pattern and requires.search(header): + if verbosity >= PROGRESS_DEBUG: + print "deheader: in %s, retaining required %s" % (souucefile, `header`,) continue saveit.remove_headers([header]) (st, t) = testcompile(sourcefile, maker, " without %s" % trim(header), verbosity) @@ -232,13 +238,13 @@ def deheader(sourcefile, maker, includes, requires, remove, verbose): # Now do the analysis if sourcefile.endswith(".c") or sourcefile.endswith(".cpp"): unneeded = c_analyze(sourcefile, maker, - includes[:], requires[:], verbose) + includes[:], requires, verbose) if unneeded: for line in unneeded: print "deheader: remove %s from %s" % (trim(line), sourcefile) if remove: remove_it = SaveForModification(sourcefile) - remove_it.remove_headers(unneeded, requires) + remove_it.remove_headers(unneeded) remove_it.forget() del remove_it return Summary([sourcefile], includes, unneeded) |