summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/cooker.py33
1 files changed, 13 insertions, 20 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 3e4f8d8e5e..9bd3460625 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -124,46 +124,39 @@ class EventWriter:
124 self.eventfile = eventfile 124 self.eventfile = eventfile
125 self.event_queue = [] 125 self.event_queue = []
126 126
127 def init_file(self):
128 # write current configuration data
129 with open(eventfile, "w") as f:
130 f.write("%s\n" % json.dumps({ "allvariables" : self.cooker.getAllKeysWithFlags(["doc", "func"])}))
131
132 def write_event(self, event): 127 def write_event(self, event):
133 with open(self.eventfile, "a") as f: 128 with open(self.eventfile, "a") as f:
134 try: 129 try:
135 str_event = codecs.encode(pickle.dumps(event), 'base64').decode('utf-8') 130 str_event = codecs.encode(pickle.dumps(event), 'base64').decode('utf-8')
136 f.write("%s\n" % json.dumps({"class": event.__module__ + "." + event.__class__.__name__, 131 f.write("%s\n" % json.dumps({"class": event.__module__ + "." + event.__class__.__name__,
137 "vars": str_event})) 132 "vars": str_event}))
138 except Exception as e: 133 except Exception as err:
139 import traceback 134 import traceback
140 print(e, traceback.format_exc()) 135 print(err, traceback.format_exc())
141
142 136
143 def send(self, event): 137 def send(self, event):
144 event_class = event.__module__ + "." + event.__class__.__name__ 138 if self.file_inited:
139 # we have the file, just write the event
140 self.write_event(event)
141 else:
142 # init on bb.event.BuildStarted
143 name = "%s.%s" % (event.__module__, event.__class__.__name__)
144 if name == "bb.event.BuildStarted":
145 with open(self.eventfile, "w") as f:
146 f.write("%s\n" % json.dumps({ "allvariables" : self.cooker.getAllKeysWithFlags(["doc", "func"])}))
145 147
146 # init on bb.event.BuildStarted
147 if self.file_inited is None:
148 if event_class == "bb.event.BuildStarted":
149 self.init_file()
150 self.file_inited = True 148 self.file_inited = True
151 149
152 # write pending events 150 # write pending events
153 for e in self.event_queue: 151 for evt in self.event_queue:
154 self.write_event(e) 152 self.write_event(evt)
155 153
156 # also write the current event 154 # also write the current event
157 self.write_event(event) 155 self.write_event(event)
158
159 else: 156 else:
160 # queue all events until the file is inited 157 # queue all events until the file is inited
161 self.event_queue.append(event) 158 self.event_queue.append(event)
162 159
163 else:
164 # we have the file, just write the event
165 self.write_event(event)
166
167#============================================================================# 160#============================================================================#
168# BBCooker 161# BBCooker
169#============================================================================# 162#============================================================================#