summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cooker.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r--bitbake/lib/bb/cooker.py44
1 files changed, 42 insertions, 2 deletions
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
39import Queue 39import Queue
40import signal 40import signal
41import prserv.serv 41import prserv.serv
42import pyinotify
42 43
43logger = logging.getLogger("BitBake") 44logger = logging.getLogger("BitBake")
44collectlog = logging.getLogger("BitBake.Collection") 45collectlog = logging.getLogger("BitBake.Collection")
@@ -120,7 +121,18 @@ class BBCooker:
120 121
121 self.configuration = configuration 122 self.configuration = configuration
122 123
124 self.configwatcher = pyinotify.WatchManager()
125 self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications)
126 self.watchmask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE | pyinotify.IN_DELETE | \
127 pyinotify.IN_DELETE_SELF | pyinotify.IN_MODIFY | pyinotify.IN_MOVE_SELF | \
128 pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO
129 self.watcher = pyinotify.WatchManager()
130 self.notifier = pyinotify.Notifier(self.watcher, self.notifications)
131
132
123 self.initConfigurationData() 133 self.initConfigurationData()
134 self.baseconfig_valid = True
135 self.parsecache_valid = False
124 136
125 # Take a lock so only one copy of bitbake can run against a given build 137 # Take a lock so only one copy of bitbake can run against a given build
126 # directory at a time 138 # directory at a time
@@ -156,6 +168,18 @@ class BBCooker:
156 # Let SIGHUP exit as SIGTERM 168 # Let SIGHUP exit as SIGTERM
157 signal.signal(signal.SIGHUP, self.sigterm_exception) 169 signal.signal(signal.SIGHUP, self.sigterm_exception)
158 170
171 def config_notifications(self, event):
172 bb.parse.update_cache(event.path)
173 self.baseconfig_valid = False
174
175 def notifications(self, event):
176 bb.parse.update_cache(event.path)
177 self.parsecache_valid = False
178
179 def add_filewatch(self, deps):
180 for i in deps:
181 self.watcher.add_watch(i[0], self.watchmask, rec=True)
182
159 def sigterm_exception(self, signum, stackframe): 183 def sigterm_exception(self, signum, stackframe):
160 if signum == signal.SIGTERM: 184 if signum == signal.SIGTERM:
161 bb.warn("Cooker recieved SIGTERM, shutting down...") 185 bb.warn("Cooker recieved SIGTERM, shutting down...")
@@ -1292,6 +1316,18 @@ class BBCooker:
1292 raise bb.BBHandledException() 1316 raise bb.BBHandledException()
1293 1317
1294 if self.state != state.parsing: 1318 if self.state != state.parsing:
1319 for n in [self.confignotifier, self.notifier]:
1320 if n.check_events(timeout=0):
1321 # read notified events and enqeue them
1322 n.read_events()
1323 n.process_events()
1324 if not self.baseconfig_valid:
1325 logger.debug(1, "Reloading base configuration data")
1326 self.initConfigurationData()
1327 self.baseconfig_valid = True
1328 self.parsecache_valid = False
1329
1330 if self.state != state.parsing and not self.parsecache_valid:
1295 self.parseConfiguration () 1331 self.parseConfiguration ()
1296 if CookerFeatures.SEND_SANITYEVENTS in self.featureset: 1332 if CookerFeatures.SEND_SANITYEVENTS in self.featureset:
1297 bb.event.fire(bb.event.SanityCheck(False), self.data) 1333 bb.event.fire(bb.event.SanityCheck(False), self.data)
@@ -1306,9 +1342,13 @@ class BBCooker:
1306 (filelist, masked) = self.collection.collect_bbfiles(self.data, self.event_data) 1342 (filelist, masked) = self.collection.collect_bbfiles(self.data, self.event_data)
1307 1343
1308 self.data.renameVar("__depends", "__base_depends") 1344 self.data.renameVar("__depends", "__base_depends")
1345 for i in self.data.getVar("__base_depends"):
1346 self.wdd = self.configwatcher.add_watch(i[0], self.watchmask, rec=True)
1309 1347
1310 self.parser = CookerParser(self, filelist, masked) 1348 self.parser = CookerParser(self, filelist, masked)
1311 self.state = state.parsing 1349 self.parsecache_valid = True
1350
1351 self.state = state.parsing
1312 1352
1313 if not self.parser.parse_next(): 1353 if not self.parser.parse_next():
1314 collectlog.debug(1, "parsing complete") 1354 collectlog.debug(1, "parsing complete")
@@ -1870,7 +1910,7 @@ class CookerParser(object):
1870 self.skipped += 1 1910 self.skipped += 1
1871 self.cooker.skiplist[virtualfn] = SkippedPackage(info_array[0]) 1911 self.cooker.skiplist[virtualfn] = SkippedPackage(info_array[0])
1872 self.bb_cache.add_info(virtualfn, info_array, self.cooker.recipecache, 1912 self.bb_cache.add_info(virtualfn, info_array, self.cooker.recipecache,
1873 parsed=parsed) 1913 parsed=parsed, watcher = self.cooker.add_filewatch)
1874 return True 1914 return True
1875 1915
1876 def reparse(self, filename): 1916 def reparse(self, filename):