diff options
-rw-r--r-- | bitbake/lib/bb/cookerdata.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/event.py | 23 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 3 |
3 files changed, 20 insertions, 8 deletions
diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py index 1bed455d16..4ddc2a5144 100644 --- a/bitbake/lib/bb/cookerdata.py +++ b/bitbake/lib/bb/cookerdata.py | |||
@@ -269,7 +269,7 @@ class CookerDataBuilder(object): | |||
269 | # Nomally we only register event handlers at the end of parsing .bb files | 269 | # Nomally we only register event handlers at the end of parsing .bb files |
270 | # We register any handlers we've found so far here... | 270 | # We register any handlers we've found so far here... |
271 | for var in data.getVar('__BBHANDLERS') or []: | 271 | for var in data.getVar('__BBHANDLERS') or []: |
272 | bb.event.register(var, data.getVar(var)) | 272 | bb.event.register(var, data.getVar(var), (data.getVarFlag(var, "eventmask", True) or "").split()) |
273 | 273 | ||
274 | if data.getVar("BB_WORKERCONTEXT", False) is None: | 274 | if data.getVar("BB_WORKERCONTEXT", False) is None: |
275 | bb.fetch.fetcher_init(data) | 275 | bb.fetch.fetcher_init(data) |
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index d73067fcf9..9c134eed0d 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py | |||
@@ -64,6 +64,8 @@ def clean_class_handlers(): | |||
64 | _handlers = clean_class_handlers() | 64 | _handlers = clean_class_handlers() |
65 | _ui_handlers = {} | 65 | _ui_handlers = {} |
66 | _ui_handler_seq = 0 | 66 | _ui_handler_seq = 0 |
67 | _event_handler_map = {} | ||
68 | _catchall_handlers = {} | ||
67 | 69 | ||
68 | def execute_handler(name, handler, event, d): | 70 | def execute_handler(name, handler, event, d): |
69 | event.data = d | 71 | event.data = d |
@@ -87,11 +89,14 @@ def fire_class_handlers(event, d): | |||
87 | if isinstance(event, logging.LogRecord): | 89 | if isinstance(event, logging.LogRecord): |
88 | return | 90 | return |
89 | 91 | ||
92 | eid = str(event.__class__)[8:-2] | ||
93 | evt_hmap = _event_handler_map.get(eid, {}) | ||
90 | for name, handler in _handlers.iteritems(): | 94 | for name, handler in _handlers.iteritems(): |
91 | try: | 95 | if name in _catchall_handlers or name in evt_hmap: |
92 | execute_handler(name, handler, event, d) | 96 | try: |
93 | except Exception: | 97 | execute_handler(name, handler, event, d) |
94 | continue | 98 | except Exception: |
99 | continue | ||
95 | 100 | ||
96 | ui_queue = [] | 101 | ui_queue = [] |
97 | @atexit.register | 102 | @atexit.register |
@@ -160,7 +165,7 @@ def fire_from_worker(event, d): | |||
160 | fire_ui_handlers(event, d) | 165 | fire_ui_handlers(event, d) |
161 | 166 | ||
162 | noop = lambda _: None | 167 | noop = lambda _: None |
163 | def register(name, handler): | 168 | def register(name, handler, mask=[]): |
164 | """Register an Event handler""" | 169 | """Register an Event handler""" |
165 | 170 | ||
166 | # already registered | 171 | # already registered |
@@ -185,6 +190,14 @@ def register(name, handler): | |||
185 | else: | 190 | else: |
186 | _handlers[name] = handler | 191 | _handlers[name] = handler |
187 | 192 | ||
193 | if not mask: | ||
194 | _catchall_handlers[name] = True | ||
195 | else: | ||
196 | for m in mask: | ||
197 | if _event_handler_map.get(m, None) is None: | ||
198 | _event_handler_map[m] = {} | ||
199 | _event_handler_map[m][name] = True | ||
200 | |||
188 | return Registered | 201 | return Registered |
189 | 202 | ||
190 | def remove(name, handler): | 203 | def remove(name, handler): |
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 713bef1cc2..6e7fd84b16 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -320,8 +320,7 @@ def finalize(fn, d, variant = None): | |||
320 | all_handlers = {} | 320 | all_handlers = {} |
321 | for var in d.getVar('__BBHANDLERS') or []: | 321 | for var in d.getVar('__BBHANDLERS') or []: |
322 | # try to add the handler | 322 | # try to add the handler |
323 | handler = d.getVar(var) | 323 | bb.event.register(var, d.getVar(var), (d.getVarFlag(var, "eventmask", True) or "").split()) |
324 | bb.event.register(var, handler) | ||
325 | 324 | ||
326 | bb.event.fire(bb.event.RecipePreFinalise(fn), d) | 325 | bb.event.fire(bb.event.RecipePreFinalise(fn), d) |
327 | 326 | ||