* [PATCH 1/3] build.py: Add a log to capture task execution order
2012-05-23 1:46 [PATCH 0/3] RFC: Refactor/cleanup logging/run file generation Mark Hatle
@ 2012-05-23 0:06 ` Mark Hatle
2012-05-23 0:06 ` [PATCH 2/3] build.py: Add additional debug messages Mark Hatle
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Mark Hatle @ 2012-05-23 0:06 UTC (permalink / raw)
To: bitbake-devel
The new log.task_order contains an ordered list of the tasks as they
were executed in any given recipe. The format of the lines is
<task> <pid>: <log file>
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
lib/bb/build.py | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 95f1dcf..4f06b15 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -290,8 +290,22 @@ def _exec_task(fn, task, d, quieterr):
bb.fatal("T variable not set, unable to build")
bb.utils.mkdirhier(tempdir)
- loglink = os.path.join(tempdir, 'log.{0}'.format(task))
+
+ # Determine the logfile to generate
logbase = 'log.{0}.{1}'.format(task, os.getpid())
+
+ # Document the order of the tasks...
+ logorder = os.path.join(tempdir, 'log.task_order')
+ try:
+ logorderfile = file(logorder, 'a')
+ except OSError:
+ logger.exception("Opening log file '%s'", logorder)
+ pass
+ logorderfile.write('{0} ({1}): {2}\n'.format(task, os.getpid(), logbase))
+ logorderfile.close()
+
+ # Setup the courtesy link to the logfn
+ loglink = os.path.join(tempdir, 'log.{0}'.format(task))
logfn = os.path.join(tempdir, logbase)
if loglink:
bb.utils.remove(loglink)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 2/3] build.py: Add additional debug messages
2012-05-23 1:46 [PATCH 0/3] RFC: Refactor/cleanup logging/run file generation Mark Hatle
2012-05-23 0:06 ` [PATCH 1/3] build.py: Add a log to capture task execution order Mark Hatle
@ 2012-05-23 0:06 ` Mark Hatle
2012-05-23 0:06 ` [PATCH 3/3] build.py: Add support for log and run filename changes Mark Hatle
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Mark Hatle @ 2012-05-23 0:06 UTC (permalink / raw)
To: bitbake-devel
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):
"""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)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 3/3] build.py: Add support for log and run filename changes
2012-05-23 1:46 [PATCH 0/3] RFC: Refactor/cleanup logging/run file generation Mark Hatle
2012-05-23 0:06 ` [PATCH 1/3] build.py: Add a log to capture task execution order Mark Hatle
2012-05-23 0:06 ` [PATCH 2/3] build.py: Add additional debug messages Mark Hatle
@ 2012-05-23 0:06 ` Mark Hatle
2012-05-23 1:46 ` [PATCH 1/3] build.py: Add a log to capture task execution order Mark Hatle
` (6 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Mark Hatle @ 2012-05-23 0:06 UTC (permalink / raw)
To: bitbake-devel
The format of the log file and run file are now selectable
using BB_LOGFMT and BB_RUNFMT, respectively.
The following values may be used:
{task} - task name
{taskfunc} - task.func or func, if task==func
{func} - function name, only available in BB_RUNFMT
{pid} - pid
The log/run files may be placed into a subdirectory that
is relative to T.
Default BB_LOGFMT is: log.{task}.{pid}
Default BB_RUNFMT is: run.{func}.{pid}
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
lib/bb/build.py | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 2fbe120..e867894 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -174,8 +174,19 @@ def exec_func(func, d, dirs = None):
lockfiles = None
tempdir = data.getVar('T', d, 1)
- bb.utils.mkdirhier(tempdir)
- runfile = os.path.join(tempdir, 'run.{0}.{1}'.format(func, os.getpid()))
+
+ # or func allows items to be executed outside of the normal
+ # task set, such as buildhistory
+ task = data.getVar('BB_RUNTASK', d, 1) or func
+ if task == func:
+ taskfunc = task
+ else:
+ taskfunc = "%s.%s" % (task, func)
+
+ runfmt = data.getVar('BB_RUNFMT', d, 1) or "run.{func}.{pid}"
+ runfn = runfmt.format(taskfunc=taskfunc, task=task, func=func, pid=os.getpid())
+ runfile = os.path.join(tempdir, runfn)
+ bb.utils.mkdirhier(os.path.dirname(runfile))
with bb.utils.fileslocked(lockfiles):
if ispython:
@@ -302,7 +313,8 @@ def _exec_task(fn, task, d, quieterr):
bb.utils.mkdirhier(tempdir)
# Determine the logfile to generate
- logbase = 'log.{0}.{1}'.format(task, os.getpid())
+ logfmt = localdata.getVar('BB_LOGFMT', True) or 'log.{task}.{pid}'
+ logbase = logfmt.format(task=task, pid=os.getpid())
# Document the order of the tasks...
logorder = os.path.join(tempdir, 'log.task_order')
@@ -338,6 +350,7 @@ def _exec_task(fn, task, d, quieterr):
# Handle logfiles
si = file('/dev/null', 'r')
try:
+ bb.utils.mkdirhier(os.path.dirname(logfn))
logfile = file(logfn, 'w')
except OSError:
logger.exception("Opening log file '%s'", logfn)
@@ -364,6 +377,7 @@ def _exec_task(fn, task, d, quieterr):
bblogger.addHandler(errchk)
localdata.setVar('BB_LOGFILE', logfn)
+ localdata.setVar('BB_RUNTASK', task)
event.fire(TaskStarted(task, localdata), localdata)
try:
--
1.7.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 1/3] build.py: Add a log to capture task execution order
2012-05-23 1:46 [PATCH 0/3] RFC: Refactor/cleanup logging/run file generation Mark Hatle
` (2 preceding siblings ...)
2012-05-23 0:06 ` [PATCH 3/3] build.py: Add support for log and run filename changes Mark Hatle
@ 2012-05-23 1:46 ` Mark Hatle
2012-05-23 1:46 ` [PATCH 2/3] build.py: Add additional debug messages Mark Hatle
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Mark Hatle @ 2012-05-23 1:46 UTC (permalink / raw)
To: bitbake-devel
The new log.task_order contains an ordered list of the tasks as they
were executed in any given recipe. The format of the lines is
<task> <pid>: <log file>
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
lib/bb/build.py | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 95f1dcf..4f06b15 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -290,8 +290,22 @@ def _exec_task(fn, task, d, quieterr):
bb.fatal("T variable not set, unable to build")
bb.utils.mkdirhier(tempdir)
- loglink = os.path.join(tempdir, 'log.{0}'.format(task))
+
+ # Determine the logfile to generate
logbase = 'log.{0}.{1}'.format(task, os.getpid())
+
+ # Document the order of the tasks...
+ logorder = os.path.join(tempdir, 'log.task_order')
+ try:
+ logorderfile = file(logorder, 'a')
+ except OSError:
+ logger.exception("Opening log file '%s'", logorder)
+ pass
+ logorderfile.write('{0} ({1}): {2}\n'.format(task, os.getpid(), logbase))
+ logorderfile.close()
+
+ # Setup the courtesy link to the logfn
+ loglink = os.path.join(tempdir, 'log.{0}'.format(task))
logfn = os.path.join(tempdir, logbase)
if loglink:
bb.utils.remove(loglink)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 2/3] build.py: Add additional debug messages
2012-05-23 1:46 [PATCH 0/3] RFC: Refactor/cleanup logging/run file generation Mark Hatle
` (3 preceding siblings ...)
2012-05-23 1:46 ` [PATCH 1/3] build.py: Add a log to capture task execution order Mark Hatle
@ 2012-05-23 1:46 ` Mark Hatle
2012-05-23 13:50 ` Richard Purdie
2012-05-23 1:46 ` [PATCH 3/3] build.py: Add support for log and run filename changes Mark Hatle
` (4 subsequent siblings)
9 siblings, 1 reply; 13+ messages in thread
From: Mark Hatle @ 2012-05-23 1:46 UTC (permalink / raw)
To: bitbake-devel
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):
"""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)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH 2/3] build.py: Add additional debug messages
2012-05-23 1:46 ` [PATCH 2/3] build.py: Add additional debug messages Mark Hatle
@ 2012-05-23 13:50 ` Richard Purdie
0 siblings, 0 replies; 13+ messages in thread
From: Richard Purdie @ 2012-05-23 13:50 UTC (permalink / raw)
To: Mark Hatle; +Cc: bitbake-devel
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/3] build.py: Add support for log and run filename changes
2012-05-23 1:46 [PATCH 0/3] RFC: Refactor/cleanup logging/run file generation Mark Hatle
` (4 preceding siblings ...)
2012-05-23 1:46 ` [PATCH 2/3] build.py: Add additional debug messages Mark Hatle
@ 2012-05-23 1:46 ` Mark Hatle
2012-05-23 15:45 ` [PATCH 1/4] build.py: Add a log to capture task execution order Mark Hatle
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Mark Hatle @ 2012-05-23 1:46 UTC (permalink / raw)
To: bitbake-devel
The format of the log file and run file are now selectable
using BB_LOGFMT and BB_RUNFMT, respectively.
The following values may be used:
{task} - task name
{taskfunc} - task.func or func, if task==func
{func} - function name, only available in BB_RUNFMT
{pid} - pid
The log/run files may be placed into a subdirectory that
is relative to T.
Default BB_LOGFMT is: log.{task}.{pid}
Default BB_RUNFMT is: run.{func}.{pid}
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
lib/bb/build.py | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 2fbe120..e867894 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -174,8 +174,19 @@ def exec_func(func, d, dirs = None):
lockfiles = None
tempdir = data.getVar('T', d, 1)
- bb.utils.mkdirhier(tempdir)
- runfile = os.path.join(tempdir, 'run.{0}.{1}'.format(func, os.getpid()))
+
+ # or func allows items to be executed outside of the normal
+ # task set, such as buildhistory
+ task = data.getVar('BB_RUNTASK', d, 1) or func
+ if task == func:
+ taskfunc = task
+ else:
+ taskfunc = "%s.%s" % (task, func)
+
+ runfmt = data.getVar('BB_RUNFMT', d, 1) or "run.{func}.{pid}"
+ runfn = runfmt.format(taskfunc=taskfunc, task=task, func=func, pid=os.getpid())
+ runfile = os.path.join(tempdir, runfn)
+ bb.utils.mkdirhier(os.path.dirname(runfile))
with bb.utils.fileslocked(lockfiles):
if ispython:
@@ -302,7 +313,8 @@ def _exec_task(fn, task, d, quieterr):
bb.utils.mkdirhier(tempdir)
# Determine the logfile to generate
- logbase = 'log.{0}.{1}'.format(task, os.getpid())
+ logfmt = localdata.getVar('BB_LOGFMT', True) or 'log.{task}.{pid}'
+ logbase = logfmt.format(task=task, pid=os.getpid())
# Document the order of the tasks...
logorder = os.path.join(tempdir, 'log.task_order')
@@ -338,6 +350,7 @@ def _exec_task(fn, task, d, quieterr):
# Handle logfiles
si = file('/dev/null', 'r')
try:
+ bb.utils.mkdirhier(os.path.dirname(logfn))
logfile = file(logfn, 'w')
except OSError:
logger.exception("Opening log file '%s'", logfn)
@@ -364,6 +377,7 @@ def _exec_task(fn, task, d, quieterr):
bblogger.addHandler(errchk)
localdata.setVar('BB_LOGFILE', logfn)
+ localdata.setVar('BB_RUNTASK', task)
event.fire(TaskStarted(task, localdata), localdata)
try:
--
1.7.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 1/4] build.py: Add a log to capture task execution order
2012-05-23 1:46 [PATCH 0/3] RFC: Refactor/cleanup logging/run file generation Mark Hatle
` (5 preceding siblings ...)
2012-05-23 1:46 ` [PATCH 3/3] build.py: Add support for log and run filename changes Mark Hatle
@ 2012-05-23 15:45 ` Mark Hatle
2012-05-23 17:15 ` Richard Purdie
2012-05-23 15:45 ` [PATCH 2/4] build.py: Cleanup exec_func_shell Mark Hatle
` (2 subsequent siblings)
9 siblings, 1 reply; 13+ messages in thread
From: Mark Hatle @ 2012-05-23 15:45 UTC (permalink / raw)
To: bitbake-devel
The new log.task_order contains an ordered list of the tasks as they
were executed in any given recipe. The format of the lines is
<task> <pid>: <log file>
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
lib/bb/build.py | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 95f1dcf..4f06b15 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -290,8 +290,22 @@ def _exec_task(fn, task, d, quieterr):
bb.fatal("T variable not set, unable to build")
bb.utils.mkdirhier(tempdir)
- loglink = os.path.join(tempdir, 'log.{0}'.format(task))
+
+ # Determine the logfile to generate
logbase = 'log.{0}.{1}'.format(task, os.getpid())
+
+ # Document the order of the tasks...
+ logorder = os.path.join(tempdir, 'log.task_order')
+ try:
+ logorderfile = file(logorder, 'a')
+ except OSError:
+ logger.exception("Opening log file '%s'", logorder)
+ pass
+ logorderfile.write('{0} ({1}): {2}\n'.format(task, os.getpid(), logbase))
+ logorderfile.close()
+
+ # Setup the courtesy link to the logfn
+ loglink = os.path.join(tempdir, 'log.{0}'.format(task))
logfn = os.path.join(tempdir, logbase)
if loglink:
bb.utils.remove(loglink)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 2/4] build.py: Cleanup exec_func_shell
2012-05-23 1:46 [PATCH 0/3] RFC: Refactor/cleanup logging/run file generation Mark Hatle
` (6 preceding siblings ...)
2012-05-23 15:45 ` [PATCH 1/4] build.py: Add a log to capture task execution order Mark Hatle
@ 2012-05-23 15:45 ` Mark Hatle
2012-05-23 15:45 ` [PATCH 3/4] build.py: Add additional debug messages Mark Hatle
2012-05-23 15:45 ` [PATCH 4/4] build.py: Add support for log and run filename changes Mark Hatle
9 siblings, 0 replies; 13+ messages in thread
From: Mark Hatle @ 2012-05-23 15:45 UTC (permalink / raw)
To: bitbake-devel
exec_func_python and exec_func_shell are similar, but variable
usage has diverged sync the two up. Since exec_func_python is first
use that as the guide for the later exec_func_shell variable naming.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
lib/bb/build.py | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 4f06b15..9f2c6a7 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -221,7 +221,7 @@ def exec_func_python(func, d, runfile, cwd=None):
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 +234,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]
@@ -259,7 +259,7 @@ def exec_func_shell(function, d, runfile, cwd=None):
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)
def _task_data(fn, task, d):
localdata = data.createCopy(d)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 3/4] build.py: Add additional debug messages
2012-05-23 1:46 [PATCH 0/3] RFC: Refactor/cleanup logging/run file generation Mark Hatle
` (7 preceding siblings ...)
2012-05-23 15:45 ` [PATCH 2/4] build.py: Cleanup exec_func_shell Mark Hatle
@ 2012-05-23 15:45 ` Mark Hatle
2012-05-23 15:45 ` [PATCH 4/4] build.py: Add support for log and run filename changes Mark Hatle
9 siblings, 0 replies; 13+ messages in thread
From: Mark Hatle @ 2012-05-23 15:45 UTC (permalink / raw)
To: bitbake-devel
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.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
lib/bb/build.py | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 9f2c6a7..363aced 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,6 +217,8 @@ 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)
@@ -255,12 +259,16 @@ def exec_func_shell(func, 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(func, logfn)
+ bb.debug(2, "Shell function %s finished" % func)
+
def _task_data(fn, task, d):
localdata = data.createCopy(d)
localdata.setVar('BB_FILENAME', fn)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 4/4] build.py: Add support for log and run filename changes
2012-05-23 1:46 [PATCH 0/3] RFC: Refactor/cleanup logging/run file generation Mark Hatle
` (8 preceding siblings ...)
2012-05-23 15:45 ` [PATCH 3/4] build.py: Add additional debug messages Mark Hatle
@ 2012-05-23 15:45 ` Mark Hatle
9 siblings, 0 replies; 13+ messages in thread
From: Mark Hatle @ 2012-05-23 15:45 UTC (permalink / raw)
To: bitbake-devel
The format of the log file and run file are now selectable
using BB_LOGFMT and BB_RUNFMT, respectively.
The following values may be used:
{task} - task name
{taskfunc} - task.func or func, if task==func
{func} - function name, only available in BB_RUNFMT
{pid} - pid
The log/run files may be placed into a subdirectory that
is relative to T.
Default BB_LOGFMT is: log.{task}.{pid}
Default BB_RUNFMT is: run.{func}.{pid}
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
lib/bb/build.py | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 363aced..a9ba02d 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -174,8 +174,19 @@ def exec_func(func, d, dirs = None):
lockfiles = None
tempdir = data.getVar('T', d, 1)
- bb.utils.mkdirhier(tempdir)
- runfile = os.path.join(tempdir, 'run.{0}.{1}'.format(func, os.getpid()))
+
+ # or func allows items to be executed outside of the normal
+ # task set, such as buildhistory
+ task = data.getVar('BB_RUNTASK', d, 1) or func
+ if task == func:
+ taskfunc = task
+ else:
+ taskfunc = "%s.%s" % (task, func)
+
+ runfmt = data.getVar('BB_RUNFMT', d, 1) or "run.{func}.{pid}"
+ runfn = runfmt.format(taskfunc=taskfunc, task=task, func=func, pid=os.getpid())
+ runfile = os.path.join(tempdir, runfn)
+ bb.utils.mkdirhier(os.path.dirname(runfile))
with bb.utils.fileslocked(lockfiles):
if ispython:
@@ -300,7 +311,8 @@ def _exec_task(fn, task, d, quieterr):
bb.utils.mkdirhier(tempdir)
# Determine the logfile to generate
- logbase = 'log.{0}.{1}'.format(task, os.getpid())
+ logfmt = localdata.getVar('BB_LOGFMT', True) or 'log.{task}.{pid}'
+ logbase = logfmt.format(task=task, pid=os.getpid())
# Document the order of the tasks...
logorder = os.path.join(tempdir, 'log.task_order')
@@ -336,6 +348,7 @@ def _exec_task(fn, task, d, quieterr):
# Handle logfiles
si = file('/dev/null', 'r')
try:
+ bb.utils.mkdirhier(os.path.dirname(logfn))
logfile = file(logfn, 'w')
except OSError:
logger.exception("Opening log file '%s'", logfn)
@@ -362,6 +375,7 @@ def _exec_task(fn, task, d, quieterr):
bblogger.addHandler(errchk)
localdata.setVar('BB_LOGFILE', logfn)
+ localdata.setVar('BB_RUNTASK', task)
event.fire(TaskStarted(task, localdata), localdata)
try:
--
1.7.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread