diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/command.py | 18 | ||||
-rw-r--r-- | bitbake/lib/bb/cooker.py | 89 | ||||
-rw-r--r-- | bitbake/lib/bb/data_smart.py | 22 | ||||
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/builder.py | 32 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 5 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/template.py | 24 |
6 files changed, 153 insertions, 37 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py index 0fed25a3ed..59336bbee7 100644 --- a/bitbake/lib/bb/command.py +++ b/bitbake/lib/bb/command.py | |||
@@ -174,6 +174,18 @@ class CommandsSync: | |||
174 | value = str(params[1]) | 174 | value = str(params[1]) |
175 | command.cooker.configuration.data.setVar(varname, value) | 175 | command.cooker.configuration.data.setVar(varname, value) |
176 | 176 | ||
177 | def enableDataTracking(self, command, params): | ||
178 | """ | ||
179 | Enable history tracking for variables | ||
180 | """ | ||
181 | command.cooker.enableDataTracking() | ||
182 | |||
183 | def disableDataTracking(self, command, params): | ||
184 | """ | ||
185 | Disable history tracking for variables | ||
186 | """ | ||
187 | command.cooker.disableDataTracking() | ||
188 | |||
177 | def initCooker(self, command, params): | 189 | def initCooker(self, command, params): |
178 | """ | 190 | """ |
179 | Init the cooker to initial state with nothing parsed | 191 | Init the cooker to initial state with nothing parsed |
@@ -210,6 +222,12 @@ class CommandsSync: | |||
210 | package_queue = params[2] | 222 | package_queue = params[2] |
211 | return command.cooker.generateNewImage(image, base_image, package_queue) | 223 | return command.cooker.generateNewImage(image, base_image, package_queue) |
212 | 224 | ||
225 | def setVarFile(self, command, params): | ||
226 | var = params[0] | ||
227 | val = params[1] | ||
228 | default_file = params[2] | ||
229 | command.cooker.saveConfigurationVar(var, val, default_file) | ||
230 | |||
213 | class CommandsAsync: | 231 | class CommandsAsync: |
214 | """ | 232 | """ |
215 | A class of asynchronous commands | 233 | A class of asynchronous commands |
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 80710fb97d..34fbfb0701 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -186,6 +186,12 @@ class BBCooker: | |||
186 | filtered_keys = bb.utils.approved_variables() | 186 | filtered_keys = bb.utils.approved_variables() |
187 | bb.data.inheritFromOS(self.configuration.data, self.savedenv, filtered_keys) | 187 | bb.data.inheritFromOS(self.configuration.data, self.savedenv, filtered_keys) |
188 | 188 | ||
189 | def enableDataTracking(self): | ||
190 | self.configuration.data.enableTracking() | ||
191 | |||
192 | def disableDataTracking(self): | ||
193 | self.configuration.data.disableTracking() | ||
194 | |||
189 | def loadConfigurationData(self): | 195 | def loadConfigurationData(self): |
190 | self.initConfigurationData() | 196 | self.initConfigurationData() |
191 | 197 | ||
@@ -201,6 +207,89 @@ class BBCooker: | |||
201 | if not self.configuration.cmd: | 207 | if not self.configuration.cmd: |
202 | self.configuration.cmd = self.configuration.data.getVar("BB_DEFAULT_TASK", True) or "build" | 208 | self.configuration.cmd = self.configuration.data.getVar("BB_DEFAULT_TASK", True) or "build" |
203 | 209 | ||
210 | def saveConfigurationVar(self, var, val, default_file): | ||
211 | |||
212 | replaced = False | ||
213 | #do not save if nothing changed | ||
214 | if str(val) == self.configuration.data.getVar(var): | ||
215 | return | ||
216 | |||
217 | conf_files = self.configuration.data.varhistory.get_variable_files(var) | ||
218 | |||
219 | #format the value when it is a list | ||
220 | if isinstance(val, list): | ||
221 | listval = "" | ||
222 | for value in val: | ||
223 | listval += "%s " % value | ||
224 | val = listval | ||
225 | |||
226 | topdir = self.configuration.data.getVar("TOPDIR") | ||
227 | |||
228 | #comment or replace operations made on var | ||
229 | for conf_file in conf_files: | ||
230 | if topdir in conf_file: | ||
231 | with open(conf_file, 'r') as f: | ||
232 | contents = f.readlines() | ||
233 | f.close() | ||
234 | |||
235 | lines = self.configuration.data.varhistory.get_variable_lines(var, conf_file) | ||
236 | for line in lines: | ||
237 | total = "" | ||
238 | i = 0 | ||
239 | for c in contents: | ||
240 | total += c | ||
241 | i = i + 1 | ||
242 | if i==int(line): | ||
243 | end_index = len(total) | ||
244 | index = total.rfind(var, 0, end_index) | ||
245 | |||
246 | begin_line = total.count("\n",0,index) | ||
247 | end_line = int(line) | ||
248 | |||
249 | #check if the variable was saved before in the same way | ||
250 | #if true it replace the place where the variable was declared | ||
251 | #else it comments it | ||
252 | if contents[begin_line-1]== "#added by bitbake\n": | ||
253 | contents[begin_line] = "%s = \"%s\"\n" % (var, val) | ||
254 | replaced = True | ||
255 | else: | ||
256 | for ii in range(begin_line, end_line): | ||
257 | contents[ii] = "#" + contents[ii] | ||
258 | |||
259 | total = "" | ||
260 | for c in contents: | ||
261 | total += c | ||
262 | with open(conf_file, 'w') as f: | ||
263 | f.write(total) | ||
264 | f.close() | ||
265 | |||
266 | if replaced == False: | ||
267 | #remove var from history | ||
268 | self.configuration.data.varhistory.del_var_history(var) | ||
269 | |||
270 | #add var to the end of default_file | ||
271 | default_file = self._findConfigFile(default_file) | ||
272 | |||
273 | with open(default_file, 'r') as f: | ||
274 | contents = f.readlines() | ||
275 | f.close() | ||
276 | |||
277 | total = "" | ||
278 | for c in contents: | ||
279 | total += c | ||
280 | |||
281 | #add the variable on a single line, to be easy to replace the second time | ||
282 | total += "#added by bitbake" | ||
283 | total += "\n%s = \"%s\"\n" % (var, val) | ||
284 | |||
285 | with open(default_file, 'w') as f: | ||
286 | f.write(total) | ||
287 | f.close() | ||
288 | |||
289 | #add to history | ||
290 | loginfo = {"op":set, "file":default_file, "line":total.count("\n")} | ||
291 | self.configuration.data.setVar(var, val, **loginfo) | ||
292 | |||
204 | def parseConfiguration(self): | 293 | def parseConfiguration(self): |
205 | 294 | ||
206 | # Set log file verbosity | 295 | # Set log file verbosity |
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index ddf98e6a2e..5bf11e5e0d 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py | |||
@@ -259,6 +259,27 @@ class VariableHistory(object): | |||
259 | o.write("#\n# $%s\n# [no history recorded]\n#\n" % var) | 259 | o.write("#\n# $%s\n# [no history recorded]\n#\n" % var) |
260 | o.write('# "%s"\n' % (commentVal)) | 260 | o.write('# "%s"\n' % (commentVal)) |
261 | 261 | ||
262 | def get_variable_files(self, var): | ||
263 | """Get the files where operations are made on a variable""" | ||
264 | var_history = self.variable(var) | ||
265 | files = [] | ||
266 | for event in var_history: | ||
267 | files.append(event['file']) | ||
268 | return files | ||
269 | |||
270 | def get_variable_lines(self, var, f): | ||
271 | """Get the line where a operation is made on a variable in file f""" | ||
272 | var_history = self.variable(var) | ||
273 | lines = [] | ||
274 | for event in var_history: | ||
275 | if f== event['file']: | ||
276 | line = event['line'] | ||
277 | lines.append(line) | ||
278 | return lines | ||
279 | |||
280 | def del_var_history(self, var): | ||
281 | if var in self.variables: | ||
282 | self.variables[var] = [] | ||
262 | 283 | ||
263 | class DataSmart(MutableMapping): | 284 | class DataSmart(MutableMapping): |
264 | def __init__(self, special = COWDictBase.copy(), seen = COWDictBase.copy() ): | 285 | def __init__(self, special = COWDictBase.copy(), seen = COWDictBase.copy() ): |
@@ -429,6 +450,7 @@ class DataSmart(MutableMapping): | |||
429 | 450 | ||
430 | 451 | ||
431 | def setVar(self, var, value, **loginfo): | 452 | def setVar(self, var, value, **loginfo): |
453 | #print("var=" + str(var) + " val=" + str(value)) | ||
432 | if 'op' not in loginfo: | 454 | if 'op' not in loginfo: |
433 | loginfo['op'] = "set" | 455 | loginfo['op'] = "set" |
434 | self.expand_cache = {} | 456 | self.expand_cache = {} |
diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py index 9da926dd14..e9cfa2197c 100755 --- a/bitbake/lib/bb/ui/crumbs/builder.py +++ b/bitbake/lib/bb/ui/crumbs/builder.py | |||
@@ -217,26 +217,32 @@ class Configuration: | |||
217 | self.split_proxy("git", template.getVar("GIT_PROXY_HOST") + ":" + template.getVar("GIT_PROXY_PORT")) | 217 | self.split_proxy("git", template.getVar("GIT_PROXY_HOST") + ":" + template.getVar("GIT_PROXY_PORT")) |
218 | self.split_proxy("cvs", template.getVar("CVS_PROXY_HOST") + ":" + template.getVar("CVS_PROXY_PORT")) | 218 | self.split_proxy("cvs", template.getVar("CVS_PROXY_HOST") + ":" + template.getVar("CVS_PROXY_PORT")) |
219 | 219 | ||
220 | def save(self, template, defaults=False): | 220 | def save(self, handler, template, defaults=False): |
221 | template.setVar("VERSION", "%s" % hobVer) | 221 | template.setVar("VERSION", "%s" % hobVer) |
222 | # bblayers.conf | 222 | # bblayers.conf |
223 | template.setVar("BBLAYERS", " ".join(self.layers)) | 223 | handler.set_var_in_file("BBLAYERS", self.layers, "bblayers.conf") |
224 | # local.conf | 224 | # local.conf |
225 | if not defaults: | 225 | if not defaults: |
226 | template.setVar("MACHINE", self.curr_mach) | 226 | handler.set_var_in_file("MACHINE", self.curr_mach, "local.conf") |
227 | template.setVar("DISTRO", self.curr_distro) | 227 | handler.set_var_in_file("DISTRO", self.curr_distro, "local.conf") |
228 | template.setVar("DL_DIR", self.dldir) | 228 | handler.set_var_in_file("DL_DIR", self.dldir, "local.conf") |
229 | template.setVar("SSTATE_DIR", self.sstatedir) | 229 | handler.set_var_in_file("SSTATE_DIR", self.sstatedir, "local.conf") |
230 | template.setVar("SSTATE_MIRRORS", self.sstatemirror) | 230 | sstate_mirror_list = self.sstatemirror.split("\\n ") |
231 | template.setVar("PARALLEL_MAKE", "-j %s" % self.pmake) | 231 | sstate_mirror_list_modified = [] |
232 | template.setVar("BB_NUMBER_THREADS", self.bbthread) | 232 | for mirror in sstate_mirror_list: |
233 | template.setVar("PACKAGE_CLASSES", " ".join(["package_" + i for i in self.curr_package_format.split()])) | 233 | if mirror != "": |
234 | mirror = mirror + "\\n" | ||
235 | sstate_mirror_list_modified.append(mirror) | ||
236 | handler.set_var_in_file("SSTATE_MIRRORS", sstate_mirror_list_modified, "local.conf") | ||
237 | handler.set_var_in_file("PARALLEL_MAKE", "-j %s" % self.pmake, "local.conf") | ||
238 | handler.set_var_in_file("BB_NUMBER_THREADS", self.bbthread, "local.conf") | ||
239 | handler.set_var_in_file("PACKAGE_CLASSES", " ".join(["package_" + i for i in self.curr_package_format.split()]), "local.conf") | ||
234 | template.setVar("IMAGE_ROOTFS_SIZE", self.image_rootfs_size) | 240 | template.setVar("IMAGE_ROOTFS_SIZE", self.image_rootfs_size) |
235 | template.setVar("IMAGE_EXTRA_SPACE", self.image_extra_size) | 241 | template.setVar("IMAGE_EXTRA_SPACE", self.image_extra_size) |
236 | template.setVar("INCOMPATIBLE_LICENSE", self.incompat_license) | 242 | template.setVar("INCOMPATIBLE_LICENSE", self.incompat_license) |
237 | template.setVar("SDKMACHINE", self.curr_sdk_machine) | 243 | template.setVar("SDKMACHINE", self.curr_sdk_machine) |
238 | template.setVar("CONF_VERSION", self.conf_version) | 244 | handler.set_var_in_file("CONF_VERSION", self.conf_version, "local.conf") |
239 | template.setVar("LCONF_VERSION", self.lconf_version) | 245 | handler.set_var_in_file("LCONF_VERSION", self.lconf_version, "bblayers.conf") |
240 | template.setVar("EXTRA_SETTING", self.extra_setting) | 246 | template.setVar("EXTRA_SETTING", self.extra_setting) |
241 | template.setVar("TOOLCHAIN_BUILD", self.toolchain_build) | 247 | template.setVar("TOOLCHAIN_BUILD", self.toolchain_build) |
242 | template.setVar("IMAGE_FSTYPES", self.image_fstypes) | 248 | template.setVar("IMAGE_FSTYPES", self.image_fstypes) |
@@ -670,7 +676,7 @@ class Builder(gtk.Window): | |||
670 | self.template = TemplateMgr() | 676 | self.template = TemplateMgr() |
671 | try: | 677 | try: |
672 | self.template.open(filename, path) | 678 | self.template.open(filename, path) |
673 | self.configuration.save(self.template, defaults) | 679 | self.configuration.save(self.handler, self.template, defaults) |
674 | 680 | ||
675 | self.template.save() | 681 | self.template.save() |
676 | except Exception as e: | 682 | except Exception as e: |
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py index 41022ef8eb..d953f3497c 100644 --- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py +++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py | |||
@@ -146,7 +146,9 @@ class HobHandler(gobject.GObject): | |||
146 | elif next_command == self.SUB_MATCH_CLASS: | 146 | elif next_command == self.SUB_MATCH_CLASS: |
147 | self.runCommand(["findFilesMatchingInDir", "rootfs_", "classes"]) | 147 | self.runCommand(["findFilesMatchingInDir", "rootfs_", "classes"]) |
148 | elif next_command == self.SUB_PARSE_CONFIG: | 148 | elif next_command == self.SUB_PARSE_CONFIG: |
149 | self.runCommand(["enableDataTracking"]) | ||
149 | self.runCommand(["parseConfigurationFiles", "", ""]) | 150 | self.runCommand(["parseConfigurationFiles", "", ""]) |
151 | self.runCommand(["disableDataTracking"]) | ||
150 | elif next_command == self.SUB_GNERATE_TGTS: | 152 | elif next_command == self.SUB_GNERATE_TGTS: |
151 | self.runCommand(["generateTargetsTree", "classes/image.bbclass", []]) | 153 | self.runCommand(["generateTargetsTree", "classes/image.bbclass", []]) |
152 | elif next_command == self.SUB_GENERATE_PKGINFO: | 154 | elif next_command == self.SUB_GENERATE_PKGINFO: |
@@ -451,6 +453,9 @@ class HobHandler(gobject.GObject): | |||
451 | ret.append(i) | 453 | ret.append(i) |
452 | return " ".join(ret) | 454 | return " ".join(ret) |
453 | 455 | ||
456 | def set_var_in_file(self, var, val, default_file=None): | ||
457 | self.server.runCommand(["setVarFile", var, val, default_file]) | ||
458 | |||
454 | def get_parameters(self): | 459 | def get_parameters(self): |
455 | # retrieve the parameters from bitbake | 460 | # retrieve the parameters from bitbake |
456 | params = {} | 461 | params = {} |
diff --git a/bitbake/lib/bb/ui/crumbs/template.py b/bitbake/lib/bb/ui/crumbs/template.py index e303c3a6b8..92c438f000 100644 --- a/bitbake/lib/bb/ui/crumbs/template.py +++ b/bitbake/lib/bb/ui/crumbs/template.py | |||
@@ -137,8 +137,6 @@ class RecipeFile(ConfigFile): | |||
137 | 137 | ||
138 | class TemplateMgr(gobject.GObject): | 138 | class TemplateMgr(gobject.GObject): |
139 | 139 | ||
140 | __gLocalVars__ = ["MACHINE", "PACKAGE_CLASSES", "DISTRO", "DL_DIR", "SSTATE_DIR", "SSTATE_MIRRORS", "PARALLEL_MAKE", "BB_NUMBER_THREADS", "CONF_VERSION"] | ||
141 | __gBBLayersVars__ = ["BBLAYERS", "LCONF_VERSION"] | ||
142 | __gRecipeVars__ = ["DEPENDS", "IMAGE_INSTALL"] | 140 | __gRecipeVars__ = ["DEPENDS", "IMAGE_INSTALL"] |
143 | 141 | ||
144 | def __init__(self): | 142 | def __init__(self): |
@@ -153,36 +151,20 @@ class TemplateMgr(gobject.GObject): | |||
153 | return "%s/%s%s%s" % (path, "template-", filename, ".hob") | 151 | return "%s/%s%s%s" % (path, "template-", filename, ".hob") |
154 | 152 | ||
155 | @classmethod | 153 | @classmethod |
156 | def convert_to_bblayers_pathfilename(cls, filename, path): | ||
157 | return "%s/%s%s%s" % (path, "bblayers-", filename, ".conf") | ||
158 | |||
159 | @classmethod | ||
160 | def convert_to_local_pathfilename(cls, filename, path): | ||
161 | return "%s/%s%s%s" % (path, "local-", filename, ".conf") | ||
162 | |||
163 | @classmethod | ||
164 | def convert_to_image_pathfilename(cls, filename, path): | 154 | def convert_to_image_pathfilename(cls, filename, path): |
165 | return "%s/%s%s%s" % (path, "hob-image-", filename, ".bb") | 155 | return "%s/%s%s%s" % (path, "hob-image-", filename, ".bb") |
166 | 156 | ||
167 | def open(self, filename, path): | 157 | def open(self, filename, path): |
168 | self.template_hob = HobTemplateFile(TemplateMgr.convert_to_template_pathfilename(filename, path)) | 158 | self.template_hob = HobTemplateFile(TemplateMgr.convert_to_template_pathfilename(filename, path)) |
169 | self.bblayers_conf = ConfigFile(TemplateMgr.convert_to_bblayers_pathfilename(filename, path)) | ||
170 | self.local_conf = ConfigFile(TemplateMgr.convert_to_local_pathfilename(filename, path)) | ||
171 | self.image_bb = RecipeFile(TemplateMgr.convert_to_image_pathfilename(filename, path)) | 159 | self.image_bb = RecipeFile(TemplateMgr.convert_to_image_pathfilename(filename, path)) |
172 | 160 | ||
173 | def setVar(self, var, val): | 161 | def setVar(self, var, val): |
174 | if var in TemplateMgr.__gLocalVars__: | ||
175 | self.local_conf.setVar(var, val) | ||
176 | if var in TemplateMgr.__gBBLayersVars__: | ||
177 | self.bblayers_conf.setVar(var, val) | ||
178 | if var in TemplateMgr.__gRecipeVars__: | 162 | if var in TemplateMgr.__gRecipeVars__: |
179 | self.image_bb.setVar(var, val) | 163 | self.image_bb.setVar(var, val) |
180 | 164 | ||
181 | self.template_hob.setVar(var, val) | 165 | self.template_hob.setVar(var, val) |
182 | 166 | ||
183 | def save(self): | 167 | def save(self): |
184 | self.local_conf.save() | ||
185 | self.bblayers_conf.save() | ||
186 | self.image_bb.save() | 168 | self.image_bb.save() |
187 | self.template_hob.save() | 169 | self.template_hob.save() |
188 | 170 | ||
@@ -200,12 +182,6 @@ class TemplateMgr(gobject.GObject): | |||
200 | if self.template_hob: | 182 | if self.template_hob: |
201 | del self.template_hob | 183 | del self.template_hob |
202 | template_hob = None | 184 | template_hob = None |
203 | if self.bblayers_conf: | ||
204 | del self.bblayers_conf | ||
205 | self.bblayers_conf = None | ||
206 | if self.local_conf: | ||
207 | del self.local_conf | ||
208 | self.local_conf = None | ||
209 | if self.image_bb: | 185 | if self.image_bb: |
210 | del self.image_bb | 186 | del self.image_bb |
211 | self.image_bb = None | 187 | self.image_bb = None |