2005-08-31 10:47:56 +00:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2007-01-08 23:53:01 +00:00
|
|
|
#
|
|
|
|
# BitBake 'Build' implementation
|
|
|
|
#
|
|
|
|
# Core code for function execution and task handling in the
|
|
|
|
# BitBake build tools.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2003, 2004 Chris Larson
|
|
|
|
#
|
|
|
|
# Based on Gentoo's portage.py.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#
|
|
|
|
#Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
from bb import data, event, mkdirhier, utils
|
2010-06-10 17:35:31 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import logging
|
|
|
|
import bb
|
2010-04-11 05:05:02 +00:00
|
|
|
import bb.utils
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2010-06-10 17:35:31 +00:00
|
|
|
logger = logging.getLogger("BitBake.Build")
|
|
|
|
|
2010-03-24 23:56:12 +00:00
|
|
|
# When we execute a python function we'd like certain things
|
2009-10-13 07:25:34 +00:00
|
|
|
# in all namespaces, hence we add them to __builtins__
|
|
|
|
# If we do not do this and use the exec globals, they will
|
|
|
|
# not be available to subfunctions.
|
|
|
|
__builtins__['bb'] = bb
|
|
|
|
__builtins__['os'] = os
|
|
|
|
|
2005-08-31 10:47:56 +00:00
|
|
|
class FuncFailed(Exception):
|
2010-09-10 01:03:40 +00:00
|
|
|
def __init__(self, name, metadata, logfile = None):
|
|
|
|
self.name = name
|
|
|
|
self.metadata = metadata
|
|
|
|
self.logfile = logfile
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
msg = "Function '%s' failed" % self.name
|
|
|
|
if self.logfile:
|
|
|
|
msg += " (see %s for further information)" % self.logfile
|
|
|
|
return msg
|
2005-08-31 10:47:56 +00:00
|
|
|
|
|
|
|
class TaskBase(event.Event):
|
|
|
|
"""Base class for task events"""
|
|
|
|
|
|
|
|
def __init__(self, t, d ):
|
|
|
|
self._task = t
|
2010-01-20 18:46:02 +00:00
|
|
|
self._package = bb.data.getVar("PF", d, 1)
|
|
|
|
event.Event.__init__(self)
|
|
|
|
self._message = "package %s: task %s: %s" % (bb.data.getVar("PF", d, 1), t, bb.event.getName(self)[4:])
|
2005-08-31 10:47:56 +00:00
|
|
|
|
|
|
|
def getTask(self):
|
|
|
|
return self._task
|
|
|
|
|
|
|
|
def setTask(self, task):
|
|
|
|
self._task = task
|
|
|
|
|
|
|
|
task = property(getTask, setTask, None, "task property")
|
|
|
|
|
|
|
|
class TaskStarted(TaskBase):
|
|
|
|
"""Task execution started"""
|
|
|
|
|
|
|
|
class TaskSucceeded(TaskBase):
|
|
|
|
"""Task execution completed"""
|
|
|
|
|
|
|
|
class TaskFailed(TaskBase):
|
|
|
|
"""Task execution failed"""
|
2010-09-10 01:03:40 +00:00
|
|
|
|
|
|
|
def __init__(self, task, logfile, metadata):
|
2010-01-20 18:46:02 +00:00
|
|
|
self.logfile = logfile
|
2010-09-10 01:03:40 +00:00
|
|
|
super(TaskFailed, self).__init__(task, metadata)
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2010-08-16 15:37:29 +00:00
|
|
|
class TaskInvalid(TaskBase):
|
2010-09-10 01:03:40 +00:00
|
|
|
|
|
|
|
def __init__(self, task, metadata):
|
|
|
|
super(TaskInvalid, self).__init__(task, metadata)
|
|
|
|
self._message = "No such task '%s'" % task
|
2005-08-31 10:47:56 +00:00
|
|
|
|
|
|
|
# functions
|
|
|
|
|
|
|
|
def exec_func(func, d, dirs = None):
|
|
|
|
"""Execute an BB 'function'"""
|
|
|
|
|
|
|
|
body = data.getVar(func, d)
|
|
|
|
if not body:
|
2010-08-05 11:40:00 +00:00
|
|
|
bb.warn("Function %s doesn't exist" % func)
|
2005-08-31 10:47:56 +00:00
|
|
|
return
|
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
flags = data.getVarFlags(func, d)
|
2010-08-16 15:37:29 +00:00
|
|
|
for item in ['deps', 'check', 'interactive', 'python', 'cleandirs', 'dirs', 'lockfiles', 'fakeroot', 'task']:
|
2008-03-03 22:01:45 +00:00
|
|
|
if not item in flags:
|
|
|
|
flags[item] = None
|
|
|
|
|
|
|
|
ispython = flags['python']
|
|
|
|
|
2010-04-20 18:53:31 +00:00
|
|
|
cleandirs = flags['cleandirs']
|
|
|
|
if cleandirs:
|
|
|
|
for cdir in data.expand(cleandirs, d).split():
|
|
|
|
os.system("rm -rf %s" % cdir)
|
2007-09-05 08:40:25 +00:00
|
|
|
|
2010-04-20 18:53:31 +00:00
|
|
|
if dirs is None:
|
|
|
|
dirs = flags['dirs']
|
|
|
|
if dirs:
|
|
|
|
dirs = data.expand(dirs, d).split()
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2010-04-20 18:53:31 +00:00
|
|
|
if dirs:
|
|
|
|
for adir in dirs:
|
|
|
|
bb.utils.mkdirhier(adir)
|
2005-08-31 10:47:56 +00:00
|
|
|
adir = dirs[-1]
|
|
|
|
else:
|
|
|
|
adir = data.getVar('B', d, 1)
|
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
# Save current directory
|
2005-08-31 10:47:56 +00:00
|
|
|
try:
|
|
|
|
prevdir = os.getcwd()
|
|
|
|
except OSError:
|
2008-03-03 22:01:45 +00:00
|
|
|
prevdir = data.getVar('TOPDIR', d, True)
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2010-10-11 11:53:54 +00:00
|
|
|
# Setup scriptfile
|
2010-01-20 18:46:02 +00:00
|
|
|
t = data.getVar('T', d, 1)
|
|
|
|
if not t:
|
2010-06-10 16:14:39 +00:00
|
|
|
raise SystemExit("T variable not set, unable to build")
|
2010-04-11 05:05:02 +00:00
|
|
|
bb.utils.mkdirhier(t)
|
2010-01-20 18:46:02 +00:00
|
|
|
runfile = "%s/run.%s.%s" % (t, func, str(os.getpid()))
|
2010-10-11 11:53:54 +00:00
|
|
|
logfile = d.getVar("BB_LOGFILE", True)
|
2010-09-30 20:04:18 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
# Change to correct directory (if specified)
|
2005-08-31 10:47:56 +00:00
|
|
|
if adir and os.access(adir, os.F_OK):
|
|
|
|
os.chdir(adir)
|
|
|
|
|
2007-11-25 14:25:59 +00:00
|
|
|
locks = []
|
2010-04-20 18:53:31 +00:00
|
|
|
lockfiles = flags['lockfiles']
|
|
|
|
if lockfiles:
|
|
|
|
for lock in data.expand(lockfiles, d).split():
|
|
|
|
locks.append(bb.utils.lockfile(lock))
|
2007-11-25 14:25:59 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
try:
|
|
|
|
# Run the function
|
|
|
|
if ispython:
|
|
|
|
exec_func_python(func, d, runfile, logfile)
|
|
|
|
else:
|
|
|
|
exec_func_shell(func, d, runfile, logfile, flags)
|
|
|
|
|
|
|
|
# Restore original directory
|
|
|
|
try:
|
|
|
|
os.chdir(prevdir)
|
|
|
|
except:
|
|
|
|
pass
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
finally:
|
2007-11-25 14:25:59 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
# Unlock any lockfiles
|
|
|
|
for lock in locks:
|
|
|
|
bb.utils.unlockfile(lock)
|
|
|
|
|
|
|
|
def exec_func_python(func, d, runfile, logfile):
|
2005-08-31 10:47:56 +00:00
|
|
|
"""Execute a python BB 'function'"""
|
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
bbfile = bb.data.getVar('FILE', d, 1)
|
2010-03-31 03:06:07 +00:00
|
|
|
tmp = "def " + func + "(d):\n%s" % data.getVar(func, d)
|
|
|
|
tmp += '\n' + func + '(d)'
|
2010-01-20 18:46:02 +00:00
|
|
|
|
|
|
|
f = open(runfile, "w")
|
|
|
|
f.write(tmp)
|
2008-03-03 22:01:45 +00:00
|
|
|
comp = utils.better_compile(tmp, func, bbfile)
|
2010-01-20 18:46:02 +00:00
|
|
|
try:
|
2010-03-31 03:06:07 +00:00
|
|
|
utils.better_exec(comp, {"d": d}, tmp, bbfile)
|
2010-09-10 01:03:40 +00:00
|
|
|
except Exception as exc:
|
|
|
|
if isinstance(exc, (bb.parse.SkipPackage, bb.build.FuncFailed)):
|
2010-01-20 18:46:02 +00:00
|
|
|
raise
|
2010-09-10 01:03:40 +00:00
|
|
|
|
|
|
|
raise FuncFailed(func, d, logfile)
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2010-08-16 15:37:29 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
def exec_func_shell(func, d, runfile, logfile, flags):
|
2005-08-31 10:47:56 +00:00
|
|
|
"""Execute a shell BB 'function' Returns true if execution was successful.
|
|
|
|
|
|
|
|
For this, it creates a bash shell script in the tmp dectory, writes the local
|
|
|
|
data into it and finally executes. The output of the shell will end in a log file and stdout.
|
|
|
|
|
|
|
|
Note on directory behavior. The 'dirs' varflag should contain a list
|
|
|
|
of the directories you need created prior to execution. The last
|
|
|
|
item in the list is where we will chdir/cd to.
|
|
|
|
"""
|
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
deps = flags['deps']
|
|
|
|
check = flags['check']
|
2005-08-31 10:47:56 +00:00
|
|
|
if check in globals():
|
|
|
|
if globals()[check](func, deps):
|
|
|
|
return
|
|
|
|
|
|
|
|
f = open(runfile, "w")
|
|
|
|
f.write("#!/bin/sh -e\n")
|
2010-06-10 17:35:31 +00:00
|
|
|
if logger.getEffectiveLevel() <= logging.DEBUG:
|
|
|
|
f.write("set -x\n")
|
2010-08-03 13:30:20 +00:00
|
|
|
data.emit_func(func, f, d)
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2007-08-03 13:40:52 +00:00
|
|
|
f.write("cd %s\n" % os.getcwd())
|
2005-08-31 10:47:56 +00:00
|
|
|
if func: f.write("%s\n" % func)
|
|
|
|
f.close()
|
|
|
|
os.chmod(runfile, 0775)
|
|
|
|
if not func:
|
2010-09-10 01:03:40 +00:00
|
|
|
raise TypeError("Function argument must be a string")
|
2005-08-31 10:47:56 +00:00
|
|
|
|
|
|
|
# execute function
|
2010-08-16 15:37:29 +00:00
|
|
|
if flags['fakeroot'] and not flags['task']:
|
|
|
|
bb.fatal("Function %s specifies fakeroot but isn't a task?!" % func)
|
|
|
|
|
2007-04-01 15:04:49 +00:00
|
|
|
lang_environment = "LC_ALL=C "
|
2010-08-16 15:37:29 +00:00
|
|
|
ret = os.system('%ssh -e %s' % (lang_environment, runfile))
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
if ret == 0:
|
2005-08-31 10:47:56 +00:00
|
|
|
return
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2010-09-10 01:03:40 +00:00
|
|
|
raise FuncFailed(func, d, logfile)
|
2005-08-31 10:47:56 +00:00
|
|
|
|
|
|
|
|
2010-09-13 14:39:07 +00:00
|
|
|
def exec_task(fn, task, d):
|
2005-08-31 10:47:56 +00:00
|
|
|
"""Execute an BB 'task'
|
|
|
|
|
|
|
|
The primary difference between executing a task versus executing
|
|
|
|
a function is that a task exists in the task digraph, and therefore
|
|
|
|
has dependencies amongst other tasks."""
|
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
# Check whther this is a valid task
|
|
|
|
if not data.getVarFlag(task, 'task', d):
|
2010-08-16 15:37:29 +00:00
|
|
|
event.fire(TaskInvalid(task, d), d)
|
2010-06-10 17:35:31 +00:00
|
|
|
logger.error("No such task: %s" % task)
|
2010-08-16 15:37:29 +00:00
|
|
|
return 1
|
|
|
|
|
|
|
|
quieterr = False
|
|
|
|
if d.getVarFlag(task, "quieterrors") is not None:
|
|
|
|
quieterr = True
|
2008-03-03 22:01:45 +00:00
|
|
|
|
|
|
|
try:
|
2010-06-10 17:35:31 +00:00
|
|
|
logger.debug(1, "Executing task %s", task)
|
2008-03-03 22:01:45 +00:00
|
|
|
old_overrides = data.getVar('OVERRIDES', d, 0)
|
|
|
|
localdata = data.createCopy(d)
|
2008-05-21 21:20:44 +00:00
|
|
|
data.setVar('OVERRIDES', 'task-%s:%s' % (task[3:], old_overrides), localdata)
|
2008-03-03 22:01:45 +00:00
|
|
|
data.update_data(localdata)
|
2008-05-13 11:45:48 +00:00
|
|
|
data.expandKeys(localdata)
|
2010-09-13 14:39:07 +00:00
|
|
|
data.setVar('BB_FILENAME', fn, d)
|
2010-08-05 09:09:13 +00:00
|
|
|
data.setVar('BB_CURRENTTASK', task[3:], d)
|
2010-01-20 18:46:02 +00:00
|
|
|
event.fire(TaskStarted(task, localdata), localdata)
|
2010-10-11 11:53:54 +00:00
|
|
|
|
|
|
|
# Setup logfiles
|
|
|
|
t = data.getVar('T', d, 1)
|
|
|
|
if not t:
|
|
|
|
raise SystemExit("T variable not set, unable to build")
|
|
|
|
bb.utils.mkdirhier(t)
|
|
|
|
loglink = "%s/log.%s" % (t, task)
|
|
|
|
logfile = "%s/log.%s.%s" % (t, task, str(os.getpid()))
|
|
|
|
d.setVar("BB_LOGFILE", logfile)
|
|
|
|
|
|
|
|
# Even though the log file has not yet been opened, lets create the link
|
|
|
|
if loglink:
|
|
|
|
try:
|
|
|
|
os.remove(loglink)
|
|
|
|
except OSError as e:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
os.symlink(logfile, loglink)
|
|
|
|
except OSError as e:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Handle logfiles
|
|
|
|
si = file('/dev/null', 'r')
|
|
|
|
try:
|
|
|
|
so = file(logfile, 'w')
|
2010-06-10 17:35:31 +00:00
|
|
|
except OSError:
|
|
|
|
logger.exception("Opening log file '%s'", logfile)
|
2010-10-11 11:53:54 +00:00
|
|
|
pass
|
|
|
|
se = so
|
|
|
|
|
|
|
|
# Dup the existing fds so we dont lose them
|
|
|
|
osi = [os.dup(sys.stdin.fileno()), sys.stdin.fileno()]
|
|
|
|
oso = [os.dup(sys.stdout.fileno()), sys.stdout.fileno()]
|
|
|
|
ose = [os.dup(sys.stderr.fileno()), sys.stderr.fileno()]
|
|
|
|
|
|
|
|
# Replace those fds with our own
|
|
|
|
os.dup2(si.fileno(), osi[1])
|
|
|
|
os.dup2(so.fileno(), oso[1])
|
|
|
|
os.dup2(se.fileno(), ose[1])
|
|
|
|
|
|
|
|
# Since we've remapped stdout and stderr, its safe for log messages to be printed there now
|
|
|
|
# exec_func can nest so we have to save state
|
|
|
|
origstdout = bb.event.useStdout
|
|
|
|
bb.event.useStdout = True
|
|
|
|
|
|
|
|
|
2010-08-04 10:30:39 +00:00
|
|
|
prefuncs = (data.getVarFlag(task, 'prefuncs', localdata) or "").split()
|
|
|
|
for func in prefuncs:
|
|
|
|
exec_func(func, localdata)
|
2008-03-03 22:01:45 +00:00
|
|
|
exec_func(task, localdata)
|
2010-08-04 10:30:39 +00:00
|
|
|
postfuncs = (data.getVarFlag(task, 'postfuncs', localdata) or "").split()
|
|
|
|
for func in postfuncs:
|
|
|
|
exec_func(func, localdata)
|
2010-10-11 11:53:54 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
event.fire(TaskSucceeded(task, localdata), localdata)
|
2010-08-16 15:37:29 +00:00
|
|
|
|
|
|
|
# make stamp, or cause event and raise exception
|
|
|
|
if not data.getVarFlag(task, 'nostamp', d) and not data.getVarFlag(task, 'selfstamp', d):
|
|
|
|
make_stamp(task, d)
|
|
|
|
|
2010-09-10 01:03:40 +00:00
|
|
|
except FuncFailed as exc:
|
2010-08-16 15:37:29 +00:00
|
|
|
if not quieterr:
|
2010-09-10 01:03:40 +00:00
|
|
|
logger.error(str(exc))
|
|
|
|
failedevent = TaskFailed(exc.name, exc.logfile, task, d)
|
2010-08-16 15:37:29 +00:00
|
|
|
event.fire(failedevent, d)
|
|
|
|
return 1
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
from traceback import format_exc
|
|
|
|
if not quieterr:
|
2010-06-10 17:35:31 +00:00
|
|
|
logger.error("Build of %s failed" % (task))
|
|
|
|
logger.error(format_exc())
|
2010-08-16 15:37:29 +00:00
|
|
|
failedevent = TaskFailed("Task Failed", None, task, d)
|
|
|
|
event.fire(failedevent, d)
|
|
|
|
return 1
|
2010-10-11 11:53:54 +00:00
|
|
|
finally:
|
|
|
|
sys.stdout.flush()
|
|
|
|
sys.stderr.flush()
|
|
|
|
|
|
|
|
bb.event.useStdout = origstdout
|
|
|
|
|
|
|
|
# Restore the backup fds
|
|
|
|
os.dup2(osi[0], osi[1])
|
|
|
|
os.dup2(oso[0], oso[1])
|
|
|
|
os.dup2(ose[0], ose[1])
|
|
|
|
|
|
|
|
# Close our logs
|
|
|
|
si.close()
|
|
|
|
so.close()
|
|
|
|
se.close()
|
|
|
|
|
|
|
|
if logfile and os.path.exists(logfile) and os.path.getsize(logfile) == 0:
|
2010-06-10 17:35:31 +00:00
|
|
|
logger.debug(2, "Zero size logfile %s, removing", logfile)
|
2010-10-11 11:53:54 +00:00
|
|
|
os.remove(logfile)
|
|
|
|
try:
|
|
|
|
os.remove(loglink)
|
|
|
|
except OSError as e:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Close the backup fds
|
|
|
|
os.close(osi[0])
|
|
|
|
os.close(oso[0])
|
|
|
|
os.close(ose[0])
|
2010-08-16 15:37:29 +00:00
|
|
|
|
|
|
|
return 0
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2007-01-08 23:53:01 +00:00
|
|
|
def extract_stamp(d, fn):
|
|
|
|
"""
|
2010-08-03 15:02:43 +00:00
|
|
|
Extracts stamp format which is either a data dictionary (fn unset)
|
2010-03-24 23:56:12 +00:00
|
|
|
or a dataCache entry (fn set).
|
2007-01-08 23:53:01 +00:00
|
|
|
"""
|
|
|
|
if fn:
|
|
|
|
return d.stamp[fn]
|
|
|
|
return data.getVar('STAMP', d, 1)
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2007-01-08 23:53:01 +00:00
|
|
|
def stamp_internal(task, d, file_name):
|
|
|
|
"""
|
|
|
|
Internal stamp helper function
|
|
|
|
Removes any stamp for the given task
|
|
|
|
Makes sure the stamp directory exists
|
|
|
|
Returns the stamp path+filename
|
|
|
|
"""
|
|
|
|
stamp = extract_stamp(d, file_name)
|
2005-08-31 10:47:56 +00:00
|
|
|
if not stamp:
|
|
|
|
return
|
2007-01-08 23:53:01 +00:00
|
|
|
stamp = "%s.%s" % (stamp, task)
|
2010-04-11 05:05:02 +00:00
|
|
|
bb.utils.mkdirhier(os.path.dirname(stamp))
|
2006-08-30 21:26:07 +00:00
|
|
|
# Remove the file and recreate to force timestamp
|
|
|
|
# change on broken NFS filesystems
|
|
|
|
if os.access(stamp, os.F_OK):
|
|
|
|
os.remove(stamp)
|
2007-01-08 23:53:01 +00:00
|
|
|
return stamp
|
|
|
|
|
|
|
|
def make_stamp(task, d, file_name = None):
|
|
|
|
"""
|
|
|
|
Creates/updates a stamp for a given task
|
|
|
|
(d can be a data dict or dataCache)
|
|
|
|
"""
|
|
|
|
stamp = stamp_internal(task, d, file_name)
|
|
|
|
if stamp:
|
|
|
|
f = open(stamp, "w")
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
def del_stamp(task, d, file_name = None):
|
|
|
|
"""
|
|
|
|
Removes a stamp for a given task
|
|
|
|
(d can be a data dict or dataCache)
|
|
|
|
"""
|
|
|
|
stamp_internal(task, d, file_name)
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2007-08-20 07:48:43 +00:00
|
|
|
def add_tasks(tasklist, d):
|
|
|
|
task_deps = data.getVar('_task_deps', d)
|
2006-11-16 15:02:15 +00:00
|
|
|
if not task_deps:
|
|
|
|
task_deps = {}
|
2008-03-03 22:01:45 +00:00
|
|
|
if not 'tasks' in task_deps:
|
|
|
|
task_deps['tasks'] = []
|
|
|
|
if not 'parents' in task_deps:
|
|
|
|
task_deps['parents'] = {}
|
2006-11-16 15:02:15 +00:00
|
|
|
|
2007-08-20 07:48:43 +00:00
|
|
|
for task in tasklist:
|
|
|
|
task = data.expand(task, d)
|
|
|
|
data.setVarFlag(task, 'task', 1, d)
|
2008-03-03 22:01:45 +00:00
|
|
|
|
|
|
|
if not task in task_deps['tasks']:
|
|
|
|
task_deps['tasks'].append(task)
|
2007-08-20 07:48:43 +00:00
|
|
|
|
2010-03-24 23:56:12 +00:00
|
|
|
flags = data.getVarFlags(task, d)
|
2007-08-20 07:48:43 +00:00
|
|
|
def getTask(name):
|
2008-03-03 22:01:45 +00:00
|
|
|
if not name in task_deps:
|
|
|
|
task_deps[name] = {}
|
2007-08-20 07:48:43 +00:00
|
|
|
if name in flags:
|
|
|
|
deptask = data.expand(flags[name], d)
|
|
|
|
task_deps[name][task] = deptask
|
|
|
|
getTask('depends')
|
|
|
|
getTask('deptask')
|
|
|
|
getTask('rdeptask')
|
|
|
|
getTask('recrdeptask')
|
|
|
|
getTask('nostamp')
|
2010-08-16 15:37:29 +00:00
|
|
|
getTask('fakeroot')
|
2010-11-06 14:33:05 +00:00
|
|
|
getTask('noexec')
|
2008-03-03 22:01:45 +00:00
|
|
|
task_deps['parents'][task] = []
|
|
|
|
for dep in flags['deps']:
|
|
|
|
dep = data.expand(dep, d)
|
|
|
|
task_deps['parents'][task].append(dep)
|
2007-08-20 07:48:43 +00:00
|
|
|
|
|
|
|
# don't assume holding a reference
|
2006-11-16 15:02:15 +00:00
|
|
|
data.setVar('_task_deps', task_deps, d)
|
2005-08-31 10:47:56 +00:00
|
|
|
|
|
|
|
def remove_task(task, kill, d):
|
|
|
|
"""Remove an BB 'task'.
|
|
|
|
|
|
|
|
If kill is 1, also remove tasks that depend on this task."""
|
|
|
|
|
|
|
|
data.delVarFlag(task, 'task', d)
|