2013-05-20 21:54:30 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# Copyright (C) 2003, 2004 Chris Larson
|
|
|
|
# Copyright (C) 2003, 2004 Phil Blundell
|
|
|
|
# Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer
|
|
|
|
# Copyright (C) 2005 Holger Hans Peter Freyther
|
|
|
|
# Copyright (C) 2005 ROAD GmbH
|
|
|
|
# Copyright (C) 2006 Richard Purdie
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
import logging
|
2016-04-30 19:52:49 +00:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
from functools import wraps
|
2013-06-07 17:11:09 +00:00
|
|
|
import bb
|
2013-05-20 21:54:30 +00:00
|
|
|
from bb import data
|
2013-06-07 17:11:09 +00:00
|
|
|
import bb.parse
|
2013-05-20 21:54:30 +00:00
|
|
|
|
|
|
|
logger = logging.getLogger("BitBake")
|
|
|
|
parselog = logging.getLogger("BitBake.Parsing")
|
|
|
|
|
|
|
|
class ConfigParameters(object):
|
2015-03-20 13:13:05 +00:00
|
|
|
def __init__(self, argv=sys.argv):
|
|
|
|
self.options, targets = self.parseCommandLine(argv)
|
2013-05-20 21:54:30 +00:00
|
|
|
self.environment = self.parseEnvironment()
|
|
|
|
|
|
|
|
self.options.pkgs_to_build = targets or []
|
|
|
|
|
|
|
|
self.options.tracking = False
|
2013-05-24 09:27:25 +00:00
|
|
|
if hasattr(self.options, "show_environment") and self.options.show_environment:
|
2013-05-20 21:54:30 +00:00
|
|
|
self.options.tracking = True
|
|
|
|
|
|
|
|
for key, val in self.options.__dict__.items():
|
|
|
|
setattr(self, key, val)
|
|
|
|
|
2015-03-20 13:13:05 +00:00
|
|
|
def parseCommandLine(self, argv=sys.argv):
|
2013-05-20 21:54:30 +00:00
|
|
|
raise Exception("Caller must implement commandline option parsing")
|
|
|
|
|
|
|
|
def parseEnvironment(self):
|
|
|
|
return os.environ.copy()
|
|
|
|
|
2013-05-20 21:54:41 +00:00
|
|
|
def updateFromServer(self, server):
|
|
|
|
if not self.options.cmd:
|
|
|
|
defaulttask, error = server.runCommand(["getVariable", "BB_DEFAULT_TASK"])
|
|
|
|
if error:
|
|
|
|
raise Exception("Unable to get the value of BB_DEFAULT_TASK from the server: %s" % error)
|
|
|
|
self.options.cmd = defaulttask or "build"
|
|
|
|
_, error = server.runCommand(["setConfig", "cmd", self.options.cmd])
|
|
|
|
if error:
|
|
|
|
raise Exception("Unable to set configuration option 'cmd' on the server: %s" % error)
|
|
|
|
|
|
|
|
if not self.options.pkgs_to_build:
|
2015-09-29 13:07:59 +00:00
|
|
|
bbpkgs, error = server.runCommand(["getVariable", "BBTARGETS"])
|
2013-05-20 21:54:41 +00:00
|
|
|
if error:
|
2015-09-29 13:07:59 +00:00
|
|
|
raise Exception("Unable to get the value of BBTARGETS from the server: %s" % error)
|
2013-05-20 21:54:41 +00:00
|
|
|
if bbpkgs:
|
|
|
|
self.options.pkgs_to_build.extend(bbpkgs.split())
|
|
|
|
|
2015-01-21 10:49:01 +00:00
|
|
|
def updateToServer(self, server, environment):
|
2014-09-23 11:58:22 +00:00
|
|
|
options = {}
|
|
|
|
for o in ["abort", "tryaltconfigs", "force", "invalidate_stamp",
|
|
|
|
"verbose", "debug", "dry_run", "dump_signatures",
|
2015-08-17 11:12:20 +00:00
|
|
|
"debug_domains", "extra_assume_provided", "profile",
|
|
|
|
"prefile", "postfile"]:
|
2014-09-23 11:58:22 +00:00
|
|
|
options[o] = getattr(self.options, o)
|
|
|
|
|
2015-01-21 10:49:01 +00:00
|
|
|
ret, error = server.runCommand(["updateConfig", options, environment])
|
2014-09-23 11:58:22 +00:00
|
|
|
if error:
|
|
|
|
raise Exception("Unable to update the server configuration with local parameters: %s" % error)
|
|
|
|
|
2013-05-20 21:54:41 +00:00
|
|
|
def parseActions(self):
|
|
|
|
# Parse any commandline into actions
|
|
|
|
action = {'action':None, 'msg':None}
|
|
|
|
if self.options.show_environment:
|
|
|
|
if 'world' in self.options.pkgs_to_build:
|
|
|
|
action['msg'] = "'world' is not a valid target for --environment."
|
|
|
|
elif 'universe' in self.options.pkgs_to_build:
|
|
|
|
action['msg'] = "'universe' is not a valid target for --environment."
|
|
|
|
elif len(self.options.pkgs_to_build) > 1:
|
|
|
|
action['msg'] = "Only one target can be used with the --environment option."
|
|
|
|
elif self.options.buildfile and len(self.options.pkgs_to_build) > 0:
|
|
|
|
action['msg'] = "No target should be used with the --environment and --buildfile options."
|
|
|
|
elif len(self.options.pkgs_to_build) > 0:
|
|
|
|
action['action'] = ["showEnvironmentTarget", self.options.pkgs_to_build]
|
|
|
|
else:
|
|
|
|
action['action'] = ["showEnvironment", self.options.buildfile]
|
|
|
|
elif self.options.buildfile is not None:
|
|
|
|
action['action'] = ["buildFile", self.options.buildfile, self.options.cmd]
|
|
|
|
elif self.options.revisions_changed:
|
|
|
|
action['action'] = ["compareRevisions"]
|
|
|
|
elif self.options.show_versions:
|
|
|
|
action['action'] = ["showVersions"]
|
|
|
|
elif self.options.parse_only:
|
|
|
|
action['action'] = ["parseFiles"]
|
|
|
|
elif self.options.dot_graph:
|
|
|
|
if self.options.pkgs_to_build:
|
|
|
|
action['action'] = ["generateDotGraph", self.options.pkgs_to_build, self.options.cmd]
|
|
|
|
else:
|
|
|
|
action['msg'] = "Please specify a package name for dependency graph generation."
|
|
|
|
else:
|
|
|
|
if self.options.pkgs_to_build:
|
|
|
|
action['action'] = ["buildTargets", self.options.pkgs_to_build, self.options.cmd]
|
|
|
|
else:
|
|
|
|
#action['msg'] = "Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information."
|
|
|
|
action = None
|
|
|
|
self.options.initialaction = action
|
|
|
|
return action
|
|
|
|
|
2013-05-20 21:54:30 +00:00
|
|
|
class CookerConfiguration(object):
|
|
|
|
"""
|
|
|
|
Manages build options and configurations for one run
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.debug_domains = []
|
|
|
|
self.extra_assume_provided = []
|
|
|
|
self.prefile = []
|
|
|
|
self.postfile = []
|
2015-10-16 16:23:58 +00:00
|
|
|
self.prefile_server = []
|
|
|
|
self.postfile_server = []
|
2013-05-20 21:54:30 +00:00
|
|
|
self.debug = 0
|
2013-05-20 21:54:41 +00:00
|
|
|
self.cmd = None
|
2013-05-20 22:01:48 +00:00
|
|
|
self.abort = True
|
|
|
|
self.force = False
|
|
|
|
self.profile = False
|
|
|
|
self.nosetscene = False
|
2016-01-08 18:25:55 +00:00
|
|
|
self.setsceneonly = False
|
2013-05-20 22:01:48 +00:00
|
|
|
self.invalidate_stamp = False
|
2014-03-26 13:46:54 +00:00
|
|
|
self.dump_signatures = []
|
2013-05-20 22:01:48 +00:00
|
|
|
self.dry_run = False
|
2013-05-24 09:27:25 +00:00
|
|
|
self.tracking = False
|
2013-11-25 21:21:26 +00:00
|
|
|
self.interface = []
|
2014-12-09 11:57:38 +00:00
|
|
|
self.writeeventlog = False
|
2016-12-13 07:07:05 +00:00
|
|
|
self.server_only = False
|
2017-01-14 14:16:44 +00:00
|
|
|
self.limited_deps = False
|
2013-05-24 09:27:25 +00:00
|
|
|
|
|
|
|
self.env = {}
|
2013-05-20 21:54:30 +00:00
|
|
|
|
|
|
|
def setConfigParameters(self, parameters):
|
2013-05-20 22:01:48 +00:00
|
|
|
for key in self.__dict__.keys():
|
|
|
|
if key in parameters.options.__dict__:
|
|
|
|
setattr(self, key, parameters.options.__dict__[key])
|
2013-05-24 09:27:25 +00:00
|
|
|
self.env = parameters.environment.copy()
|
|
|
|
self.tracking = parameters.tracking
|
2013-05-20 21:54:30 +00:00
|
|
|
|
|
|
|
def setServerRegIdleCallback(self, srcb):
|
|
|
|
self.server_register_idlecallback = srcb
|
|
|
|
|
2013-06-07 17:11:09 +00:00
|
|
|
def __getstate__(self):
|
|
|
|
state = {}
|
|
|
|
for key in self.__dict__.keys():
|
|
|
|
if key == "server_register_idlecallback":
|
|
|
|
state[key] = None
|
|
|
|
else:
|
|
|
|
state[key] = getattr(self, key)
|
|
|
|
return state
|
|
|
|
|
|
|
|
def __setstate__(self,state):
|
|
|
|
for k in state:
|
|
|
|
setattr(self, k, state[k])
|
|
|
|
|
|
|
|
|
2013-05-20 22:00:31 +00:00
|
|
|
def catch_parse_error(func):
|
|
|
|
"""Exception handling bits for our parsing"""
|
|
|
|
@wraps(func)
|
|
|
|
def wrapped(fn, *args):
|
|
|
|
try:
|
|
|
|
return func(fn, *args)
|
2015-07-31 18:16:45 +00:00
|
|
|
except IOError as exc:
|
2013-06-07 17:11:09 +00:00
|
|
|
import traceback
|
2015-07-31 18:16:45 +00:00
|
|
|
parselog.critical(traceback.format_exc())
|
|
|
|
parselog.critical("Unable to parse %s: %s" % (fn, exc))
|
|
|
|
sys.exit(1)
|
2016-03-28 17:04:10 +00:00
|
|
|
except bb.data_smart.ExpansionError as exc:
|
2015-08-24 22:32:00 +00:00
|
|
|
import traceback
|
|
|
|
|
|
|
|
bbdir = os.path.dirname(__file__) + os.sep
|
|
|
|
exc_class, exc, tb = sys.exc_info()
|
|
|
|
for tb in iter(lambda: tb.tb_next, None):
|
|
|
|
# Skip frames in bitbake itself, we only want the metadata
|
|
|
|
fn, _, _, _ = traceback.extract_tb(tb, 1)[0]
|
|
|
|
if not fn.startswith(bbdir):
|
|
|
|
break
|
2016-05-12 07:13:04 +00:00
|
|
|
parselog.critical("Unable to parse %s" % fn, exc_info=(exc_class, exc, tb))
|
|
|
|
sys.exit(1)
|
2016-03-28 17:04:10 +00:00
|
|
|
except bb.parse.ParseError as exc:
|
|
|
|
parselog.critical(str(exc))
|
2013-05-20 22:00:31 +00:00
|
|
|
sys.exit(1)
|
|
|
|
return wrapped
|
|
|
|
|
|
|
|
@catch_parse_error
|
2013-05-22 14:25:13 +00:00
|
|
|
def parse_config_file(fn, data, include=True):
|
2013-05-20 22:00:31 +00:00
|
|
|
return bb.parse.handle(fn, data, include)
|
|
|
|
|
|
|
|
@catch_parse_error
|
|
|
|
def _inherit(bbclass, data):
|
|
|
|
bb.parse.BBHandler.inherit(bbclass, "configuration INHERITs", 0, data)
|
|
|
|
return data
|
|
|
|
|
2013-08-29 13:27:29 +00:00
|
|
|
def findConfigFile(configfile, data):
|
|
|
|
search = []
|
2016-11-25 15:28:08 +00:00
|
|
|
bbpath = data.getVar("BBPATH")
|
2013-08-29 13:27:29 +00:00
|
|
|
if bbpath:
|
|
|
|
for i in bbpath.split(":"):
|
|
|
|
search.append(os.path.join(i, "conf", configfile))
|
2013-05-20 22:00:31 +00:00
|
|
|
path = os.getcwd()
|
|
|
|
while path != "/":
|
2013-08-29 13:27:29 +00:00
|
|
|
search.append(os.path.join(path, "conf", configfile))
|
2013-05-20 22:00:31 +00:00
|
|
|
path, _ = os.path.split(path)
|
2013-08-29 13:27:29 +00:00
|
|
|
|
|
|
|
for i in search:
|
|
|
|
if os.path.exists(i):
|
|
|
|
return i
|
|
|
|
|
2013-05-20 22:00:31 +00:00
|
|
|
return None
|
|
|
|
|
|
|
|
class CookerDataBuilder(object):
|
|
|
|
|
2013-05-24 09:27:25 +00:00
|
|
|
def __init__(self, cookercfg, worker = False):
|
2013-05-20 22:00:31 +00:00
|
|
|
|
2013-05-24 09:27:25 +00:00
|
|
|
self.prefiles = cookercfg.prefile
|
|
|
|
self.postfiles = cookercfg.postfile
|
|
|
|
self.tracking = cookercfg.tracking
|
2013-05-20 22:00:31 +00:00
|
|
|
|
2013-05-23 09:49:57 +00:00
|
|
|
bb.utils.set_context(bb.utils.clean_context())
|
2013-05-23 09:50:30 +00:00
|
|
|
bb.event.set_class_handlers(bb.event.clean_class_handlers())
|
2016-08-16 16:47:06 +00:00
|
|
|
self.basedata = bb.data.init()
|
2013-05-20 22:00:31 +00:00
|
|
|
if self.tracking:
|
2016-08-16 16:47:06 +00:00
|
|
|
self.basedata.enableTracking()
|
2013-05-20 22:00:31 +00:00
|
|
|
|
|
|
|
# Keep a datastore of the initial environment variables and their
|
|
|
|
# values from when BitBake was launched to enable child processes
|
|
|
|
# to use environment variables which have been cleaned from the
|
|
|
|
# BitBake processes env
|
|
|
|
self.savedenv = bb.data.init()
|
2013-05-24 09:27:25 +00:00
|
|
|
for k in cookercfg.env:
|
|
|
|
self.savedenv.setVar(k, cookercfg.env[k])
|
2013-05-20 22:00:31 +00:00
|
|
|
|
|
|
|
filtered_keys = bb.utils.approved_variables()
|
2016-08-16 16:47:06 +00:00
|
|
|
bb.data.inheritFromOS(self.basedata, self.savedenv, filtered_keys)
|
|
|
|
self.basedata.setVar("BB_ORIGENV", self.savedenv)
|
2013-05-20 22:00:31 +00:00
|
|
|
|
|
|
|
if worker:
|
2016-08-16 16:47:06 +00:00
|
|
|
self.basedata.setVar("BB_WORKERCONTEXT", "1")
|
|
|
|
|
|
|
|
self.data = self.basedata
|
|
|
|
self.mcdata = {}
|
2013-05-20 22:00:31 +00:00
|
|
|
|
|
|
|
def parseBaseConfiguration(self):
|
|
|
|
try:
|
2016-08-16 16:47:06 +00:00
|
|
|
bb.parse.init_parser(self.basedata)
|
|
|
|
self.data = self.parseConfigurationFiles(self.prefiles, self.postfiles)
|
|
|
|
|
|
|
|
if self.data.getVar("BB_WORKERCONTEXT", False) is None:
|
|
|
|
bb.fetch.fetcher_init(self.data)
|
|
|
|
bb.codeparser.parser_cache_init(self.data)
|
|
|
|
|
|
|
|
bb.event.fire(bb.event.ConfigParsed(), self.data)
|
|
|
|
|
2016-09-15 11:20:50 +00:00
|
|
|
reparse_cnt = 0
|
|
|
|
while self.data.getVar("BB_INVALIDCONF", False) is True:
|
|
|
|
if reparse_cnt > 20:
|
|
|
|
logger.error("Configuration has been re-parsed over 20 times, "
|
|
|
|
"breaking out of the loop...")
|
|
|
|
raise Exception("Too deep config re-parse loop. Check locations where "
|
|
|
|
"BB_INVALIDCONF is being set (ConfigParsed event handlers)")
|
2016-08-16 16:47:06 +00:00
|
|
|
self.data.setVar("BB_INVALIDCONF", False)
|
|
|
|
self.data = self.parseConfigurationFiles(self.prefiles, self.postfiles)
|
2016-09-15 11:20:50 +00:00
|
|
|
reparse_cnt += 1
|
2016-09-15 11:20:49 +00:00
|
|
|
bb.event.fire(bb.event.ConfigParsed(), self.data)
|
2016-08-16 16:47:06 +00:00
|
|
|
|
|
|
|
bb.parse.init_parser(self.data)
|
|
|
|
self.data_hash = self.data.get_hash()
|
|
|
|
self.mcdata[''] = self.data
|
|
|
|
|
2016-11-25 15:28:08 +00:00
|
|
|
multiconfig = (self.data.getVar("BBMULTICONFIG") or "").split()
|
2016-08-16 16:47:06 +00:00
|
|
|
for config in multiconfig:
|
2016-12-20 19:02:11 +00:00
|
|
|
mcdata = self.parseConfigurationFiles(self.prefiles, self.postfiles, config)
|
2016-08-16 16:47:06 +00:00
|
|
|
bb.event.fire(bb.event.ConfigParsed(), mcdata)
|
|
|
|
self.mcdata[config] = mcdata
|
|
|
|
|
2016-09-15 20:57:21 +00:00
|
|
|
except (SyntaxError, bb.BBHandledException):
|
2014-05-30 14:53:53 +00:00
|
|
|
raise bb.BBHandledException
|
|
|
|
except bb.data_smart.ExpansionError as e:
|
|
|
|
logger.error(str(e))
|
|
|
|
raise bb.BBHandledException
|
2013-05-20 22:00:31 +00:00
|
|
|
except Exception:
|
|
|
|
logger.exception("Error parsing configuration files")
|
2014-05-30 14:53:53 +00:00
|
|
|
raise bb.BBHandledException
|
2013-05-20 22:00:31 +00:00
|
|
|
|
2013-08-29 13:27:29 +00:00
|
|
|
def _findLayerConf(self, data):
|
|
|
|
return findConfigFile("bblayers.conf", data)
|
2013-05-20 22:00:31 +00:00
|
|
|
|
2016-12-20 19:02:11 +00:00
|
|
|
def parseConfigurationFiles(self, prefiles, postfiles, mc = "default"):
|
2016-08-16 16:47:06 +00:00
|
|
|
data = bb.data.createCopy(self.basedata)
|
2016-12-20 19:02:11 +00:00
|
|
|
data.setVar("BB_CURRENT_MC", mc)
|
2013-05-20 22:00:31 +00:00
|
|
|
|
|
|
|
# Parse files for loading *before* bitbake.conf and any includes
|
|
|
|
for f in prefiles:
|
2013-05-22 14:25:13 +00:00
|
|
|
data = parse_config_file(f, data)
|
2013-05-20 22:00:31 +00:00
|
|
|
|
2013-08-29 13:27:29 +00:00
|
|
|
layerconf = self._findLayerConf(data)
|
2013-05-20 22:00:31 +00:00
|
|
|
if layerconf:
|
|
|
|
parselog.debug(2, "Found bblayers.conf (%s)", layerconf)
|
2013-08-29 13:26:53 +00:00
|
|
|
# By definition bblayers.conf is in conf/ of TOPDIR.
|
|
|
|
# We may have been called with cwd somewhere else so reset TOPDIR
|
|
|
|
data.setVar("TOPDIR", os.path.dirname(os.path.dirname(layerconf)))
|
2013-05-22 14:25:13 +00:00
|
|
|
data = parse_config_file(layerconf, data)
|
2013-05-20 22:00:31 +00:00
|
|
|
|
2016-11-25 15:28:08 +00:00
|
|
|
layers = (data.getVar('BBLAYERS') or "").split()
|
2013-05-20 22:00:31 +00:00
|
|
|
|
|
|
|
data = bb.data.createCopy(data)
|
2015-04-18 15:09:46 +00:00
|
|
|
approved = bb.utils.approved_variables()
|
2013-05-20 22:00:31 +00:00
|
|
|
for layer in layers:
|
2016-05-26 08:05:43 +00:00
|
|
|
if not os.path.isdir(layer):
|
|
|
|
parselog.critical("Layer directory '%s' does not exist! "
|
|
|
|
"Please check BBLAYERS in %s" % (layer, layerconf))
|
|
|
|
sys.exit(1)
|
2013-05-20 22:00:31 +00:00
|
|
|
parselog.debug(2, "Adding layer %s", layer)
|
2015-04-18 15:09:46 +00:00
|
|
|
if 'HOME' in approved and '~' in layer:
|
|
|
|
layer = os.path.expanduser(layer)
|
2016-03-30 09:32:55 +00:00
|
|
|
if layer.endswith('/'):
|
|
|
|
layer = layer.rstrip('/')
|
2013-05-20 22:00:31 +00:00
|
|
|
data.setVar('LAYERDIR', layer)
|
2016-04-30 19:52:49 +00:00
|
|
|
data.setVar('LAYERDIR_RE', re.escape(layer))
|
2013-05-22 14:25:13 +00:00
|
|
|
data = parse_config_file(os.path.join(layer, "conf", "layer.conf"), data)
|
2013-05-20 22:00:31 +00:00
|
|
|
data.expandVarref('LAYERDIR')
|
2016-04-30 19:52:49 +00:00
|
|
|
data.expandVarref('LAYERDIR_RE')
|
2013-05-20 22:00:31 +00:00
|
|
|
|
2016-04-30 19:52:49 +00:00
|
|
|
data.delVar('LAYERDIR_RE')
|
2013-05-20 22:00:31 +00:00
|
|
|
data.delVar('LAYERDIR')
|
|
|
|
|
2016-11-25 15:28:08 +00:00
|
|
|
if not data.getVar("BBPATH"):
|
2013-06-28 09:32:56 +00:00
|
|
|
msg = "The BBPATH variable is not set"
|
|
|
|
if not layerconf:
|
|
|
|
msg += (" and bitbake did not find a conf/bblayers.conf file in"
|
|
|
|
" the expected location.\nMaybe you accidentally"
|
|
|
|
" invoked bitbake from the wrong directory?")
|
|
|
|
raise SystemExit(msg)
|
2013-05-20 22:00:31 +00:00
|
|
|
|
2013-05-22 14:25:13 +00:00
|
|
|
data = parse_config_file(os.path.join("conf", "bitbake.conf"), data)
|
2013-05-20 22:00:31 +00:00
|
|
|
|
|
|
|
# Parse files for loading *after* bitbake.conf and any includes
|
|
|
|
for p in postfiles:
|
2013-05-22 14:25:13 +00:00
|
|
|
data = parse_config_file(p, data)
|
2013-05-20 22:00:31 +00:00
|
|
|
|
|
|
|
# Handle any INHERITs and inherit the base class
|
2016-11-25 15:28:08 +00:00
|
|
|
bbclasses = ["base"] + (data.getVar('INHERIT') or "").split()
|
2013-05-20 22:00:31 +00:00
|
|
|
for bbclass in bbclasses:
|
|
|
|
data = _inherit(bbclass, data)
|
|
|
|
|
|
|
|
# Nomally we only register event handlers at the end of parsing .bb files
|
|
|
|
# We register any handlers we've found so far here...
|
2015-06-18 14:14:19 +00:00
|
|
|
for var in data.getVar('__BBHANDLERS', False) or []:
|
bitbake: ast/event/utils: Improve tracebacks to include file and line numbers more correctly
Currently bitbake tracebacks can have places where the line numbers are
inaccurate and filenames may be missing. These changes start to try and
correct this.
The only way I could find to correct line numbers was to compile as a
python ast, tweak the line numbers then compile to bytecode. I'm open
to better ways of doing this if anyone knows of any.
This does mean passing a few more parameters into functions, and putting
more data into the data store about functions (i.e. their filenames
and line numbers) but the improvement in debugging is more than worthwhile).
Before:
----------------
ERROR: Execution of event handler 'run_buildstats' failed
Traceback (most recent call last):
File "run_buildstats(e)", line 43, in run_buildstats(e=<bb.build.TaskStarted object at 0x7f7b7c57a590>)
NameError: global name 'notexist' is not defined
ERROR: Build of do_patch failed
ERROR: Traceback (most recent call last):
File "/media/build1/poky/bitbake/lib/bb/build.py", line 560, in exec_task
return _exec_task(fn, task, d, quieterr)
File "/media/build1/poky/bitbake/lib/bb/build.py", line 497, in _exec_task
event.fire(TaskStarted(task, logfn, flags, localdata), localdata)
File "/media/build1/poky/bitbake/lib/bb/event.py", line 170, in fire
fire_class_handlers(event, d)
File "/media/build1/poky/bitbake/lib/bb/event.py", line 109, in fire_class_handlers
execute_handler(name, handler, event, d)
File "/media/build1/poky/bitbake/lib/bb/event.py", line 81, in execute_handler
ret = handler(event)
File "run_buildstats(e)", line 43, in run_buildstats
NameError: global name 'notexist' is not defined
----------------
After:
----------------
ERROR: Execution of event handler 'run_buildstats' failed
Traceback (most recent call last):
File "/media/build1/poky/meta/classes/buildstats.bbclass", line 143, in run_buildstats(e=<bb.build.TaskStarted object at 0x7efe89284e10>):
if isinstance(e, bb.build.TaskStarted):
> trigger = notexist
pn = d.getVar("PN", True)
NameError: global name 'notexist' is not defined
ERROR: Build of do_package failed
ERROR: Traceback (most recent call last):
File "/media/build1/poky/bitbake/lib/bb/build.py", line 560, in exec_task
return _exec_task(fn, task, d, quieterr)
File "/media/build1/poky/bitbake/lib/bb/build.py", line 497, in _exec_task
event.fire(TaskStarted(task, logfn, flags, localdata), localdata)
File "/media/build1/poky/bitbake/lib/bb/event.py", line 170, in fire
fire_class_handlers(event, d)
File "/media/build1/poky/bitbake/lib/bb/event.py", line 109, in fire_class_handlers
execute_handler(name, handler, event, d)
File "/media/build1/poky/bitbake/lib/bb/event.py", line 81, in execute_handler
ret = handler(event)
File "/media/build1/poky/meta/classes/buildstats.bbclass", line 143, in run_buildstats
trigger = notexist
NameError: global name 'notexist' is not defined
----------------
(Bitbake rev: 1ff860960919ff6f8097138bc68de85bcb5f88b0)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-12-15 17:41:12 +00:00
|
|
|
handlerfn = data.getVarFlag(var, "filename", False)
|
2016-08-30 09:53:30 +00:00
|
|
|
if not handlerfn:
|
|
|
|
parselog.critical("Undefined event handler function '%s'" % var)
|
|
|
|
sys.exit(1)
|
bitbake: ast/event/utils: Improve tracebacks to include file and line numbers more correctly
Currently bitbake tracebacks can have places where the line numbers are
inaccurate and filenames may be missing. These changes start to try and
correct this.
The only way I could find to correct line numbers was to compile as a
python ast, tweak the line numbers then compile to bytecode. I'm open
to better ways of doing this if anyone knows of any.
This does mean passing a few more parameters into functions, and putting
more data into the data store about functions (i.e. their filenames
and line numbers) but the improvement in debugging is more than worthwhile).
Before:
----------------
ERROR: Execution of event handler 'run_buildstats' failed
Traceback (most recent call last):
File "run_buildstats(e)", line 43, in run_buildstats(e=<bb.build.TaskStarted object at 0x7f7b7c57a590>)
NameError: global name 'notexist' is not defined
ERROR: Build of do_patch failed
ERROR: Traceback (most recent call last):
File "/media/build1/poky/bitbake/lib/bb/build.py", line 560, in exec_task
return _exec_task(fn, task, d, quieterr)
File "/media/build1/poky/bitbake/lib/bb/build.py", line 497, in _exec_task
event.fire(TaskStarted(task, logfn, flags, localdata), localdata)
File "/media/build1/poky/bitbake/lib/bb/event.py", line 170, in fire
fire_class_handlers(event, d)
File "/media/build1/poky/bitbake/lib/bb/event.py", line 109, in fire_class_handlers
execute_handler(name, handler, event, d)
File "/media/build1/poky/bitbake/lib/bb/event.py", line 81, in execute_handler
ret = handler(event)
File "run_buildstats(e)", line 43, in run_buildstats
NameError: global name 'notexist' is not defined
----------------
After:
----------------
ERROR: Execution of event handler 'run_buildstats' failed
Traceback (most recent call last):
File "/media/build1/poky/meta/classes/buildstats.bbclass", line 143, in run_buildstats(e=<bb.build.TaskStarted object at 0x7efe89284e10>):
if isinstance(e, bb.build.TaskStarted):
> trigger = notexist
pn = d.getVar("PN", True)
NameError: global name 'notexist' is not defined
ERROR: Build of do_package failed
ERROR: Traceback (most recent call last):
File "/media/build1/poky/bitbake/lib/bb/build.py", line 560, in exec_task
return _exec_task(fn, task, d, quieterr)
File "/media/build1/poky/bitbake/lib/bb/build.py", line 497, in _exec_task
event.fire(TaskStarted(task, logfn, flags, localdata), localdata)
File "/media/build1/poky/bitbake/lib/bb/event.py", line 170, in fire
fire_class_handlers(event, d)
File "/media/build1/poky/bitbake/lib/bb/event.py", line 109, in fire_class_handlers
execute_handler(name, handler, event, d)
File "/media/build1/poky/bitbake/lib/bb/event.py", line 81, in execute_handler
ret = handler(event)
File "/media/build1/poky/meta/classes/buildstats.bbclass", line 143, in run_buildstats
trigger = notexist
NameError: global name 'notexist' is not defined
----------------
(Bitbake rev: 1ff860960919ff6f8097138bc68de85bcb5f88b0)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-12-15 17:41:12 +00:00
|
|
|
handlerln = int(data.getVarFlag(var, "lineno", False))
|
2016-11-25 15:28:09 +00:00
|
|
|
bb.event.register(var, data.getVar(var, False), (data.getVarFlag(var, "eventmask") or "").split(), handlerfn, handlerln)
|
2013-05-20 22:00:31 +00:00
|
|
|
|
|
|
|
data.setVar('BBINCLUDED',bb.parse.get_file_depends(data))
|
|
|
|
|
2016-08-16 16:47:06 +00:00
|
|
|
return data
|
2013-05-20 22:00:31 +00:00
|
|
|
|