Patchwork [bitbake-devel,2/3] build.py: Add additional debug messages

login
register
mail settings
Submitter Mark Hatle
Date May 23, 2012, 1:46 a.m.
Message ID <1337737597-5964-2-git-send-email-mark.hatle@windriver.com>
Download mbox | patch
Permalink /patch/28391/
State New
Headers show

Comments

Mark Hatle - May 23, 2012, 1:46 a.m.
We now add a debug message when entering and exiting a python or
shell function.  This makes it easier to inspect a log and figure
out the run order from the logs.

Also minor cleanup in th exec_func_shell to match the exec_func_python
variables.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
 lib/bb/build.py |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
Richard Purdie - May 23, 2012, 1:50 p.m.
On Tue, 2012-05-22 at 20:46 -0500, Mark Hatle wrote:
> We now add a debug message when entering and exiting a python or
> shell function.  This makes it easier to inspect a log and figure
> out the run order from the logs.
> 
> Also minor cleanup in th exec_func_shell to match the exec_func_python
> variables.
> 
> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
> ---
>  lib/bb/build.py |   20 +++++++++++++++-----
>  1 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/bb/build.py b/lib/bb/build.py
> index 4f06b15..2fbe120 100644
> --- a/lib/bb/build.py
> +++ b/lib/bb/build.py
> @@ -206,6 +206,8 @@ def exec_func_python(func, d, runfile, cwd=None):
>              olddir = None
>          os.chdir(cwd)
>  
> +    bb.debug(2, "Executing python function %s" % func)
> +
>      try:
>          comp = utils.better_compile(code, func, bbfile)
>          utils.better_exec(comp, {"d": d}, code, bbfile)
> @@ -215,13 +217,15 @@ def exec_func_python(func, d, runfile, cwd=None):
>  
>          raise FuncFailed(func, None)
>      finally:
> +        bb.debug(2, "Python function %s finished" % func)
> +
>          if cwd and olddir:
>              try:
>                  os.chdir(olddir)
>              except OSError:
>                  pass
>  
> -def exec_func_shell(function, d, runfile, cwd=None):
> +def exec_func_shell(func, d, runfile, cwd=None):

Mixing variable renames with other code changes isn't really a good idea
and confuses this patch :/.

Cheers,

Richard

Patch

diff --git a/lib/bb/build.py b/lib/bb/build.py
index 4f06b15..2fbe120 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -206,6 +206,8 @@  def exec_func_python(func, d, runfile, cwd=None):
             olddir = None
         os.chdir(cwd)
 
+    bb.debug(2, "Executing python function %s" % func)
+
     try:
         comp = utils.better_compile(code, func, bbfile)
         utils.better_exec(comp, {"d": d}, code, bbfile)
@@ -215,13 +217,15 @@  def exec_func_python(func, d, runfile, cwd=None):
 
         raise FuncFailed(func, None)
     finally:
+        bb.debug(2, "Python function %s finished" % func)
+
         if cwd and olddir:
             try:
                 os.chdir(olddir)
             except OSError:
                 pass
 
-def exec_func_shell(function, d, runfile, cwd=None):
+def exec_func_shell(func, d, runfile, cwd=None):
     """Execute a shell function from the metadata
 
     Note on directory behavior.  The 'dirs' varflag should contain a list
@@ -234,18 +238,18 @@  def exec_func_shell(function, d, runfile, cwd=None):
 
     with open(runfile, 'w') as script:
         script.write('#!/bin/sh -e\n')
-        data.emit_func(function, script, d)
+        data.emit_func(func, script, d)
 
         if bb.msg.loggerVerboseLogs:
             script.write("set -x\n")
         if cwd:
             script.write("cd %s\n" % cwd)
-        script.write("%s\n" % function)
+        script.write("%s\n" % func)
 
     os.chmod(runfile, 0775)
 
     cmd = runfile
-    if d.getVarFlag(function, 'fakeroot'):
+    if d.getVarFlag(func, 'fakeroot'):
         fakerootcmd = d.getVar('FAKEROOT', True)
         if fakerootcmd:
             cmd = [fakerootcmd, runfile]
@@ -255,11 +259,17 @@  def exec_func_shell(function, d, runfile, cwd=None):
     else:
         logfile = sys.stdout
 
+    bb.debug(2, "Executing shell function %s" % func)
+
     try:
         bb.process.run(cmd, shell=False, stdin=NULL, log=logfile)
+
     except bb.process.CmdError:
         logfn = d.getVar('BB_LOGFILE', True)
-        raise FuncFailed(function, logfn)
+        raise FuncFailed(func, logfn)
+
+    bb.debug(2, "Shell function %s finished" % func)
+
 
 def _task_data(fn, task, d):
     localdata = data.createCopy(d)