diff options
author | Cristiana Voicu <cristiana.voicu@intel.com> | 2013-07-29 11:44:58 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-08-06 13:02:24 +0100 |
commit | bb8a265b0fa61a502c95b830ac82715e6685e2ab (patch) | |
tree | e9b9facdca1126f32037309e21d9dc30253367ea /bitbake | |
parent | 116219ce09c63dfdbf1f57563c6d0b400bd96823 (diff) | |
download | poky-bb8a265b0fa61a502c95b830ac82715e6685e2ab.tar.gz |
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>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/command.py | 5 | ||||
-rw-r--r-- | bitbake/lib/bb/cooker.py | 29 | ||||
-rw-r--r-- | bitbake/lib/bb/data.py | 4 | ||||
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/builder.py | 1 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 11 |
5 files changed, 47 insertions, 3 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py index 5eb34aff3d..33a24406b5 100644 --- a/bitbake/lib/bb/command.py +++ b/bitbake/lib/bb/command.py | |||
@@ -153,7 +153,7 @@ class CommandsSync: | |||
153 | varname = params[0] | 153 | varname = params[0] |
154 | expand = True | 154 | expand = True |
155 | if len(params) > 1: | 155 | if len(params) > 1: |
156 | expand = params[1] | 156 | expand = (params[1] == "True") |
157 | 157 | ||
158 | return command.cooker.data.getVar(varname, expand) | 158 | return command.cooker.data.getVar(varname, expand) |
159 | getVariable.readonly = True | 159 | getVariable.readonly = True |
@@ -230,7 +230,8 @@ class CommandsSync: | |||
230 | var = params[0] | 230 | var = params[0] |
231 | val = params[1] | 231 | val = params[1] |
232 | default_file = params[2] | 232 | default_file = params[2] |
233 | command.cooker.saveConfigurationVar(var, val, default_file) | 233 | op = params[3] |
234 | command.cooker.modifyConfigurationVar(var, val, default_file, op) | ||
234 | 235 | ||
235 | def createConfigFile(self, command, params): | 236 | def createConfigFile(self, command, params): |
236 | """ | 237 | """ |
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 7ca9947df8..a4a6be658d 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -162,6 +162,35 @@ class BBCooker: | |||
162 | self.data = self.databuilder.data | 162 | self.data = self.databuilder.data |
163 | self.data_hash = self.databuilder.data_hash | 163 | self.data_hash = self.databuilder.data_hash |
164 | 164 | ||
165 | def modifyConfigurationVar(self, var, val, default_file, op): | ||
166 | if op == "append": | ||
167 | self.appendConfigurationVar(var, val, default_file) | ||
168 | elif op == "set": | ||
169 | self.saveConfigurationVar(var, val, default_file) | ||
170 | |||
171 | def appendConfigurationVar(self, var, val, default_file): | ||
172 | #add append var operation to the end of default_file | ||
173 | default_file = bb.cookerdata.findConfigFile(default_file) | ||
174 | |||
175 | with open(default_file, 'r') as f: | ||
176 | contents = f.readlines() | ||
177 | f.close() | ||
178 | |||
179 | total = "" | ||
180 | for c in contents: | ||
181 | total += c | ||
182 | |||
183 | total += "#added by bitbake" | ||
184 | total += "\n%s += \"%s\"\n" % (var, val) | ||
185 | |||
186 | with open(default_file, 'w') as f: | ||
187 | f.write(total) | ||
188 | f.close() | ||
189 | |||
190 | #add to history | ||
191 | loginfo = {"op":append, "file":default_file, "line":total.count("\n")} | ||
192 | self.data.appendVar(var, val, **loginfo) | ||
193 | |||
165 | def saveConfigurationVar(self, var, val, default_file): | 194 | def saveConfigurationVar(self, var, val, default_file): |
166 | 195 | ||
167 | replaced = False | 196 | replaced = False |
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py index 87c4808b5e..8c9cb0f025 100644 --- a/bitbake/lib/bb/data.py +++ b/bitbake/lib/bb/data.py | |||
@@ -97,6 +97,10 @@ def delVar(var, d): | |||
97 | """Removes a variable from the data set""" | 97 | """Removes a variable from the data set""" |
98 | d.delVar(var) | 98 | d.delVar(var) |
99 | 99 | ||
100 | def appendVar(var, value, d): | ||
101 | """Append additional value to a variable""" | ||
102 | d.appendVar(var, value) | ||
103 | |||
100 | def setVarFlag(var, flag, flagvalue, d): | 104 | def setVarFlag(var, flag, flagvalue, d): |
101 | """Set a flag for a given variable to a given value""" | 105 | """Set a flag for a given variable to a given value""" |
102 | d.setVarFlag(var, flag, flagvalue) | 106 | d.setVarFlag(var, flag, flagvalue) |
diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py index 6bf402405d..3ddfb36a0c 100755 --- a/bitbake/lib/bb/ui/crumbs/builder.py +++ b/bitbake/lib/bb/ui/crumbs/builder.py | |||
@@ -440,6 +440,7 @@ class Builder(gtk.Window): | |||
440 | self.handler.connect("recipe-populated", self.handler_recipe_populated_cb) | 440 | self.handler.connect("recipe-populated", self.handler_recipe_populated_cb) |
441 | self.handler.connect("package-populated", self.handler_package_populated_cb) | 441 | self.handler.connect("package-populated", self.handler_package_populated_cb) |
442 | 442 | ||
443 | self.handler.append_to_bbfiles("${TOPDIR}/recipes/images/*.bb") | ||
443 | self.initiate_new_build_async() | 444 | self.initiate_new_build_async() |
444 | 445 | ||
445 | signal.signal(signal.SIGINT, self.event_handle_SIGINT) | 446 | signal.signal(signal.SIGINT, self.event_handle_SIGINT) |
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py index 42fd0b972b..7854742d4a 100644 --- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py +++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py | |||
@@ -471,9 +471,18 @@ class HobHandler(gobject.GObject): | |||
471 | 471 | ||
472 | def set_var_in_file(self, var, val, default_file=None): | 472 | def set_var_in_file(self, var, val, default_file=None): |
473 | self.runCommand(["enableDataTracking"]) | 473 | self.runCommand(["enableDataTracking"]) |
474 | self.server.runCommand(["setVarFile", var, val, default_file]) | 474 | self.server.runCommand(["setVarFile", var, val, default_file, "set"]) |
475 | self.runCommand(["disableDataTracking"]) | 475 | self.runCommand(["disableDataTracking"]) |
476 | 476 | ||
477 | def append_var_in_file(self, var, val, default_file=None): | ||
478 | self.server.runCommand(["setVarFile", var, val, default_file, "append"]) | ||
479 | |||
480 | def append_to_bbfiles(self, val): | ||
481 | bbfiles = self.runCommand(["getVariable", "BBFILES", "False"]) or "" | ||
482 | bbfiles = bbfiles.split() | ||
483 | if val not in bbfiles: | ||
484 | self.append_var_in_file("BBFILES", val, "local.conf") | ||
485 | |||
477 | def get_parameters(self): | 486 | def get_parameters(self): |
478 | # retrieve the parameters from bitbake | 487 | # retrieve the parameters from bitbake |
479 | params = {} | 488 | params = {} |