bitbake: bitbake: Add explict getVar param for (non) expansion

Rather than just use d.getVar(X), use the more explict d.getVar(X, False)
since at some point in the future, having the default of expansion would
be nice. This is the first step towards that.

This patch was mostly made using the command:

sed -e 's:\(getVar([^,()]*\)\s*):\1, False):g' -i `grep -ril getVar *`

(Bitbake rev: 659ef95c9b8aced3c4ded81c48bcc0fbde4d429f)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2015-06-18 15:14:19 +01:00
parent 86d30d756a
commit 69b6919341
16 changed files with 63 additions and 63 deletions

View File

@ -287,8 +287,8 @@
<link linkend='var-PN'><filename>PN</filename></link> and <link linkend='var-PN'><filename>PN</filename></link> and
<link linkend='var-PV'><filename>PV</filename></link>: <link linkend='var-PV'><filename>PV</filename></link>:
<literallayout class='monospaced'> <literallayout class='monospaced'>
PN = "${@bb.parse.BBHandler.vars_from_file(d.getVar('FILE'),d)[0] or 'defaultpkgname'}" PN = "${@bb.parse.BBHandler.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
PV = "${@bb.parse.BBHandler.vars_from_file(d.getVar('FILE'),d)[1] or '1.0'}" PV = "${@bb.parse.BBHandler.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
</literallayout> </literallayout>
In this example, a recipe called "something_1.2.3.bb" would set In this example, a recipe called "something_1.2.3.bb" would set
<filename>PN</filename> to "something" and <filename>PN</filename> to "something" and

View File

@ -628,7 +628,7 @@
<literallayout class='monospaced'> <literallayout class='monospaced'>
SRC_URI = "ccrc://cc.example.org/ccrc;vob=/example_vob;module=/example_module" SRC_URI = "ccrc://cc.example.org/ccrc;vob=/example_vob;module=/example_module"
SRCREV = "EXAMPLE_CLEARCASE_TAG" SRCREV = "EXAMPLE_CLEARCASE_TAG"
PV = "${@d.getVar("SRCREV").replace("/", "+")}" PV = "${@d.getVar("SRCREV", False).replace("/", "+")}"
</literallayout> </literallayout>
The fetcher uses the <filename>rcleartool</filename> or The fetcher uses the <filename>rcleartool</filename> or
<filename>cleartool</filename> remote client, depending on <filename>cleartool</filename> remote client, depending on

View File

@ -327,8 +327,8 @@
The following lines select the values of a package name The following lines select the values of a package name
and its version number, respectively: and its version number, respectively:
<literallayout class='monospaced'> <literallayout class='monospaced'>
PN = "${@bb.parse.BBHandler.vars_from_file(d.getVar('FILE'),d)[0] or 'defaultpkgname'}" PN = "${@bb.parse.BBHandler.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
PV = "${@bb.parse.BBHandler.vars_from_file(d.getVar('FILE'),d)[1] or '1.0'}" PV = "${@bb.parse.BBHandler.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
</literallayout> </literallayout>
</para> </para>
</section> </section>
@ -1163,7 +1163,7 @@
<para> <para>
The <filename>BB_ORIGENV</filename> variable returns a datastore The <filename>BB_ORIGENV</filename> variable returns a datastore
object that can be queried using the standard datastore operators object that can be queried using the standard datastore operators
such as <filename>getVar()</filename>. such as <filename>getVar(, False)</filename>.
The datastore object is useful, for example, to find the original The datastore object is useful, for example, to find the original
<filename>DISPLAY</filename> variable. <filename>DISPLAY</filename> variable.
Here is an example: Here is an example:

View File

