2022-06-26 12:00:03 +00:00
|
|
|
from SCons.Script import GetBuildFailures
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import atexit
|
2022-10-25 22:15:02 +00:00
|
|
|
from ansi.color import fg, fx
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
sys.path.insert(0, os.path.join(os.getcwd(), "scripts"))
|
|
|
|
|
|
|
|
|
|
|
|
def bf_to_str(bf):
|
|
|
|
"""Convert an element of GetBuildFailures() to a string
|
|
|
|
in a useful way."""
|
|
|
|
import SCons.Errors
|
|
|
|
|
|
|
|
if bf is None: # unknown targets product None in list
|
|
|
|
return "(unknown tgt)"
|
|
|
|
elif isinstance(bf, SCons.Errors.StopError):
|
2022-10-25 22:15:02 +00:00
|
|
|
return fg.yellow(str(bf))
|
2022-06-26 12:00:03 +00:00
|
|
|
elif bf.node:
|
2022-10-25 22:15:02 +00:00
|
|
|
return fg.yellow(str(bf.node)) + ": " + bf.errstr
|
2022-06-26 12:00:03 +00:00
|
|
|
elif bf.filename:
|
2022-10-25 22:15:02 +00:00
|
|
|
return fg.yellow(bf.filename) + ": " + bf.errstr
|
|
|
|
return fg.yellow("unknown failure: ") + bf.errstr
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
def display_build_status():
|
|
|
|
"""Display the build status. Called by atexit.
|
|
|
|
Here you could do all kinds of complicated things."""
|
|
|
|
bf = GetBuildFailures()
|
|
|
|
if bf:
|
|
|
|
# bf is normally a list of build failures; if an element is None,
|
|
|
|
# it's because of a target that scons doesn't know anything about.
|
2022-10-25 22:15:02 +00:00
|
|
|
failures_message = "\n".join([bf_to_str(x) for x in bf if x is not None])
|
|
|
|
print()
|
|
|
|
print(fg.brightred(fx.bold("*" * 10 + " FBT ERRORS " + "*" * 10)))
|
2022-06-26 12:00:03 +00:00
|
|
|
print(failures_message)
|
|
|
|
|
|
|
|
|
|
|
|
atexit.register(display_build_status)
|