Group --debug=count output by object modules.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 1 Mar 2005 13:27:51 +0000 (13:27 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 1 Mar 2005 13:27:51 +0000 (13:27 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1238 fdb21ef1-2011-0410-befe-b5e4ea1792b1

bin/objcounts.py
src/engine/SCons/Action.py
src/engine/SCons/Builder.py
src/engine/SCons/Environment.py
src/engine/SCons/Executor.py
src/engine/SCons/Node/FS.py
src/engine/SCons/Node/__init__.py
test/option/debug-count.py

index 7aa293b70d2265cb3670dedbd189b61f503a81d1..1b72837a10da7831b06ae282033f48e6a8afbb18 100644 (file)
@@ -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]
index fa8f1d25b539382f911e5a87dd2a026df12b58ae..077ddfb60d959f603bee66ca160b9bbd2103fa72 100644 (file)
@@ -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
index 584becad5c3a191f1df4a640e80bef988d27a2eb..39466a56feea2835d89070b38e3979e4a1fa716e 100644 (file)
@@ -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.
index 94706234b97d1c584794ceed806bfdae85b0feb3..5249bbd4ef17b950aaa3abd95c93c9206997410d 100644 (file)
@@ -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
 
index 5b45d5521acaa979e91b543c76049325c263dfc3..c425a052351b54276ff082345e47889c33c198bc 100644 (file)
@@ -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):
index e42166fcf4263464c55d49bcfc13df50313c992e..d15043cd35fd12706edda2e9bbdc85b523b456e8 100644 (file)
@@ -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()
index 3c0ce990050720a9536b56a7f17d761e57a7859e..825e1324397289696af8fbeffd0c2385355d1852 100644 (file)
@@ -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
index 37323db445166c99d3a42c716afcab487d398a7b..ca627e88fe9568344a53c3d5c770f589096a3dc1 100644 (file)
@@ -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()