[bitbake-devel] [PATCH 04/13] command: ensure sync commands that read configuration see updates
Paul Eggleton
paul.eggleton at linux.intel.com
Mon Aug 17 11:12:19 UTC 2015
From: Richard Purdie <richard.purdie at linuxfoundation.org>
Add a means of ensuring that synchronous commands that read the results
of the configuration trigger a reparse of the configuration if any
underlying files have changed.
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>
---
lib/bb/command.py | 13 ++++++++++++-
lib/bb/cooker.py | 27 ++++++++++++++++-----------
2 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/lib/bb/command.py b/lib/bb/command.py
index a7cac97..398c1d6 100644
--- a/lib/bb/command.py
+++ b/lib/bb/command.py
@@ -68,6 +68,8 @@ class Command:
if not hasattr(command_method, 'readonly') or False == getattr(command_method, 'readonly'):
return None, "Not able to execute not readonly commands in readonly mode"
try:
+ if getattr(command_method, 'needconfig', False):
+ self.cooker.updateCacheSync()
result = command_method(self, commandline)
except CommandError as exc:
return None, exc.args[0]
@@ -204,6 +206,7 @@ class CommandsSync:
postfiles = params[1].split()
command.cooker.configuration.prefile = prefiles
command.cooker.configuration.postfile = postfiles
+ setPrePostConfFiles.needconfig = False
def getCpuCount(self, command, params):
"""
@@ -211,10 +214,12 @@ class CommandsSync:
"""
return bb.utils.cpu_count()
getCpuCount.readonly = True
+ getCpuCount.needconfig = False
def matchFile(self, command, params):
fMatch = params[0]
return command.cooker.matchFile(fMatch)
+ matchFile.needconfig = False
def generateNewImage(self, command, params):
image = params[0]
@@ -228,6 +233,7 @@ class CommandsSync:
def ensureDir(self, command, params):
directory = params[0]
bb.utils.mkdirhier(directory)
+ ensureDir.needconfig = False
def setVarFile(self, command, params):
"""
@@ -238,6 +244,7 @@ class CommandsSync:
default_file = params[2]
op = params[3]
command.cooker.modifyConfigurationVar(var, val, default_file, op)
+ setVarFile.needconfig = False
def removeVarFile(self, command, params):
"""
@@ -245,6 +252,7 @@ class CommandsSync:
"""
var = params[0]
command.cooker.removeConfigurationVar(var)
+ removeVarFile.needconfig = False
def createConfigFile(self, command, params):
"""
@@ -252,6 +260,7 @@ class CommandsSync:
"""
name = params[0]
command.cooker.createConfigFile(name)
+ createConfigFile.needconfig = False
def setEventMask(self, command, params):
handlerNum = params[0]
@@ -259,6 +268,7 @@ class CommandsSync:
debug_domains = params[2]
mask = params[3]
return bb.event.set_UIHmask(handlerNum, llevel, debug_domains, mask)
+ setEventMask.needconfig = False
def setFeatures(self, command, params):
"""
@@ -266,7 +276,7 @@ class CommandsSync:
"""
features = params[0]
command.cooker.setFeatures(features)
-
+ setFeatures.needconfig = False
# although we change the internal state of the cooker, this is transparent since
# we always take and leave the cooker in state.initial
setFeatures.readonly = True
@@ -275,6 +285,7 @@ class CommandsSync:
options = params[0]
environment = params[1]
command.cooker.updateConfigOpts(options, environment)
+ updateConfig.needconfig = False
class CommandsAsync:
"""
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index f0f9c66..fb38289 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -1445,6 +1445,21 @@ class BBCooker:
if timestamp:
return timestr
+ def updateCacheSync(self):
+ if self.state == state.running:
+ return
+
+ # reload files for which we got notifications
+ for p in self.inotify_modified_files:
+ bb.parse.update_cache(p)
+ self.inotify_modified_files = []
+
+ if not self.baseconfig_valid:
+ logger.debug(1, "Reloading base configuration data")
+ self.initConfigurationData()
+ self.baseconfig_valid = True
+ self.parsecache_valid = False
+
# This is called for all async commands when self.state != running
def updateCache(self):
if self.state == state.running:
@@ -1456,17 +1471,7 @@ class BBCooker:
raise bb.BBHandledException()
if self.state != state.parsing:
-
- # reload files for which we got notifications
- for p in self.inotify_modified_files:
- bb.parse.update_cache(p)
- self.inotify_modified_files = []
-
- if not self.baseconfig_valid:
- logger.debug(1, "Reloading base configuration data")
- self.initConfigurationData()
- self.baseconfig_valid = True
- self.parsecache_valid = False
+ self.updateCacheSync()
if self.state != state.parsing and not self.parsecache_valid:
self.parseConfiguration ()
--
2.1.0
More information about the bitbake-devel
mailing list