@ -159,7 +159,7 @@ class LogTee(object):
def exec_func(func, d, dirs = None): def exec_func(func, d, dirs = None):
"""Execute a BB 'function'""" """Execute a BB 'function'"""
body = d.getVar(func) body = d.getVar(func, False)
if not body: if not body:
if body is None: if body is None:
logger.warn("Function %s doesn't exist", func) logger.warn("Function %s doesn't exist", func)
@ -646,7 +646,7 @@ def stampfile(taskname, d, file_name = None):
return stamp_internal(taskname, d, file_name) return stamp_internal(taskname, d, file_name)
def add_tasks(tasklist, deltasklist, d): def add_tasks(tasklist, deltasklist, d):
task_deps = d.getVar('_task_deps') task_deps = d.getVar('_task_deps', False)
if not task_deps: if not task_deps:
task_deps = {} task_deps = {}
if not 'tasks' in task_deps: if not 'tasks' in task_deps:
@ -696,7 +696,7 @@ def addtask(task, before, after, d):
task = "do_" + task task = "do_" + task
d.setVarFlag(task, "task", 1) d.setVarFlag(task, "task", 1)
bbtasks = d.getVar('__BBTASKS') or [] bbtasks = d.getVar('__BBTASKS', False) or []
if not task in bbtasks: if not task in bbtasks:
bbtasks.append(task) bbtasks.append(task)
d.setVar('__BBTASKS', bbtasks) d.setVar('__BBTASKS', bbtasks)
@ -719,7 +719,7 @@ def deltask(task, d):
if task[:3] != "do_": if task[:3] != "do_":
task = "do_" + task task = "do_" + task
bbtasks = d.getVar('__BBDELTASKS') or [] bbtasks = d.getVar('__BBDELTASKS', False) or []
if not task in bbtasks: if not task in bbtasks:
bbtasks.append(task) bbtasks.append(task)
d.setVar('__BBDELTASKS', bbtasks) d.setVar('__BBDELTASKS', bbtasks)

View File

