From 4b6bd8ead0395bd6c0975fefc0255fab306a23bf Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Mon, 5 Oct 2009 18:11:07 +0100 Subject: [PATCH] Add an --in-checkoutdir option for jhbuild run Signed-off-by: Jon TURNEY --- doc/C/jhbuild.xml | 11 +++++++++++ jhbuild/commands/base.py | 25 ++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/doc/C/jhbuild.xml b/doc/C/jhbuild.xml index 967a2b87..bd4af2ef 100644 --- a/doc/C/jhbuild.xml +++ b/doc/C/jhbuild.xml @@ -1059,6 +1059,7 @@ libgnomecanvas is missing branch definition for gnome-2-20 jhbuild run --in-builddir + --in-checkoutdir program argument @@ -1076,6 +1077,16 @@ libgnomecanvas is missing branch definition for gnome-2-20 + + + =module + + Run the command in the source directory of the + specified module. + + + +
diff --git a/jhbuild/commands/base.py b/jhbuild/commands/base.py index 93d552db..fb40b896 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) -- 2.11.4.GIT