From: stevenknight Date: Tue, 1 Mar 2005 13:27:51 +0000 (+0000) Subject: Group --debug=count output by object modules. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cef01552083d49970d8382e12cb2657eac92e8c6;p=scons.git Group --debug=count output by object modules. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1238 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/bin/objcounts.py b/bin/objcounts.py index 7aa293b7..1b72837a 100644 --- a/bin/objcounts.py +++ b/bin/objcounts.py @@ -51,7 +51,19 @@ for k in c1.keys(): try: common[k] = (c1[k], c2[k]) except KeyError: - pass + # Transition: we added the module to the names of a bunch of + # the logged objects. Assume that c1 might be from an older log + # without the modules in the names, and look for an equivalent + # in c2. + if not '.' in k: + s = '.'+k + l = len(s) + for k2 in c2.keys(): + if k2[-l:] == s: + common[k2] = (c1[k], c2[k2]) + del c1[k] + del c2[k2] + break else: del c1[k] del c2[k] diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index fa8f1d25..077ddfb6 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -343,7 +343,7 @@ class CommandAction(_ActionAction): # factory above does). cmd will be passed to # Environment.subst_list() for substituting environment # variables. - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Action.CommandAction') apply(_ActionAction.__init__, (self,)+args, kw) if SCons.Util.is_List(cmd): if filter(SCons.Util.is_List, cmd): @@ -441,7 +441,7 @@ class CommandAction(_ActionAction): class CommandGeneratorAction(ActionBase): """Class for command-generator actions.""" def __init__(self, generator, *args, **kw): - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Action.CommandGeneratorAction') self.generator = generator self.gen_kw = kw @@ -506,7 +506,7 @@ class LazyAction(CommandGeneratorAction, CommandAction): __metaclass__ = SCons.Memoize.Memoized_Metaclass def __init__(self, var, *args, **kw): - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Action.LazyAction') apply(CommandAction.__init__, (self, '$'+var)+args, kw) self.var = SCons.Util.to_String(var) self.gen_kw = kw @@ -550,7 +550,7 @@ class FunctionAction(_ActionAction): """Class for Python function actions.""" def __init__(self, execfunction, *args, **kw): - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Action.FunctionAction') self.execfunction = execfunction apply(_ActionAction.__init__, (self,)+args, kw) self.varlist = kw.get('varlist', []) @@ -626,7 +626,7 @@ class FunctionAction(_ActionAction): class ListAction(ActionBase): """Class for lists of other actions.""" def __init__(self, list): - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Action.ListAction') def list_of_actions(x): if isinstance(x, ActionBase): return x diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 584becad..39466a56 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -222,7 +222,7 @@ class OverrideWarner(UserDict.UserDict): """ def __init__(self, dict): UserDict.UserDict.__init__(self, dict) - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Builder.OverrideWarner') self.already_warned = None def warn(self): if self.already_warned: @@ -396,7 +396,7 @@ class BuilderBase: chdir = _null, is_explicit = 1, **overrides): - if __debug__: logInstanceCreation(self, 'BuilderBase') + if __debug__: logInstanceCreation(self, 'Builder.BuilderBase') self.action = SCons.Action.Action(action) self.multi = multi if SCons.Util.is_Dict(prefix): @@ -648,7 +648,7 @@ class ListBuilder(SCons.Util.Proxy): """ def __init__(self, builder, env, tlist): - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Builder.ListBuilder') SCons.Util.Proxy.__init__(self, builder) self.builder = builder self.target_scanner = builder.target_scanner @@ -690,7 +690,7 @@ class MultiStepBuilder(BuilderBase): source_scanner = None, emitter=None, single_source=0): - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Builder.MultiStepBuilder') BuilderBase.__init__(self, action, prefix, suffix, src_suffix, target_factory, source_factory, target_scanner, source_scanner, emitter, @@ -774,7 +774,7 @@ class CompositeBuilder(SCons.Util.Proxy): """ def __init__(self, builder, cmdgen): - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Builder.CompositeBuilder') SCons.Util.Proxy.__init__(self, builder) # cmdgen should always be an instance of DictCmdGenerator. diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 94706234..5249bbd4 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -245,7 +245,7 @@ class SubstitutionEnvironment: def __init__(self, **kw): """Initialization of an underlying SubstitutionEnvironment class. """ - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Environment.SubstitutionEnvironment') self.fs = SCons.Node.FS.default_fs self.ans = SCons.Node.Alias.default_ans self.lookup_list = SCons.Node.arg2nodes_lookups @@ -478,7 +478,7 @@ class Base(SubstitutionEnvironment): initialize things in a very specific order that doesn't work with the much simpler base class initialization. """ - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Environment.Base') self.fs = SCons.Node.FS.default_fs self.ans = SCons.Node.Alias.default_ans self.lookup_list = SCons.Node.arg2nodes_lookups @@ -730,7 +730,7 @@ class Base(SubstitutionEnvironment): for key, value in kw.items(): new[key] = SCons.Util.scons_subst_once(value, self, key) apply(clone.Replace, (), new) - if __debug__: logInstanceCreation(self, 'EnvironmentCopy') + if __debug__: logInstanceCreation(self, 'Environment.EnvironmentCopy') return clone def Detect(self, progs): @@ -1423,7 +1423,7 @@ class OverrideEnvironment(SubstitutionEnvironment): __metaclass__ = SCons.Memoize.Memoized_Metaclass def __init__(self, subject, overrides={}): - if __debug__: logInstanceCreation(self, 'OverrideEnvironment') + if __debug__: logInstanceCreation(self, 'Environment.OverrideEnvironment') self.__dict__['__subject'] = subject self.__dict__['overrides'] = overrides diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index 5b45d552..c425a052 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -47,7 +47,7 @@ class Executor: def __init__(self, action, env=None, overridelist=[{}], targets=[], sources=[], builder_kw={}): - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Executor.Executor') if not action: raise SCons.Errors.UserError, "Executor must have an action." self.action = action @@ -204,6 +204,8 @@ class Null: disassociate Builders from Nodes entirely, so we're not going to worry about unit tests for this--at least for now. """ + def __init__(self): + if __debug__: logInstanceCreation(self, 'Executor.Null') def get_build_env(self): class NullEnvironment: def get_scanner(self, key): diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index e42166fc..d15043cd 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -756,7 +756,7 @@ class FS(LocalFS): The path argument must be a valid absolute path. """ - if __debug__: logInstanceCreation(self) + if __debug__: logInstanceCreation(self, 'Node.FS') self.Top = None if path == None: self.pathTop = os.getcwd() diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 3c0ce990..825e1324 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -99,7 +99,7 @@ class Node: pass def __init__(self): - if __debug__: logInstanceCreation(self, 'Node') + if __debug__: logInstanceCreation(self, 'Node.Node') # Note that we no longer explicitly initialize a self.builder # attribute to None here. That's because the self.builder # attribute may be created on-the-fly later by a subclass (the diff --git a/test/option/debug-count.py b/test/option/debug-count.py index 37323db4..ca627e88 100644 --- a/test/option/debug-count.py +++ b/test/option/debug-count.py @@ -59,11 +59,28 @@ test.write('file.in', "file.in\n") test.run(arguments = "--debug=count") stdout = test.stdout() -test.fail_test(re.search('\d+ +\d+ +\d+ +\d+ BuilderBase', stdout) is None) -test.fail_test(re.search('\d+ +\d+ +\d+ +\d+ FS', stdout) is None) -test.fail_test(re.search('\d+ +\d+ +\d+ +\d+ Node', stdout) is None) -test.fail_test(re.search('\d+ +\d+ +\d+ +\d+ SConsEnvironment', stdout) is None) +def find_object_count(s, stdout): + re_string = '\d+ +\d+ +\d+ +\d+ %s' % re.escape(s) + return re.search(re_string, stdout) +objects = [ + 'Action.CommandAction', + 'Builder.BuilderBase', + 'Environment.Base', + 'Executor.Executor', + 'Node.FS', + 'Node.FS.Base', + 'Node.Node', +] + +missing = filter(lambda o: find_object_count(o, stdout) is None, objects) + +if missing: + print "Missing the following object lines:" + print "\t", string.join(missing) + print "STDOUT ==========" + print stdout + test.fail_test(1) test.pass_test()