blob: 74a319320e2c4c7bdf44f0b54c6f05307d729e17 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001#!/usr/bin/env python3
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002#
3# Copyright (C) 2014 Alex Damian
4#
Brad Bishopc342db32019-05-15 21:57:59 -04005# SPDX-License-Identifier: GPL-2.0-only
6#
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007# This file re-uses code spread throughout other Bitbake source files.
8# As such, all other copyrights belong to their own right holders.
9#
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010
Patrick Williamsc0f7c042017-02-23 20:41:17 -060011"""
12This command takes a filename as a single parameter. The filename is read
13as a build eventlog, and the ToasterUI is used to process events in the file
14and log data in the database
15"""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017import os
Patrick Williamsc0f7c042017-02-23 20:41:17 -060018import sys
19import json
20import pickle
21import codecs
Andrew Geissler5199d832021-09-24 16:47:35 -050022import warnings
23warnings.simplefilter("default")
Patrick Williamsc0f7c042017-02-23 20:41:17 -060024
25from collections import namedtuple
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026
27# mangle syspath to allow easy import of modules
Patrick Williamsc0f7c042017-02-23 20:41:17 -060028from os.path import join, dirname, abspath
29sys.path.insert(0, join(dirname(dirname(abspath(__file__))), 'lib'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030
31import bb.cooker
32from bb.ui import toasterui
Patrick Williams169d7bc2024-01-05 11:33:25 -060033from bb.ui import eventreplay
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034
Patrick Williamsc0f7c042017-02-23 20:41:17 -060035def main(argv):
36 with open(argv[-1]) as eventfile:
37 # load variables from the first line
Patrick Williams169d7bc2024-01-05 11:33:25 -060038 variables = None
39 while line := eventfile.readline().strip():
40 try:
41 variables = json.loads(line)['allvariables']
42 break
43 except (KeyError, json.JSONDecodeError):
44 continue
45 if not variables:
46 sys.exit("Cannot find allvariables entry in event log file %s" % argv[-1])
47 eventfile.seek(0)
Patrick Williamsc0f7c042017-02-23 20:41:17 -060048 params = namedtuple('ConfigParams', ['observe_only'])(True)
Patrick Williams169d7bc2024-01-05 11:33:25 -060049 player = eventreplay.EventPlayer(eventfile, variables)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050
Patrick Williamsc0f7c042017-02-23 20:41:17 -060051 return toasterui.main(player, player, params)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052
53# run toaster ui on our mock bitbake class
54if __name__ == "__main__":
Patrick Williamsc0f7c042017-02-23 20:41:17 -060055 if len(sys.argv) != 2:
56 print("Usage: %s <event file>" % os.path.basename(sys.argv[0]))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050057 sys.exit(1)
58
Patrick Williamsc0f7c042017-02-23 20:41:17 -060059 sys.exit(main(sys.argv))