SCons: Fix minor show_progress
issues
This commit is contained in:
parent
2b7ea6223b
commit
df6ac3973e
23
methods.py
23
methods.py
@ -857,10 +857,8 @@ def using_emcc(env):
|
||||
|
||||
|
||||
def show_progress(env):
|
||||
# Progress reporting is not available in non-TTY environments since it messes with the output
|
||||
# (for example, when writing to a file). Ninja has its own progress/tracking tool that clashes
|
||||
# with ours.
|
||||
if not env["progress"] or not IS_TTY or env["ninja"]:
|
||||
# Ninja has its own progress/tracking tool that clashes with ours.
|
||||
if env["ninja"]:
|
||||
return
|
||||
|
||||
NODE_COUNT_FILENAME = f"{base_folder_path}.scons_node_count"
|
||||
@ -877,30 +875,33 @@ def show_progress(env):
|
||||
if self.max == 0:
|
||||
print("NOTE: Performing initial build, progress percentage unavailable!")
|
||||
|
||||
# Progress reporting is not available in non-TTY environments since it
|
||||
# messes with the output (for example, when writing to a file).
|
||||
self.display = cast(bool, self.max and env["progress"] and IS_TTY)
|
||||
|
||||
def __call__(self, node, *args, **kw):
|
||||
self.count += 1
|
||||
if self.max != 0:
|
||||
if self.display:
|
||||
percent = int(min(self.count * 100 / self.max, 100))
|
||||
sys.stdout.write(f"\r[{percent:3d}%] ")
|
||||
sys.stdout.flush()
|
||||
|
||||
from SCons.Script import Progress
|
||||
from SCons.Script.Main import GetBuildFailures
|
||||
|
||||
progressor = ShowProgress()
|
||||
Progress(progressor)
|
||||
|
||||
def progress_finish(target, source, env):
|
||||
def progress_finish():
|
||||
if len(GetBuildFailures()):
|
||||
return
|
||||
try:
|
||||
with open(NODE_COUNT_FILENAME, "w", encoding="utf-8", newline="\n") as f:
|
||||
f.write(f"{progressor.count}\n")
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
env.AlwaysBuild(
|
||||
env.CommandNoCache(
|
||||
"progress_finish", [], env.Action(progress_finish, "Building node count database .scons_node_count")
|
||||
)
|
||||
)
|
||||
atexit.register(progress_finish)
|
||||
|
||||
|
||||
def convert_size(size_bytes: int) -> str:
|
||||
|
Loading…
x
Reference in New Issue
Block a user