summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/ui/crumbs/configurator.py94
-rw-r--r--bitbake/lib/bb/ui/crumbs/hobeventhandler.py11
-rw-r--r--bitbake/lib/bb/ui/crumbs/hobprefs.py22
-rw-r--r--bitbake/lib/bb/ui/hob.py4
4 files changed, 83 insertions, 48 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/configurator.py b/bitbake/lib/bb/ui/crumbs/configurator.py
index c37e9175ea..458e05626d 100644
--- a/bitbake/lib/bb/ui/crumbs/configurator.py
+++ b/bitbake/lib/bb/ui/crumbs/configurator.py
@@ -40,12 +40,13 @@ class Configurator(gobject.GObject):
40 40
41 def __init__(self): 41 def __init__(self):
42 gobject.GObject.__init__(self) 42 gobject.GObject.__init__(self)
43 self.local = None
44 self.bblayers = None 43 self.bblayers = None
45 self.enabled_layers = {} 44 self.enabled_layers = {}
46 self.loaded_layers = {} 45 self.loaded_layers = {}
47 self.config = {} 46 self.config = {}
48 self.orig_config = {} 47 self.orig_config = {}
48 self.preconf = None
49 self.postconf = None
49 50
50 # NOTE: cribbed from the cooker... 51 # NOTE: cribbed from the cooker...
51 def _parse(self, f, data, include=False): 52 def _parse(self, f, data, include=False):
@@ -55,18 +56,16 @@ class Configurator(gobject.GObject):
55 parselog.critical("Unable to parse %s: %s" % (f, exc)) 56 parselog.critical("Unable to parse %s: %s" % (f, exc))
56 sys.exit(1) 57 sys.exit(1)
57 58
58 def _loadLocalConf(self, path): 59 def _loadConf(self, path):
59 def getString(var): 60 def getString(var):
60 return bb.data.getVar(var, data, True) or "" 61 return bb.data.getVar(var, data, True) or ""
61 62
62 self.local = path
63
64 if self.orig_config: 63 if self.orig_config:
65 del self.orig_config 64 del self.orig_config
66 self.orig_config = {} 65 self.orig_config = {}
67 66
68 data = bb.data.init() 67 data = bb.data.init()
69 data = self._parse(self.local, data) 68 data = self._parse(path, data)
70 69
71 # We only need to care about certain variables 70 # We only need to care about certain variables
72 mach = getString('MACHINE') 71 mach = getString('MACHINE')
@@ -76,6 +75,8 @@ class Configurator(gobject.GObject):
76 if sdkmach and sdkmach != self.config.get('SDKMACHINE', ''): 75 if sdkmach and sdkmach != self.config.get('SDKMACHINE', ''):
77 self.config['SDKMACHINE'] = sdkmach 76 self.config['SDKMACHINE'] = sdkmach
78 distro = getString('DISTRO') 77 distro = getString('DISTRO')
78 if not distro:
79 distro = "defaultsetup"
79 if distro and distro != self.config.get('DISTRO', ''): 80 if distro and distro != self.config.get('DISTRO', ''):
80 self.config['DISTRO'] = distro 81 self.config['DISTRO'] = distro
81 bbnum = getString('BB_NUMBER_THREADS') 82 bbnum = getString('BB_NUMBER_THREADS')
@@ -109,10 +110,10 @@ class Configurator(gobject.GObject):
109 110
110 self.orig_config = copy.deepcopy(self.config) 111 self.orig_config = copy.deepcopy(self.config)
111 112
112 def setLocalConfVar(self, var, val): 113 def setConfVar(self, var, val):
113 self.config[var] = val 114 self.config[var] = val
114 115
115 def getLocalConfVar(self, var): 116 def getConfVar(self, var):
116 if var in self.config: 117 if var in self.config:
117 return self.config[var] 118 return self.config[var]
118 else: 119 else:
@@ -135,9 +136,17 @@ class Configurator(gobject.GObject):
135 self.emit("layers-loaded") 136 self.emit("layers-loaded")
136 137
137 def _addConfigFile(self, path): 138 def _addConfigFile(self, path):
139 conffiles = ["local.conf", "hob-pre.conf", "hob-post.conf"]
138 pref, sep, filename = path.rpartition("/") 140 pref, sep, filename = path.rpartition("/")
139 if filename == "local.conf" or filename == "hob.local.conf": 141
140 self._loadLocalConf(path) 142 if filename == "hob-pre.conf":
143 self.preconf = path
144
145 if filename == "hob-post.conf":
146 self.postconf = path
147
148 if filename in conffiles:
149 self._loadConf(path)
141 elif filename == "bblayers.conf": 150 elif filename == "bblayers.conf":
142 self._loadLayerConf(path) 151 self._loadLayerConf(path)
143 152
@@ -220,22 +229,8 @@ class Configurator(gobject.GObject):
220 with open(conffile, "w") as new: 229 with open(conffile, "w") as new:
221 new.write("".join(contents)) 230 new.write("".join(contents))
222 231
223 def writeLocalConf(self): 232 def updateConf(self, orig_lines, changed_values):
224 # Dictionary containing only new or modified variables 233 new_config_lines = []
225 changed_values = {}
226 for var in self.config:
227 val = self.config[var]
228 if self.orig_config.get(var, None) != val:
229 changed_values[var] = val
230
231 if not len(changed_values):
232 return
233
234 # read the original conf into a list
235 with open(self.local, 'r') as config:
236 config_lines = config.readlines()
237
238 new_config_lines = ["\n"]
239 for var in changed_values: 234 for var in changed_values:
240 # Convenience function for re.subn(). If the pattern matches 235 # Convenience function for re.subn(). If the pattern matches
241 # return a string which contains an assignment using the same 236 # return a string which contains an assignment using the same
@@ -254,10 +249,10 @@ class Configurator(gobject.GObject):
254 # Iterate over the local.conf lines and if they are a match 249 # Iterate over the local.conf lines and if they are a match
255 # for the pattern comment out the line and append a new line 250 # for the pattern comment out the line and append a new line
256 # with the new VAR op "value" entry 251 # with the new VAR op "value" entry
257 for line in config_lines: 252 for line in orig_lines:
258 new_line, replacements = p.subn(replace_val, line) 253 new_line, replacements = p.subn(replace_val, line)
259 if replacements: 254 if replacements:
260 config_lines[cnt] = "#%s" % line 255 orig_lines[cnt] = "#%s" % line
261 new_config_lines.append(new_line) 256 new_config_lines.append(new_line)
262 replaced = True 257 replaced = True
263 cnt = cnt + 1 258 cnt = cnt + 1
@@ -266,16 +261,53 @@ class Configurator(gobject.GObject):
266 new_config_lines.append("%s = \"%s\"\n" % (var, changed_values[var])) 261 new_config_lines.append("%s = \"%s\"\n" % (var, changed_values[var]))
267 262
268 # Add the modified variables 263 # Add the modified variables
269 config_lines.extend(new_config_lines) 264 orig_lines.extend(new_config_lines)
265 return orig_lines
266
267 def writeConf(self):
268 pre_vars = ["MACHINE", "SDKMACHINE", "DISTRO",
269 "INCOMPATIBLE_LICENSE"]
270 post_vars = ["BB_NUMBER_THREADS", "PARALLEL_MAKE", "PACKAGE_CLASSES",
271 "IMAGE_FSTYPES", "HOB_BUILD_TOOLCHAIN",
272 "HOB_BUILD_TOOLCHAIN_HEADERS"]
273 pre_values = {}
274 post_values = {}
275 changed_values = {}
276 pre_lines = None
277 post_lines = None
270 278
271 self.writeConfFile(self.local, config_lines) 279 for var in self.config:
280 val = self.config[var]
281 if self.orig_config.get(var, None) != val:
282 changed_values[var] = val
283
284 if not len(changed_values):
285 return
286
287 for var in changed_values:
288 if var in pre_vars:
289 pre_values[var] = changed_values[var]
290 elif var in post_vars:
291 post_values[var] = changed_values[var]
292
293 with open(self.preconf, 'r') as pre:
294 pre_lines = pre.readlines()
295 pre_lines = self.updateConf(pre_lines, pre_values)
296 if len(pre_lines):
297 self.writeConfFile(self.preconf, pre_lines)
298
299 with open(self.postconf, 'r') as post:
300 post_lines = post.readlines()
301 post_lines = self.updateConf(post_lines, post_values)
302 if len(post_lines):
303 self.writeConfFile(self.postconf, post_lines)
272 304
273 del self.orig_config 305 del self.orig_config
274 self.orig_config = copy.deepcopy(self.config) 306 self.orig_config = copy.deepcopy(self.config)
275 307
276 def insertTempBBPath(self, bbpath, bbfiles): 308 def insertTempBBPath(self, bbpath, bbfiles):
277 # read the original conf into a list 309 # read the original conf into a list
278 with open(self.local, 'r') as config: 310 with open(self.postconf, 'r') as config:
279 config_lines = config.readlines() 311 config_lines = config.readlines()
280 312
281 if bbpath: 313 if bbpath:
@@ -283,7 +315,7 @@ class Configurator(gobject.GObject):
283 if bbfiles: 315 if bbfiles:
284 config_lines.append("BBFILES := \"${BBFILES} %s\"\n" % bbfiles) 316 config_lines.append("BBFILES := \"${BBFILES} %s\"\n" % bbfiles)
285 317
286 self.writeConfFile(self.local, config_lines) 318 self.writeConfFile(self.postconf, config_lines)
287 319
288 def writeLayerConf(self): 320 def writeLayerConf(self):
289 # If we've not added/removed new layers don't write 321 # If we've not added/removed new layers don't write
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
index fca4401420..66dffac223 100644
--- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
+++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
@@ -65,7 +65,7 @@ class HobHandler(gobject.GObject):
65 gobject.TYPE_STRING,)), 65 gobject.TYPE_STRING,)),
66 } 66 }
67 67
68 (CFG_PATH_LOCAL, CFG_PATH_HOB, CFG_PATH_LAYERS, CFG_FILES_DISTRO, CFG_FILES_MACH, CFG_FILES_SDK, FILES_MATCH_CLASS, GENERATE_TGTS, REPARSE_FILES, BUILD_IMAGE) = range(10) 68 (CFG_PATH_LOCAL, CFG_PATH_PRE, CFG_PATH_POST, CFG_PATH_LAYERS, CFG_FILES_DISTRO, CFG_FILES_MACH, CFG_FILES_SDK, FILES_MATCH_CLASS, GENERATE_TGTS, REPARSE_FILES, BUILD_IMAGE) = range(11)
69 69
70 def __init__(self, taskmodel, server): 70 def __init__(self, taskmodel, server):
71 gobject.GObject.__init__(self) 71 gobject.GObject.__init__(self)
@@ -90,9 +90,12 @@ class HobHandler(gobject.GObject):
90 self.generating = True 90 self.generating = True
91 91
92 if self.current_command == self.CFG_PATH_LOCAL: 92 if self.current_command == self.CFG_PATH_LOCAL:
93 self.current_command = self.CFG_PATH_HOB 93 self.current_command = self.CFG_PATH_PRE
94 self.server.runCommand(["findConfigFilePath", "hob.local.conf"]) 94 self.server.runCommand(["findConfigFilePath", "hob-pre.conf"])
95 elif self.current_command == self.CFG_PATH_HOB: 95 elif self.current_command == self.CFG_PATH_PRE:
96 self.current_command = self.CFG_PATH_POST
97 self.server.runCommand(["findConfigFilePath", "hob-post.conf"])
98 elif self.current_command == self.CFG_PATH_POST:
96 self.current_command = self.CFG_PATH_LAYERS 99 self.current_command = self.CFG_PATH_LAYERS
97 self.server.runCommand(["findConfigFilePath", "bblayers.conf"]) 100 self.server.runCommand(["findConfigFilePath", "bblayers.conf"])
98 elif self.current_command == self.CFG_PATH_LAYERS: 101 elif self.current_command == self.CFG_PATH_LAYERS:
diff --git a/bitbake/lib/bb/ui/crumbs/hobprefs.py b/bitbake/lib/bb/ui/crumbs/hobprefs.py
index 3859b29a0f..14d6bc7b23 100644
--- a/bitbake/lib/bb/ui/crumbs/hobprefs.py
+++ b/bitbake/lib/bb/ui/crumbs/hobprefs.py
@@ -38,13 +38,13 @@ class HobPrefs(gtk.Dialog):
38 else: 38 else:
39 self.selected_image_types = handler.remove_image_output_type(ot) 39 self.selected_image_types = handler.remove_image_output_type(ot)
40 40
41 self.configurator.setLocalConfVar('IMAGE_FSTYPES', "%s" % " ".join(self.selected_image_types).lstrip(" ")) 41 self.configurator.setConfVar('IMAGE_FSTYPES', "%s" % " ".join(self.selected_image_types).lstrip(" "))
42 42
43 def sdk_machine_combo_changed_cb(self, combo, handler): 43 def sdk_machine_combo_changed_cb(self, combo, handler):
44 sdk_mach = combo.get_active_text() 44 sdk_mach = combo.get_active_text()
45 if sdk_mach != self.curr_sdk_mach: 45 if sdk_mach != self.curr_sdk_mach:
46 self.curr_sdk_mach = sdk_mach 46 self.curr_sdk_mach = sdk_mach
47 self.configurator.setLocalConfVar('SDKMACHINE', sdk_mach) 47 self.configurator.setConfVar('SDKMACHINE', sdk_mach)
48 handler.set_sdk_machine(sdk_mach) 48 handler.set_sdk_machine(sdk_mach)
49 49
50 def update_sdk_machines(self, handler, sdk_machines): 50 def update_sdk_machines(self, handler, sdk_machines):
@@ -67,7 +67,7 @@ class HobPrefs(gtk.Dialog):
67 distro = combo.get_active_text() 67 distro = combo.get_active_text()
68 if distro != self.curr_distro: 68 if distro != self.curr_distro:
69 self.curr_distro = distro 69 self.curr_distro = distro
70 self.configurator.setLocalConfVar('DISTRO', distro) 70 self.configurator.setConfVar('DISTRO', distro)
71 handler.set_distro(distro) 71 handler.set_distro(distro)
72 self.reload_required = True 72 self.reload_required = True
73 73
@@ -91,7 +91,7 @@ class HobPrefs(gtk.Dialog):
91 package_format = combo.get_active_text() 91 package_format = combo.get_active_text()
92 if package_format != self.curr_package_format: 92 if package_format != self.curr_package_format:
93 self.curr_package_format = package_format 93 self.curr_package_format = package_format
94 self.configurator.setLocalConfVar('PACKAGE_CLASSES', 'package_%s' % package_format) 94 self.configurator.setConfVar('PACKAGE_CLASSES', 'package_%s' % package_format)
95 handler.set_package_format(package_format) 95 handler.set_package_format(package_format)
96 self.reload_required = True 96 self.reload_required = True
97 97
@@ -113,7 +113,7 @@ class HobPrefs(gtk.Dialog):
113 113
114 def include_gplv3_cb(self, toggle): 114 def include_gplv3_cb(self, toggle):
115 excluded = toggle.get_active() 115 excluded = toggle.get_active()
116 orig_incompatible = self.configurator.getLocalConfVar('INCOMPATIBLE_LICENSE') 116 orig_incompatible = self.configurator.getConfVar('INCOMPATIBLE_LICENSE')
117 new_incompatible = "" 117 new_incompatible = ""
118 if excluded: 118 if excluded:
119 if not orig_incompatible: 119 if not orig_incompatible:
@@ -125,18 +125,18 @@ class HobPrefs(gtk.Dialog):
125 125
126 if new_incompatible != orig_incompatible: 126 if new_incompatible != orig_incompatible:
127 self.handler.set_incompatible_license(new_incompatible) 127 self.handler.set_incompatible_license(new_incompatible)
128 self.configurator.setLocalConfVar('INCOMPATIBLE_LICENSE', new_incompatible) 128 self.configurator.setConfVar('INCOMPATIBLE_LICENSE', new_incompatible)
129 self.reload_required = True 129 self.reload_required = True
130 130
131 def change_bb_threads_cb(self, spinner): 131 def change_bb_threads_cb(self, spinner):
132 val = spinner.get_value_as_int() 132 val = spinner.get_value_as_int()
133 self.handler.set_bbthreads(val) 133 self.handler.set_bbthreads(val)
134 self.configurator.setLocalConfVar('BB_NUMBER_THREADS', val) 134 self.configurator.setConfVar('BB_NUMBER_THREADS', val)
135 135
136 def change_make_threads_cb(self, spinner): 136 def change_make_threads_cb(self, spinner):
137 val = spinner.get_value_as_int() 137 val = spinner.get_value_as_int()
138 self.handler.set_pmake(val) 138 self.handler.set_pmake(val)
139 self.configurator.setLocalConfVar('PARALLEL_MAKE', "-j %s" % val) 139 self.configurator.setConfVar('PARALLEL_MAKE', "-j %s" % val)
140 140
141 def toggle_toolchain_cb(self, check): 141 def toggle_toolchain_cb(self, check):
142 enabled = check.get_active() 142 enabled = check.get_active()
@@ -144,7 +144,7 @@ class HobPrefs(gtk.Dialog):
144 if enabled: 144 if enabled:
145 toolchain = '1' 145 toolchain = '1'
146 self.handler.toggle_toolchain(enabled) 146 self.handler.toggle_toolchain(enabled)
147 self.configurator.setLocalConfVar('HOB_BUILD_TOOLCHAIN', toolchain) 147 self.configurator.setConfVar('HOB_BUILD_TOOLCHAIN', toolchain)
148 148
149 def toggle_headers_cb(self, check): 149 def toggle_headers_cb(self, check):
150 enabled = check.get_active() 150 enabled = check.get_active()
@@ -152,13 +152,13 @@ class HobPrefs(gtk.Dialog):
152 if enabled: 152 if enabled:
153 headers = '1' 153 headers = '1'
154 self.handler.toggle_toolchain_headers(enabled) 154 self.handler.toggle_toolchain_headers(enabled)
155 self.configurator.setLocalConfVar('HOB_BUILD_TOOLCHAIN_HEADERS', headers) 155 self.configurator.setConfVar('HOB_BUILD_TOOLCHAIN_HEADERS', headers)
156 156
157 def set_parent_window(self, parent): 157 def set_parent_window(self, parent):
158 self.set_transient_for(parent) 158 self.set_transient_for(parent)
159 159
160 def write_changes(self): 160 def write_changes(self):
161 self.configurator.writeLocalConf() 161 self.configurator.writeConf()
162 162
163 def prefs_response_cb(self, dialog, response): 163 def prefs_response_cb(self, dialog, response):
164 if self.reload_required: 164 if self.reload_required:
diff --git a/bitbake/lib/bb/ui/hob.py b/bitbake/lib/bb/ui/hob.py
index c2acadac91..c1302e51fa 100644
--- a/bitbake/lib/bb/ui/hob.py
+++ b/bitbake/lib/bb/ui/hob.py
@@ -192,8 +192,8 @@ class MainWindow (gtk.Window):
192 self.curr_mach = mach 192 self.curr_mach = mach
193 # Flush this straight to the file as MACHINE is changed 193 # Flush this straight to the file as MACHINE is changed
194 # independently of other 'Preferences' 194 # independently of other 'Preferences'
195 self.configurator.setLocalConfVar('MACHINE', mach) 195 self.configurator.setConfVar('MACHINE', mach)
196 self.configurator.writeLocalConf() 196 self.configurator.writeConf()
197 handler.set_machine(mach) 197 handler.set_machine(mach)
198 handler.reload_data() 198 handler.reload_data()
199 199