diff options
-rw-r--r-- | bitbake/lib/bb/cache.py | 5 | ||||
-rw-r--r-- | bitbake/lib/bb/cooker.py | 44 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/__init__.py | 5 |
3 files changed, 51 insertions, 3 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py index 715da07e8d..a1dde96425 100644 --- a/bitbake/lib/bb/cache.py +++ b/bitbake/lib/bb/cache.py @@ -623,10 +623,13 @@ class Cache(object): def mtime(cachefile): return bb.parse.cached_mtime_noerror(cachefile) - def add_info(self, filename, info_array, cacheData, parsed=None): + def add_info(self, filename, info_array, cacheData, parsed=None, watcher=None): if isinstance(info_array[0], CoreRecipeInfo) and (not info_array[0].skipped): cacheData.add_from_recipeinfo(filename, info_array) + if watcher: + watcher(info_array[0].file_depends) + if not self.has_cache: return diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 8e6d91bc50..b5a5281c0e 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py @@ -39,6 +39,7 @@ from bb import utils, data, parse, event, cache, providers, taskdata, runqueue import Queue import signal import prserv.serv +import pyinotify logger = logging.getLogger("BitBake") collectlog = logging.getLogger("BitBake.Collection") @@ -120,7 +121,18 @@ class BBCooker: self.configuration = configuration + self.configwatcher = pyinotify.WatchManager() + self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications) + self.watchmask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE | pyinotify.IN_DELETE | \ + pyinotify.IN_DELETE_SELF | pyinotify.IN_MODIFY | pyinotify.IN_MOVE_SELF | \ + pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO + self.watcher = pyinotify.WatchManager() + self.notifier = pyinotify.Notifier(self.watcher, self.notifications) + + self.initConfigurationData() + self.baseconfig_valid = True + self.parsecache_valid = False # Take a lock so only one copy of bitbake can run against a given build # directory at a time @@ -156,6 +168,18 @@ class BBCooker: # Let SIGHUP exit as SIGTERM signal.signal(signal.SIGHUP, self.sigterm_exception) + def config_notifications(self, event): + bb.parse.update_cache(event.path) + self.baseconfig_valid = False + + def notifications(self, event): + bb.parse.update_cache(event.path) + self.parsecache_valid = False + + def add_filewatch(self, deps): + for i in deps: + self.watcher.add_watch(i[0], self.watchmask, rec=True) + def sigterm_exception(self, signum, stackframe): if signum == signal.SIGTERM: bb.warn("Cooker recieved SIGTERM, shutting down...") @@ -1292,6 +1316,18 @@ class BBCooker: raise bb.BBHandledException() if self.state != state.parsing: + for n in [self.confignotifier, self.notifier]: + if n.check_events(timeout=0): + # read notified events and enqeue them + n.read_events() + n.process_events() + if not self.baseconfig_valid: + logger.debug(1, "Reloading base configuration data") + self.initConfigurationData() + self.baseconfig_valid = True + self.parsecache_valid = False + + if self.state != state.parsing and not self.parsecache_valid: self.parseConfiguration () if CookerFeatures.SEND_SANITYEVENTS in self.featureset: bb.event.fire(bb.event.SanityCheck(False), self.data) @@ -1306,9 +1342,13 @@ class BBCooker: (filelist, masked) = self.collection.collect_bbfiles(self.data, self.event_data) self.data.renameVar("__depends", "__base_depends") + for i in self.data.getVar("__base_depends"): + self.wdd = self.configwatcher.add_watch(i[0], self.watchmask, rec=True) self.parser = CookerParser(self, filelist, masked) - self.state = state.parsing + self.parsecache_valid = True + + self.state = state.parsing if not self.parser.parse_next(): collectlog.debug(1, "parsing complete") @@ -1870,7 +1910,7 @@ class CookerParser(object): self.skipped += 1 self.cooker.skiplist[virtualfn] = SkippedPackage(info_array[0]) self.bb_cache.add_info(virtualfn, info_array, self.cooker.recipecache, - parsed=parsed) + parsed=parsed, watcher = self.cooker.add_filewatch) return True def reparse(self, filename): diff --git a/bitbake/lib/bb/parse/__init__.py b/bitbake/lib/bb/parse/__init__.py index 2303f15b9e..25effc2200 100644 --- a/bitbake/lib/bb/parse/__init__.py +++ b/bitbake/lib/bb/parse/__init__.py @@ -73,6 +73,11 @@ def update_mtime(f): __mtime_cache[f] = os.stat(f)[stat.ST_MTIME] return __mtime_cache[f] +def update_cache(f): + if f in __mtime_cache: + logger.debug(1, "Updating mtime cache for %s" % f) + update_mtime(f) + def mark_dependency(d, f): if f.startswith('./'): f = "%s/%s" % (os.getcwd(), f[2:]) |