jhbuild r1845 - in trunk: . doc/C jhbuild jhbuild/commands



Author: fpeters
Date: Fri Jan 18 21:16:14 2008
New Revision: 1845
URL: http://svn.gnome.org/viewvc/jhbuild?rev=1845&view=rev

Log:
* doc/C/jhbuild.xml, jhbuild/commands/base.py, jhbuild/moduleset.py:
added --soft-deps and --clusters options to the dot command; the
--soft-deps option will add dotted lines from the modules to their soft
dependencies; the --clusters option will group modules from metamodules
together.



Modified:
   trunk/ChangeLog
   trunk/doc/C/jhbuild.xml
   trunk/jhbuild/commands/base.py
   trunk/jhbuild/moduleset.py

Modified: trunk/doc/C/jhbuild.xml
==============================================================================
--- trunk/doc/C/jhbuild.xml	(original)
+++ trunk/doc/C/jhbuild.xml	Fri Jan 18 21:16:14 2008
@@ -740,18 +740,30 @@
 
       <cmdsynopsis>
 	<command>jhbuild dot</command>
+	<arg>--soft-deps</arg>
+	<arg>--clusters</arg>
 	<arg rep="repeat">module</arg>
       </cmdsynopsis>
 
       <para>If no module names are given on the command line, then the
       module list found in the configuration file will be used.</para>
 
+      <para>The <option>--soft-deps</option> option will add dotted lines from
+      the modules to their soft dependencies.  The <option>--clusters</option>
+      option will group modules from <link
+      linkend="moduleset-syntax-defs-metamodule">metamodules</link>
+      together.</para>
+
       <para>The output of this command can easily be piped to the
-      <command>dot</command> utility to generate a postscript
+      <command>dot</command> utility to generate a PostScript
       file:</para>
 
       <screen><prompt>$</prompt> <userinput>jhbuild dot <replaceable>modules</replaceable> | dot -Tps > dependencies.ps</userinput></screen>
 
+      <para>Or a PNG image:</para>
+
+      <screen><prompt>$</prompt> <userinput>jhbuild dot <replaceable>modules</replaceable> | dot -Tpng > dependencies.png</userinput></screen>
+
       <figure id="sample-dot-output">
         <title>Sample jhbuild dot output</title>
         <screenshot>

Modified: trunk/jhbuild/commands/base.py
==============================================================================
--- trunk/jhbuild/commands/base.py	(original)
+++ trunk/jhbuild/commands/base.py	Fri Jan 18 21:16:14 2008
@@ -382,6 +382,16 @@
     name = 'dot'
     usage_args = '[ modules ... ]'
 
+    def __init__(self):
+        Command.__init__(self, [
+            make_option('--soft-deps',
+                        action='store_true', dest='soft_deps', default=False,
+                        help='add dotted lines to soft dependencies'),
+            make_option('--clusters',
+                        action='store_true', dest='clusters', default=False,
+                        help='group modules from metamodule together'),
+            ])
+
     def run(self, config, options, args):
         module_set = jhbuild.moduleset.load(config)
         if args:
@@ -390,6 +400,11 @@
             modules = None
         else:
             modules = config.modules
-        module_set.write_dot(modules)
+        kwargs = {}
+        if options.soft_deps:
+            kwargs['suggests'] = True
+        if options.clusters:
+            kwargs['clusters'] = True
+        module_set.write_dot(modules, **kwargs)
 
 register_command(cmd_dot)

Modified: trunk/jhbuild/moduleset.py
==============================================================================
--- trunk/jhbuild/moduleset.py	(original)
+++ trunk/jhbuild/moduleset.py	Fri Jan 18 21:16:14 2008
@@ -161,7 +161,7 @@
                     test_modules.append(mod)
         return test_modules
     
-    def write_dot(self, modules=None, fp=sys.stdout):
+    def write_dot(self, modules=None, fp=sys.stdout, suggests=False, clusters=False):
         from jhbuild.modtypes import MetaModule
         from jhbuild.modtypes.autotools import AutogenModule
         from jhbuild.versioncontrol.tarball import TarballBranch
@@ -202,6 +202,28 @@
                 if not inlist.has_key(dep):
                     modules.append(dep)
                 inlist[dep] = None
+
+            if suggests:
+                for dep in self.modules[modname].after + self.modules[modname].suggests:
+                    if self.modules.has_key(dep):
+                        fp.write('  "%s" -> "%s" [style=dotted];\n' % (modname, dep))
+                        if not inlist.has_key(dep):
+                            modules.append(dep)
+                        inlist[dep] = None
+
+        if clusters:
+            # create clusters for MetaModules
+            for modname in inlist.keys():
+                mod = self.modules.get(modname)
+                if isinstance(mod, MetaModule):
+                    fp.write('  subgraph "cluster_%s" {\n' % mod.name)
+                    fp.write('     label="%s";\n' % mod.name)
+                    fp.write('     style="filled";bgcolor="honeydew2";\n')
+
+                    for dep in mod.dependencies:
+                        fp.write('    "%s";\n' % dep)
+                    fp.write('  }\n')
+
         fp.write('}\n')
 
 def load(config, uri=None):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]