@ -386,7 +386,7 @@ class BBCooker:
replaced = False replaced = False
#do not save if nothing changed #do not save if nothing changed
if str(val) == self.data.getVar(var): if str(val) == self.data.getVar(var, False):
return return
conf_files = self.data.varhistory.get_variable_files(var) conf_files = self.data.varhistory.get_variable_files(var)
@ -398,7 +398,7 @@ class BBCooker:
listval += "%s " % value listval += "%s " % value
val = listval val = listval
topdir = self.data.getVar("TOPDIR") topdir = self.data.getVar("TOPDIR", False)
#comment or replace operations made on var #comment or replace operations made on var
for conf_file in conf_files: for conf_file in conf_files:
@ -453,7 +453,7 @@ class BBCooker:
def removeConfigurationVar(self, var): def removeConfigurationVar(self, var):
conf_files = self.data.varhistory.get_variable_files(var) conf_files = self.data.varhistory.get_variable_files(var)
topdir = self.data.getVar("TOPDIR") topdir = self.data.getVar("TOPDIR", False)
for conf_file in conf_files: for conf_file in conf_files:
if topdir in conf_file: if topdir in conf_file:
@ -493,7 +493,7 @@ class BBCooker:
def parseConfiguration(self): def parseConfiguration(self):
# Set log file verbosity # Set log file verbosity
verboselogs = bb.utils.to_boolean(self.data.getVar("BB_VERBOSE_LOGS", "0")) verboselogs = bb.utils.to_boolean(self.data.getVar("BB_VERBOSE_LOGS", False))
if verboselogs: if verboselogs:
bb.msg.loggerVerboseLogs = True bb.msg.loggerVerboseLogs = True
@ -613,7 +613,7 @@ class BBCooker:
data.expandKeys(envdata) data.expandKeys(envdata)
for e in envdata.keys(): for e in envdata.keys():
if data.getVarFlag( e, 'python', envdata ): if data.getVarFlag( e, 'python', envdata ):
logger.plain("\npython %s () {\n%s}\n", e, data.getVar(e, envdata, 1)) logger.plain("\npython %s () {\n%s}\n", e, envdata.getVar(e, True))
def buildTaskData(self, pkgs_to_build, task, abort): def buildTaskData(self, pkgs_to_build, task, abort):
@ -908,8 +908,8 @@ class BBCooker:
for appends in appends_without_recipes for appends in appends_without_recipes
for append in appends) for append in appends)
msg = 'No recipes available for:\n%s' % '\n'.join(appendlines) msg = 'No recipes available for:\n%s' % '\n'.join(appendlines)
warn_only = data.getVar("BB_DANGLINGAPPENDS_WARNONLY", \ warn_only = self.data.getVar("BB_DANGLINGAPPENDS_WARNONLY", \
self.data, False) or "no" False) or "no"
if warn_only.lower() in ("1", "yes", "true"): if warn_only.lower() in ("1", "yes", "true"):
bb.warn(msg) bb.warn(msg)
else: else:
@ -956,8 +956,8 @@ class BBCooker:
# Generate a list of parsed configuration files by searching the files # Generate a list of parsed configuration files by searching the files
# listed in the __depends and __base_depends variables with a .conf suffix. # listed in the __depends and __base_depends variables with a .conf suffix.
conffiles = [] conffiles = []
dep_files = self.data.getVar('__base_depends') or [] dep_files = self.data.getVar('__base_depends', False) or []
dep_files = dep_files + (self.data.getVar('__depends') or []) dep_files = dep_files + (self.data.getVar('__depends', False) or [])
for f in dep_files: for f in dep_files:
if f[0].endswith(".conf"): if f[0].endswith(".conf"):
@ -1174,7 +1174,7 @@ class BBCooker:
""" """
Setup any variables needed before starting a build Setup any variables needed before starting a build
""" """
if not self.data.getVar("BUILDNAME"): if not self.data.getVar("BUILDNAME", False):
self.data.setVar("BUILDNAME", time.strftime('%Y%m%d%H%M')) self.data.setVar("BUILDNAME", time.strftime('%Y%m%d%H%M'))
self.data.setVar("BUILDSTART", time.strftime('%m/%d/%Y %H:%M:%S', time.gmtime())) self.data.setVar("BUILDSTART", time.strftime('%m/%d/%Y %H:%M:%S', time.gmtime()))
@ -1275,7 +1275,7 @@ class BBCooker:
taskdata = bb.taskdata.TaskData(self.configuration.abort) taskdata = bb.taskdata.TaskData(self.configuration.abort)
taskdata.add_provider(self.data, self.recipecache, item) taskdata.add_provider(self.data, self.recipecache, item)
buildname = self.data.getVar("BUILDNAME") buildname = self.data.getVar("BUILDNAME", False)
bb.event.fire(bb.event.BuildStarted(buildname, [item]), self.expanded_data) bb.event.fire(bb.event.BuildStarted(buildname, [item]), self.expanded_data)
# Execute the runqueue # Execute the runqueue
@ -1348,7 +1348,7 @@ class BBCooker:
taskdata, runlist, fulltargetlist = self.buildTaskData(targets, task, self.configuration.abort) taskdata, runlist, fulltargetlist = self.buildTaskData(targets, task, self.configuration.abort)
buildname = self.data.getVar("BUILDNAME") buildname = self.data.getVar("BUILDNAME", False)
bb.event.fire(bb.event.BuildStarted(buildname, fulltargetlist), self.data) bb.event.fire(bb.event.BuildStarted(buildname, fulltargetlist), self.data)
rq = bb.runqueue.RunQueue(self, self.data, self.recipecache, taskdata, runlist) rq = bb.runqueue.RunQueue(self, self.data, self.recipecache, taskdata, runlist)
@ -1402,7 +1402,7 @@ class BBCooker:
if base_image is None: if base_image is None:
imagefile.write("inherit core-image\n") imagefile.write("inherit core-image\n")
else: else:
topdir = self.data.getVar("TOPDIR") topdir = self.data.getVar("TOPDIR", False)
if topdir in base_image: if topdir in base_image:
base_image = require_line.split()[1] base_image = require_line.split()[1]
imagefile.write("require " + base_image + "\n") imagefile.write("require " + base_image + "\n")
@ -1462,7 +1462,7 @@ class BBCooker:
(filelist, masked) = self.collection.collect_bbfiles(self.data, self.expanded_data) (filelist, masked) = self.collection.collect_bbfiles(self.data, self.expanded_data)
self.data.renameVar("__depends", "__base_depends") self.data.renameVar("__depends", "__base_depends")
self.add_filewatch(self.data.getVar("__base_depends"), self.configwatcher) self.add_filewatch(self.data.getVar("__base_depends", False), self.configwatcher)
self.parser = CookerParser(self, filelist, masked) self.parser = CookerParser(self, filelist, masked)
self.parsecache_valid = True self.parsecache_valid = True

View File

