|
@@ -857,10 +857,8 @@ def using_emcc(env):
|
|
|
|
|
|
|
|
|
|
def show_progress(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
|
|
return
|
|
|
|
|
|
NODE_COUNT_FILENAME = f"{base_folder_path}.scons_node_count"
|
|
NODE_COUNT_FILENAME = f"{base_folder_path}.scons_node_count"
|
|
@@ -877,30 +875,33 @@ def show_progress(env):
|
|
if self.max == 0:
|
|
if self.max == 0:
|
|
print("NOTE: Performing initial build, progress percentage unavailable!")
|
|
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):
|
|
def __call__(self, node, *args, **kw):
|
|
self.count += 1
|
|
self.count += 1
|
|
- if self.max != 0:
|
|
|
|
|
|
+ if self.display:
|
|
percent = int(min(self.count * 100 / self.max, 100))
|
|
percent = int(min(self.count * 100 / self.max, 100))
|
|
sys.stdout.write(f"\r[{percent:3d}%] ")
|
|
sys.stdout.write(f"\r[{percent:3d}%] ")
|
|
sys.stdout.flush()
|
|
sys.stdout.flush()
|
|
|
|
|
|
from SCons.Script import Progress
|
|
from SCons.Script import Progress
|
|
|
|
+ from SCons.Script.Main import GetBuildFailures
|
|
|
|
|
|
progressor = ShowProgress()
|
|
progressor = ShowProgress()
|
|
Progress(progressor)
|
|
Progress(progressor)
|
|
|
|
|
|
- def progress_finish(target, source, env):
|
|
|
|
|
|
+ def progress_finish():
|
|
|
|
+ if len(GetBuildFailures()):
|
|
|
|
+ return
|
|
try:
|
|
try:
|
|
with open(NODE_COUNT_FILENAME, "w", encoding="utf-8", newline="\n") as f:
|
|
with open(NODE_COUNT_FILENAME, "w", encoding="utf-8", newline="\n") as f:
|
|
f.write(f"{progressor.count}\n")
|
|
f.write(f"{progressor.count}\n")
|
|
except OSError:
|
|
except OSError:
|
|
pass
|
|
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:
|
|
def convert_size(size_bytes: int) -> str:
|