mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 00:39:46 +00:00
bitbake: hob & bitbake: append a value to a variable from hob throught bitbake
It was necessary to append ${TOPDIR}/recipes/images to BBFILES.
Implemented the mechanism to append a value to a variable: a command and
the method in cooker.
[YOCTO #4193]
(Bitbake rev: 4aedbee90bd92395c2460a68702e6ede00e256c9)
Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
116219ce09
commit
bb8a265b0f
@@ -153,7 +153,7 @@ class CommandsSync:
|
|||||||
varname = params[0]
|
varname = params[0]
|
||||||
expand = True
|
expand = True
|
||||||
if len(params) > 1:
|
if len(params) > 1:
|
||||||
expand = params[1]
|
expand = (params[1] == "True")
|
||||||
|
|
||||||
return command.cooker.data.getVar(varname, expand)
|
return command.cooker.data.getVar(varname, expand)
|
||||||
getVariable.readonly = True
|
getVariable.readonly = True
|
||||||
@@ -230,7 +230,8 @@ class CommandsSync:
|
|||||||
var = params[0]
|
var = params[0]
|
||||||
val = params[1]
|
val = params[1]
|
||||||
default_file = params[2]
|
default_file = params[2]
|
||||||
command.cooker.saveConfigurationVar(var, val, default_file)
|
op = params[3]
|
||||||
|
command.cooker.modifyConfigurationVar(var, val, default_file, op)
|
||||||
|
|
||||||
def createConfigFile(self, command, params):
|
def createConfigFile(self, command, params):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -162,6 +162,35 @@ class BBCooker:
|
|||||||
self.data = self.databuilder.data
|
self.data = self.databuilder.data
|
||||||
self.data_hash = self.databuilder.data_hash
|
self.data_hash = self.databuilder.data_hash
|
||||||
|
|
||||||
|
def modifyConfigurationVar(self, var, val, default_file, op):
|
||||||
|
if op == "append":
|
||||||
|
self.appendConfigurationVar(var, val, default_file)
|
||||||
|
elif op == "set":
|
||||||
|
self.saveConfigurationVar(var, val, default_file)
|
||||||
|
|
||||||
|
def appendConfigurationVar(self, var, val, default_file):
|
||||||
|
#add append var operation to the end of default_file
|
||||||
|
default_file = bb.cookerdata.findConfigFile(default_file)
|
||||||
|
|
||||||
|
with open(default_file, 'r') as f:
|
||||||
|
contents = f.readlines()
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
total = ""
|
||||||
|
for c in contents:
|
||||||
|
total += c
|
||||||
|
|
||||||
|
total += "#added by bitbake"
|
||||||
|
total += "\n%s += \"%s\"\n" % (var, val)
|
||||||
|
|
||||||
|
with open(default_file, 'w') as f:
|
||||||
|
f.write(total)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
#add to history
|
||||||
|
loginfo = {"op":append, "file":default_file, "line":total.count("\n")}
|
||||||
|
self.data.appendVar(var, val, **loginfo)
|
||||||
|
|
||||||
def saveConfigurationVar(self, var, val, default_file):
|
def saveConfigurationVar(self, var, val, default_file):
|
||||||
|
|
||||||
replaced = False
|
replaced = False
|
||||||
|
|||||||
@@ -97,6 +97,10 @@ def delVar(var, d):
|
|||||||
"""Removes a variable from the data set"""
|
"""Removes a variable from the data set"""
|
||||||
d.delVar(var)
|
d.delVar(var)
|
||||||
|
|
||||||
|
def appendVar(var, value, d):
|
||||||
|
"""Append additional value to a variable"""
|
||||||
|
d.appendVar(var, value)
|
||||||
|
|
||||||
def setVarFlag(var, flag, flagvalue, d):
|
def setVarFlag(var, flag, flagvalue, d):
|
||||||
"""Set a flag for a given variable to a given value"""
|
"""Set a flag for a given variable to a given value"""
|
||||||
d.setVarFlag(var, flag, flagvalue)
|
d.setVarFlag(var, flag, flagvalue)
|
||||||
|
|||||||
@@ -440,6 +440,7 @@ class Builder(gtk.Window):
|
|||||||
self.handler.connect("recipe-populated", self.handler_recipe_populated_cb)
|
self.handler.connect("recipe-populated", self.handler_recipe_populated_cb)
|
||||||
self.handler.connect("package-populated", self.handler_package_populated_cb)
|
self.handler.connect("package-populated", self.handler_package_populated_cb)
|
||||||
|
|
||||||
|
self.handler.append_to_bbfiles("${TOPDIR}/recipes/images/*.bb")
|
||||||
self.initiate_new_build_async()
|
self.initiate_new_build_async()
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, self.event_handle_SIGINT)
|
signal.signal(signal.SIGINT, self.event_handle_SIGINT)
|
||||||
|
|||||||
@@ -471,9 +471,18 @@ class HobHandler(gobject.GObject):
|
|||||||
|
|
||||||
def set_var_in_file(self, var, val, default_file=None):
|
def set_var_in_file(self, var, val, default_file=None):
|
||||||
self.runCommand(["enableDataTracking"])
|
self.runCommand(["enableDataTracking"])
|
||||||
self.server.runCommand(["setVarFile", var, val, default_file])
|
self.server.runCommand(["setVarFile", var, val, default_file, "set"])
|
||||||
self.runCommand(["disableDataTracking"])
|
self.runCommand(["disableDataTracking"])
|
||||||
|
|
||||||
|
def append_var_in_file(self, var, val, default_file=None):
|
||||||
|
self.server.runCommand(["setVarFile", var, val, default_file, "append"])
|
||||||
|
|
||||||
|
def append_to_bbfiles(self, val):
|
||||||
|
bbfiles = self.runCommand(["getVariable", "BBFILES", "False"]) or ""
|
||||||
|
bbfiles = bbfiles.split()
|
||||||
|
if val not in bbfiles:
|
||||||
|
self.append_var_in_file("BBFILES", val, "local.conf")
|
||||||
|
|
||||||
def get_parameters(self):
|
def get_parameters(self):
|
||||||
# retrieve the parameters from bitbake
|
# retrieve the parameters from bitbake
|
||||||
params = {}
|
params = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user