@ -301,15 +301,15 @@ class CookerDataBuilder(object):
# Nomally we only register event handlers at the end of parsing .bb files # Nomally we only register event handlers at the end of parsing .bb files
# We register any handlers we've found so far here... # We register any handlers we've found so far here...
for var in data.getVar('__BBHANDLERS') or []: for var in data.getVar('__BBHANDLERS', False) or []:
bb.event.register(var, data.getVar(var), (data.getVarFlag(var, "eventmask", True) or "").split()) bb.event.register(var, data.getVar(var, False), (data.getVarFlag(var, "eventmask", True) or "").split())
if data.getVar("BB_WORKERCONTEXT", False) is None: if data.getVar("BB_WORKERCONTEXT", False) is None:
bb.fetch.fetcher_init(data) bb.fetch.fetcher_init(data)
bb.codeparser.parser_cache_init(data) bb.codeparser.parser_cache_init(data)
bb.event.fire(bb.event.ConfigParsed(), data) bb.event.fire(bb.event.ConfigParsed(), data)
if data.getVar("BB_INVALIDCONF") is True: if data.getVar("BB_INVALIDCONF", False) is True:
data.setVar("BB_INVALIDCONF", False) data.setVar("BB_INVALIDCONF", False)
self.parseConfigurationFiles(self.prefiles, self.postfiles) self.parseConfigurationFiles(self.prefiles, self.postfiles)
return return

View File

@ -419,7 +419,7 @@ def generate_dependencies(d):
deps = {} deps = {}
values = {} values = {}
tasklist = d.getVar('__BBTASKS') or [] tasklist = d.getVar('__BBTASKS', False) or []
for task in tasklist: for task in tasklist:
deps[task], values[task] = build_dependencies(task, keys, shelldeps, varflagsexcl, d) deps[task], values[task] = build_dependencies(task, keys, shelldeps, varflagsexcl, d)
newdeps = deps[task] newdeps = deps[task]

View File

@ -1003,7 +1003,7 @@ def trusted_network(d, url):
if d.getVar('BB_NO_NETWORK', True) == "1": if d.getVar('BB_NO_NETWORK', True) == "1":
return True return True
pkgname = d.expand(d.getVar('PN')) pkgname = d.expand(d.getVar('PN', False))
trusted_hosts = d.getVarFlag('BB_ALLOWED_NETWORKS', pkgname) trusted_hosts = d.getVarFlag('BB_ALLOWED_NETWORKS', pkgname)
if not trusted_hosts: if not trusted_hosts:

View File

@ -9,7 +9,7 @@ Usage in the recipe:
SRC_URI = "ccrc://cc.example.org/ccrc;vob=/example_vob;module=/example_module" SRC_URI = "ccrc://cc.example.org/ccrc;vob=/example_vob;module=/example_module"
SRCREV = "EXAMPLE_CLEARCASE_TAG" SRCREV = "EXAMPLE_CLEARCASE_TAG"
PV = "${@d.getVar("SRCREV").replace("/", "+")}" PV = "${@d.getVar("SRCREV", False).replace("/", "+")}"
The fetcher uses the rcleartool or cleartool remote client, depending on which one is available. The fetcher uses the rcleartool or cleartool remote client, depending on which one is available.
@ -113,7 +113,7 @@ class ClearCase(FetchMethod):
if data.getVar("SRCREV", d, True) == "INVALID": if data.getVar("SRCREV", d, True) == "INVALID":
raise FetchError("Set a valid SRCREV for the clearcase fetcher in your recipe, e.g. SRCREV = \"/main/LATEST\" or any other label of your choice.") raise FetchError("Set a valid SRCREV for the clearcase fetcher in your recipe, e.g. SRCREV = \"/main/LATEST\" or any other label of your choice.")
ud.label = d.getVar("SRCREV") ud.label = d.getVar("SRCREV", False)
ud.customspec = d.getVar("CCASE_CUSTOM_CONFIG_SPEC", True) ud.customspec = d.getVar("CCASE_CUSTOM_CONFIG_SPEC", True)
ud.server = "%s://%s%s" % (ud.proto, ud.host, ud.path) ud.server = "%s://%s%s" % (ud.proto, ud.host, ud.path)

View File

@ -48,7 +48,7 @@ class Perforce(FetchMethod):
(user, pswd, host, port) = path.split('@')[0].split(":") (user, pswd, host, port) = path.split('@')[0].split(":")
path = path.split('@')[1] path = path.split('@')[1]
else: else:
(host, port) = d.getVar('P4PORT').split(':') (host, port) = d.getVar('P4PORT', False).split(':')
user = "" user = ""
pswd = "" pswd = ""

