@@ -857,10 +857,8 @@ def using_emcc(env):
857
857
858
858
859
859
def show_progress (env ):
860
- # Progress reporting is not available in non-TTY environments since it messes with the output
861
- # (for example, when writing to a file). Ninja has its own progress/tracking tool that clashes
862
- # with ours.
863
- if not env ["progress" ] or not IS_TTY or env ["ninja" ]:
860
+ # Ninja has its own progress/tracking tool that clashes with ours.
861
+ if env ["ninja" ]:
864
862
return
865
863
866
864
NODE_COUNT_FILENAME = f"{ base_folder_path } .scons_node_count"
@@ -877,30 +875,33 @@ def __init__(self):
877
875
if self .max == 0 :
878
876
print ("NOTE: Performing initial build, progress percentage unavailable!" )
879
877
878
+ # Progress reporting is not available in non-TTY environments since it
879
+ # messes with the output (for example, when writing to a file).
880
+ self .display = cast (bool , self .max and env ["progress" ] and IS_TTY )
881
+
880
882
def __call__ (self , node , * args , ** kw ):
881
883
self .count += 1
882
- if self .max != 0 :
884
+ if self .display :
883
885
percent = int (min (self .count * 100 / self .max , 100 ))
884
886
sys .stdout .write (f"\r [{ percent :3d} %] " )
885
887
sys .stdout .flush ()
886
888
887
889
from SCons .Script import Progress
890
+ from SCons .Script .Main import GetBuildFailures
888
891
889
892
progressor = ShowProgress ()
890
893
Progress (progressor )
891
894
892
- def progress_finish (target , source , env ):
895
+ def progress_finish ():
896
+ if len (GetBuildFailures ()):
897
+ return
893
898
try :
894
899
with open (NODE_COUNT_FILENAME , "w" , encoding = "utf-8" , newline = "\n " ) as f :
895
900
f .write (f"{ progressor .count } \n " )
896
901
except OSError :
897
902
pass
898
903
899
- env .AlwaysBuild (
900
- env .CommandNoCache (
901
- "progress_finish" , [], env .Action (progress_finish , "Building node count database .scons_node_count" )
902
- )
903
- )
904
+ atexit .register (progress_finish )
904
905
905
906
906
907
def convert_size (size_bytes : int ) -> str :
0 commit comments