#! /usr/bin/env python3

# List tasks which were not ran from sstate
# MIT licensed

import sys
import re

def log_parser(stream):
    # NOTE: Running setscene task 170 of 191 (virtual:native:/home/ross/Yocto/poky/meta/recipes-support/gdbm/gdbm_1.23.bb:do_populate_sysroot_setscene)
    # NOTE: Running task 313 of 785 (/home/ross/Yocto/poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers_6.1.bb:do_unpack)
    task_re = re.compile(r"NOTE: Running( setscene)? task \d+ of \d+ \((?P<recipe>.+):(?P<task>.+)\)")
    for line in stream:
        m = task_re.search(line)
        if m:
            yield m.group("recipe"), m.group("task")

recipes = set()
for recipe, task in log_parser(open(sys.argv[1], encoding="utf-8")):
    # Ignore setscene tasks as these pulled from sstate
    if task.endswith("_setscene"):
        continue
    if task in ("do_rm_work",):
        continue
    recipes.add(recipe)

print("Built recipes:")
for t in sorted(recipes):
    print(" %s" % t)