View File

@ -81,7 +81,7 @@ def update_cache(f):
def mark_dependency(d, f): def mark_dependency(d, f):
if f.startswith('./'): if f.startswith('./'):
f = "%s/%s" % (os.getcwd(), f[2:]) f = "%s/%s" % (os.getcwd(), f[2:])
deps = (d.getVar('__depends') or []) deps = (d.getVar('__depends', False) or [])
s = (f, cached_mtime_noerror(f)) s = (f, cached_mtime_noerror(f))
if s not in deps: if s not in deps:
deps.append(s) deps.append(s)
@ -89,7 +89,7 @@ def mark_dependency(d, f):
def check_dependency(d, f): def check_dependency(d, f):
s = (f, cached_mtime_noerror(f)) s = (f, cached_mtime_noerror(f))
deps = (d.getVar('__depends') or []) deps = (d.getVar('__depends', False) or [])
return s in deps return s in deps
def supports(fn, data): def supports(fn, data):

View File

@ -85,7 +85,7 @@ class DataNode(AstNode):
if 'flag' in self.groupd and self.groupd['flag'] != None: if 'flag' in self.groupd and self.groupd['flag'] != None:
return data.getVarFlag(key, self.groupd['flag'], noweakdefault=True) return data.getVarFlag(key, self.groupd['flag'], noweakdefault=True)
else: else:
return data.getVar(key, noweakdefault=True) return data.getVar(key, False, noweakdefault=True)
def eval(self, data): def eval(self, data):
groupd = self.groupd groupd = self.groupd
@ -152,7 +152,7 @@ class MethodNode(AstNode):
funcname = ("__anon_%s_%s" % (self.lineno, self.filename.translate(MethodNode.tr_tbl))) funcname = ("__anon_%s_%s" % (self.lineno, self.filename.translate(MethodNode.tr_tbl)))
text = "def %s(d):\n" % (funcname) + text text = "def %s(d):\n" % (funcname) + text
bb.methodpool.insert_method(funcname, text, self.filename) bb.methodpool.insert_method(funcname, text, self.filename)
anonfuncs = data.getVar('__BBANONFUNCS') or [] anonfuncs = data.getVar('__BBANONFUNCS', False) or []
anonfuncs.append(funcname) anonfuncs.append(funcname)
data.setVar('__BBANONFUNCS', anonfuncs) data.setVar('__BBANONFUNCS', anonfuncs)
data.setVar(funcname, text) data.setVar(funcname, text)
@ -184,7 +184,7 @@ class MethodFlagsNode(AstNode):
self.m = m self.m = m
def eval(self, data): def eval(self, data):
if data.getVar(self.key): if data.getVar(self.key, False):
# clean up old version of this piece of metadata, as its # clean up old version of this piece of metadata, as its
# flags could cause problems # flags could cause problems
data.setVarFlag(self.key, 'python', None) data.setVarFlag(self.key, 'python', None)
@ -209,10 +209,10 @@ class ExportFuncsNode(AstNode):
for func in self.n: for func in self.n:
calledfunc = self.classname + "_" + func calledfunc = self.classname + "_" + func
if data.getVar(func) and not data.getVarFlag(func, 'export_func'): if data.getVar(func, False) and not data.getVarFlag(func, 'export_func'):
continue continue
if data.getVar(func): if data.getVar(func, False):
data.setVarFlag(func, 'python', None) data.setVarFlag(func, 'python', None)
data.setVarFlag(func, 'func', None) data.setVarFlag(func, 'func', None)
@ -255,7 +255,7 @@ class BBHandlerNode(AstNode):
self.hs = fns.split() self.hs = fns.split()
def eval(self, data): def eval(self, data):
bbhands = data.getVar('__BBHANDLERS') or [] bbhands = data.getVar('__BBHANDLERS', False) or []
for h in self.hs: for h in self.hs:
bbhands.append(h) bbhands.append(h)
data.setVarFlag(h, "handler", 1) data.setVarFlag(h, "handler", 1)
@ -315,22 +315,22 @@ def handleInherit(statements, filename, lineno, m):
def finalize(fn, d, variant = None): def finalize(fn, d, variant = None):
all_handlers = {} all_handlers = {}
for var in d.getVar('__BBHANDLERS') or []: for var in d.getVar('__BBHANDLERS', False) or []:
# try to add the handler # try to add the handler
bb.event.register(var, d.getVar(var), (d.getVarFlag(var, "eventmask", True) or "").split()) bb.event.register(var, d.getVar(var, False), (d.getVarFlag(var, "eventmask", True) or "").split())
bb.event.fire(bb.event.RecipePreFinalise(fn), d) bb.event.fire(bb.event.RecipePreFinalise(fn), d)
bb.data.expandKeys(d) bb.data.expandKeys(d)
bb.data.update_data(d) bb.data.update_data(d)
code = [] code = []
for funcname in d.getVar("__BBANONFUNCS") or []: for funcname in d.getVar("__BBANONFUNCS", False) or []:
code.append("%s(d)" % funcname) code.append("%s(d)" % funcname)
bb.utils.better_exec("\n".join(code), {"d": d}) bb.utils.better_exec("\n".join(code), {"d": d})
bb.data.update_data(d) bb.data.update_data(d)
tasklist = d.getVar('__BBTASKS') or [] tasklist = d.getVar('__BBTASKS', False) or []
deltasklist = d.getVar('__BBDELTASKS') or [] deltasklist = d.getVar('__BBDELTASKS', False) or []
bb.build.add_tasks(tasklist, deltasklist, d) bb.build.add_tasks(tasklist, deltasklist, d)
bb.parse.siggen.finalise(fn, d, variant) bb.parse.siggen.finalise(fn, d, variant)

