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 23e7abda39..f14eb64c83 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...")
@@ -1361,6 +1385,18 @@ class BBCooker:
1361 raise bb.BBHandledException() 1385 raise bb.BBHandledException()
1362 1386
1363 if self.state != state.parsing: 1387 if self.state != state.parsing:
1388 for n in [self.confignotifier, self.notifier]:
1389 if n.check_events(timeout=0):
1390 # read notified events and enqeue them
1391 n.read_events()
1392 n.process_events()
1393 if not self.baseconfig_valid:
1394 logger.debug(1, "Reloading base configuration data")
1395 self.initConfigurationData()
1396 self.baseconfig_valid = True
1397 self.parsecache_valid = False
1398
1399 if self.state != state.parsing and not self.parsecache_valid:
1364 self.parseConfiguration () 1400 self.parseConfiguration ()
1365 if CookerFeatures.SEND_SANITYEVENTS in self.featureset: 1401 if CookerFeatures.SEND_SANITYEVENTS in self.featureset:
1366 bb.event.fire(bb.event.SanityCheck(False), self.data) 1402 bb.event.fire(bb.event.SanityCheck(False), self.data)
@@ -1375,9 +1411,13 @@ class BBCooker:
1375 (filelist, masked) = self.collection.collect_bbfiles(self.data, self.event_data) 1411 (filelist, masked) = self.collection.collect_bbfiles(self.data, self.event_data)
1376 1412
1377 self.data.renameVar("__depends", "__base_depends") 1413 self.data.renameVar("__depends", "__base_depends")
1414 for i in self.data.getVar("__base_depends"):
1415 self.wdd = self.configwatcher.add_watch(i[0], self.watchmask, rec=True)
1378 1416
1379 self.parser = CookerParser(self, filelist, masked) 1417 self.parser = CookerParser(self, filelist, masked)
1380 self.state = state.parsing 1418 self.parsecache_valid = True
1419
1420 self.state = state.parsing
1381 1421
1382 if not self.parser.parse_next(): 1422 if not self.parser.parse_next():
1383 collectlog.debug(1, "parsing complete") 1423 collectlog.debug(1, "parsing complete")
@@ -1940,7 +1980,7 @@ class CookerParser(object):
1940 self.skipped += 1 1980 self.skipped += 1
1941 self.cooker.skiplist[virtualfn] = SkippedPackage(info_array[0]) 1981 self.cooker.skiplist[virtualfn] = SkippedPackage(info_array[0])
1942 self.bb_cache.add_info(virtualfn, info_array, self.cooker.recipecache, 1982 self.bb_cache.add_info(virtualfn, info_array, self.cooker.recipecache,
1943 parsed=parsed) 1983 parsed=parsed, watcher = self.cooker.add_filewatch)
1944 return True 1984 return True
1945 1985
1946 def reparse(self, filename): 1986 def reparse(self, filename):