[jhbuild] Add an --in-checkoutdir option for jhbuild run



commit 4b6bd8ead0395bd6c0975fefc0255fab306a23bf
Author: Jon TURNEY <jon turney dronecode org uk>
Date:   Mon Oct 5 18:11:07 2009 +0100

    Add an --in-checkoutdir option for jhbuild run
    
    Signed-off-by: Jon TURNEY <jon turney dronecode org uk>

 doc/C/jhbuild.xml        |   11 +++++++++++
 jhbuild/commands/base.py |   25 ++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/doc/C/jhbuild.xml b/doc/C/jhbuild.xml
index 967a2b8..bd4af2e 100644
--- a/doc/C/jhbuild.xml
+++ b/doc/C/jhbuild.xml
@@ -1059,6 +1059,7 @@ libgnomecanvas is missing branch definition for gnome-2-20
       <cmdsynopsis>
 	<command>jhbuild run</command>
 	<arg>--in-builddir</arg>
+	<arg>--in-checkoutdir</arg>
 	<arg choice="plain"><replaceable>program</replaceable></arg>
 	<arg rep="repeat"><replaceable>argument</replaceable></arg>
       </cmdsynopsis>
@@ -1076,6 +1077,16 @@ libgnomecanvas is missing branch definition for gnome-2-20
 	</varlistentry>
       </variablelist>
 
+      <variablelist>
+        <varlistentry>
+	  <term><option>--in-checkoutdir</option>=<replaceable>module</replaceable></term>
+  	  <listitem>
+	    <simpara>Run the command in the source directory of the
+	    specified module.</simpara>
+  	  </listitem>
+	</varlistentry>
+      </variablelist>
+
     </section>
 
     <section id="command-reference-sanitycheck">
diff --git a/jhbuild/commands/base.py b/jhbuild/commands/base.py
index 93d552d..fb40b89 100644
--- a/jhbuild/commands/base.py
+++ b/jhbuild/commands/base.py
@@ -364,10 +364,16 @@ class cmd_run(Command):
             make_option('--in-builddir', metavar='MODULE',
                         action='store', dest='in_builddir', default = None,
                         help=_('run command in build dir of the given module')),
+            make_option('--in-checkoutdir', metavar='MODULE',
+                        action='store', dest='in_checkoutdir', default = None,
+                        help=_('run command in checkout dir of the given module')),
             ])
 
     def execute(self, config, args):
-        if not args or args[0] in ('--', '--help') or args[0].startswith('--in-builddir'):
+        # Do a shallow check of the arguments list
+        # so that '--' isn't always required when command has arguments, 
+        # only if some of them look like they might be for us
+        if not args or args[0] in ('--', '--help') or args[0].startswith('--in-builddir') or args[0].startswith('--in-checkoutdir'):
             options, args = self.parse_args(args)
             return self.run(config, options, args)
         try:
@@ -394,6 +400,23 @@ class cmd_run(Command):
                     raise FatalError(_("Unable to execute the command '%s'") % args[0])
                 else:
                     raise FatalError(str(exc))
+        elif options.in_checkoutdir:
+            module_set = jhbuild.moduleset.load(config)
+            try:
+                module_list = [module_set.get_module(options.in_checkoutdir, ignore_case = True)
+                               for modname in args]
+            except KeyError, e:
+                raise FatalError(_("A module called '%s' could not be found.") % e)
+
+            build = jhbuild.frontends.get_buildscript(config, module_list)
+            checkoutdir = module_list[0].get_srcdir(build)
+            try:
+                build.execute(args, cwd=checkoutdir)
+            except CommandError, exc:
+                if args:
+                    raise FatalError(_("Unable to execute the command '%s'") % args[0])
+                else:
+                    raise FatalError(str(exc))
         else:
             try:
                 os.execlp(args[0], *args)



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