View File

@ -69,7 +69,7 @@ def supports(fn, d):
return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"] return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"]
def inherit(files, fn, lineno, d): def inherit(files, fn, lineno, d):
__inherit_cache = d.getVar('__inherit_cache') or [] __inherit_cache = d.getVar('__inherit_cache', False) or []
files = d.expand(files).split() files = d.expand(files).split()
for file in files: for file in files:
if not os.path.isabs(file) and not file.endswith(".bbclass"): if not os.path.isabs(file) and not file.endswith(".bbclass"):
@ -89,7 +89,7 @@ def inherit(files, fn, lineno, d):
__inherit_cache.append( file ) __inherit_cache.append( file )
d.setVar('__inherit_cache', __inherit_cache) d.setVar('__inherit_cache', __inherit_cache)
include(fn, file, lineno, d, "inherit") include(fn, file, lineno, d, "inherit")
__inherit_cache = d.getVar('__inherit_cache') or [] __inherit_cache = d.getVar('__inherit_cache', False) or []
def get_statements(filename, absolute_filename, base_name): def get_statements(filename, absolute_filename, base_name):
global cached_statements global cached_statements
@ -129,13 +129,13 @@ def handle(fn, d, include):
if ext == ".bbclass": if ext == ".bbclass":
__classname__ = root __classname__ = root
__inherit_cache = d.getVar('__inherit_cache') or [] __inherit_cache = d.getVar('__inherit_cache', False) or []
if not fn in __inherit_cache: if not fn in __inherit_cache:
__inherit_cache.append(fn) __inherit_cache.append(fn)
d.setVar('__inherit_cache', __inherit_cache) d.setVar('__inherit_cache', __inherit_cache)
if include != 0: if include != 0:
oldfile = d.getVar('FILE') oldfile = d.getVar('FILE', False)
else: else:
oldfile = None oldfile = None

View File

@ -58,7 +58,7 @@ __require_regexp__ = re.compile( r"require\s+(.+)" )
__export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/]+)$" ) __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/]+)$" )
def init(data): def init(data):
topdir = data.getVar('TOPDIR') topdir = data.getVar('TOPDIR', False)
if not topdir: if not topdir:
data.setVar('TOPDIR', os.getcwd()) data.setVar('TOPDIR', os.getcwd())
@ -112,7 +112,7 @@ def handle(fn, data, include):
if include == 0: if include == 0:
oldfile = None oldfile = None
else: else:
oldfile = data.getVar('FILE') oldfile = data.getVar('FILE', False)
abs_fn = resolve_file(fn, data) abs_fn = resolve_file(fn, data)
f = open(abs_fn, 'r') f = open(abs_fn, 'r')

View File

