if op == "append":
self.appendConfigurationVar(var, val, default_file)
elif op == "set":
- self.saveConfigurationVar(var, val, default_file)
+ self.saveConfigurationVar(var, val, default_file, "=")
+ elif op == "earlyAssign":
+ self.saveConfigurationVar(var, val, default_file, "?=")
+
def appendConfigurationVar(self, var, val, default_file):
#add append var operation to the end of default_file
for c in contents:
total += c
- total += "#added by bitbake"
+ total += "#added by hob"
total += "\n%s += \"%s\"\n" % (var, val)
with open(default_file, 'w') as f:
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, op):
replaced = False
#do not save if nothing changed
#check if the variable was saved before in the same way
#if true it replace the place where the variable was declared
#else it comments it
- if contents[begin_line-1]== "#added by bitbake\n":
- contents[begin_line] = "%s = \"%s\"\n" % (var, val)
+ if contents[begin_line-1]== "#added by hob\n":
+ contents[begin_line] = "%s %s \"%s\"\n" % (var, op, val)
replaced = True
else:
for ii in range(begin_line, end_line):
total += c
#add the variable on a single line, to be easy to replace the second time
- total += "\n#added by bitbake"
- total += "\n%s = \"%s\"\n" % (var, val)
+ total += "\n#added by hob"
+ total += "\n%s %s \"%s\"\n" % (var, op, val)
with open(default_file, 'w') as f:
f.write(total)
handler.set_var_in_file("BBLAYERS", self.layers, "bblayers.conf")
# local.conf
if not defaults:
- handler.set_var_in_file("MACHINE", self.curr_mach, "local.conf")
+ handler.early_assign_var_in_file("MACHINE", self.curr_mach, "local.conf")
handler.set_var_in_file("DISTRO", self.curr_distro, "local.conf")
handler.set_var_in_file("DL_DIR", self.dldir, "local.conf")
handler.set_var_in_file("SSTATE_DIR", self.sstatedir, "local.conf")
def set_machine(self, machine):
if machine:
- self.set_var_in_file("MACHINE", machine, "local.conf")
+ self.early_assign_var_in_file("MACHINE", machine, "local.conf")
def set_sdk_machine(self, sdk_machine):
self.set_var_in_file("SDKMACHINE", sdk_machine, "local.conf")
self.server.runCommand(["setVarFile", var, val, default_file, "set"])
self.runCommand(["disableDataTracking"])
+ def early_assign_var_in_file(self, var, val, default_file=None):
+ self.runCommand(["enableDataTracking"])
+ self.server.runCommand(["setVarFile", var, val, default_file, "earlyAssign"])
+ self.runCommand(["disableDataTracking"])
+
def append_var_in_file(self, var, val, default_file=None):
self.server.runCommand(["setVarFile", var, val, default_file, "append"])