@ -134,12 +134,12 @@ class DataExpansions(unittest.TestCase):
def test_rename(self): def test_rename(self):
self.d.renameVar("foo", "newfoo") self.d.renameVar("foo", "newfoo")
self.assertEqual(self.d.getVar("newfoo"), "value_of_foo") self.assertEqual(self.d.getVar("newfoo", False), "value_of_foo")
self.assertEqual(self.d.getVar("foo"), None) self.assertEqual(self.d.getVar("foo", False), None)
def test_deletion(self): def test_deletion(self):
self.d.delVar("foo") self.d.delVar("foo")
self.assertEqual(self.d.getVar("foo"), None) self.assertEqual(self.d.getVar("foo", False), None)
def test_keys(self): def test_keys(self):
keys = self.d.keys() keys = self.d.keys()
@ -196,28 +196,28 @@ class TestMemoize(unittest.TestCase):
def test_memoized(self): def test_memoized(self):
d = bb.data.init() d = bb.data.init()
d.setVar("FOO", "bar") d.setVar("FOO", "bar")
self.assertTrue(d.getVar("FOO") is d.getVar("FOO")) self.assertTrue(d.getVar("FOO", False) is d.getVar("FOO", False))
def test_not_memoized(self): def test_not_memoized(self):
d1 = bb.data.init() d1 = bb.data.init()
d2 = bb.data.init() d2 = bb.data.init()
d1.setVar("FOO", "bar") d1.setVar("FOO", "bar")
d2.setVar("FOO", "bar2") d2.setVar("FOO", "bar2")
self.assertTrue(d1.getVar("FOO") is not d2.getVar("FOO")) self.assertTrue(d1.getVar("FOO", False) is not d2.getVar("FOO", False))
def test_changed_after_memoized(self): def test_changed_after_memoized(self):
d = bb.data.init() d = bb.data.init()
d.setVar("foo", "value of foo") d.setVar("foo", "value of foo")
self.assertEqual(str(d.getVar("foo")), "value of foo") self.assertEqual(str(d.getVar("foo", False)), "value of foo")
d.setVar("foo", "second value of foo") d.setVar("foo", "second value of foo")
self.assertEqual(str(d.getVar("foo")), "second value of foo") self.assertEqual(str(d.getVar("foo", False)), "second value of foo")
def test_same_value(self): def test_same_value(self):
d = bb.data.init() d = bb.data.init()
d.setVar("foo", "value of") d.setVar("foo", "value of")
d.setVar("bar", "value of") d.setVar("bar", "value of")
self.assertEqual(d.getVar("foo"), self.assertEqual(d.getVar("foo", False),
d.getVar("bar")) d.getVar("bar", False))
class TestConcat(unittest.TestCase): class TestConcat(unittest.TestCase):
def setUp(self): def setUp(self):

View File

@ -309,7 +309,7 @@ class Parameters:
def hob_conf_filter(fn, data): def hob_conf_filter(fn, data):
if fn.endswith("/local.conf"): if fn.endswith("/local.conf"):
distro = data.getVar("DISTRO_HOB") distro = data.getVar("DISTRO_HOB", False)
if distro: if distro:
if distro != "defaultsetup": if distro != "defaultsetup":
data.setVar("DISTRO", distro) data.setVar("DISTRO", distro)
@ -320,13 +320,13 @@ def hob_conf_filter(fn, data):
"BB_NUMBER_THREADS_HOB", "PARALLEL_MAKE_HOB", "DL_DIR_HOB", \ "BB_NUMBER_THREADS_HOB", "PARALLEL_MAKE_HOB", "DL_DIR_HOB", \
"SSTATE_DIR_HOB", "SSTATE_MIRRORS_HOB", "INCOMPATIBLE_LICENSE_HOB"] "SSTATE_DIR_HOB", "SSTATE_MIRRORS_HOB", "INCOMPATIBLE_LICENSE_HOB"]
for key in keys: for key in keys:
var_hob = data.getVar(key) var_hob = data.getVar(key, False)
if var_hob: if var_hob:
data.setVar(key.split("_HOB")[0], var_hob) data.setVar(key.split("_HOB")[0], var_hob)
return return
if fn.endswith("/bblayers.conf"): if fn.endswith("/bblayers.conf"):
layers = data.getVar("BBLAYERS_HOB") layers = data.getVar("BBLAYERS_HOB", False)
if layers: if layers:
data.setVar("BBLAYERS", layers) data.setVar("BBLAYERS", layers)
return return