@@ -418,6 +418,7 @@ def __init__(self, script, backend="c", defines=None, flags=None, target=None):
418418 self ._keep_going = False
419419 self ._list_only = False
420420 self ._no_action = False
421+ self ._no_buffering = False
421422
422423 def backend (self ):
423424 "The compiler backend to use when building packages"
@@ -566,13 +567,17 @@ def no_action(self):
566567 "Perform a dry-run, do not make any changes to the system"
567568 return self ._no_action
568569
570+ def no_buffering (self ):
571+ "Let cm3 child process not buffer its output"
572+ return self ._no_buffering
573+
569574 def script (self ):
570575 "The script is used to locate the source directory"
571576 return Path (self ._script ).resolve ()
572577
573578 def set_options (self , namespace ):
574579 "Inform CM3 of options detected in argument parsing"
575- for attr in ["_keep_going" , "_list_only" , "_no_action" ]:
580+ for attr in ["_keep_going" , "_list_only" , "_no_action" , "_no_buffering" ]:
576581 if hasattr (namespace , attr ):
577582 setattr (self , attr , getattr (namespace , attr ))
578583
@@ -638,6 +643,7 @@ def __getattr__(self, method_name):
638643 "keep_going" ,
639644 "list_only" ,
640645 "no_action" ,
646+ "no_buffering" ,
641647 "source" ,
642648 "target" ,
643649 "use_c_backend" ,
@@ -866,16 +872,26 @@ def run(self, package_path, args):
866872 if self .no_action ():
867873 return
868874
869- proc = subprocess .run (
870- args ,
871- cwd = cwd ,
872- env = self .env (),
873- stdout = subprocess .PIPE ,
874- stderr = subprocess .STDOUT ,
875- check = True ,
876- errors = "ignore"
877- )
878- sys .stdout .write (proc .stdout )
875+ #if noBuffering the cm3 process sends output direct which aids debug
876+ if self .no_buffering ():
877+ proc = subprocess .run (
878+ args ,
879+ cwd = cwd ,
880+ env = self .env (),
881+ errors = "ignore"
882+ )
883+ else :
884+ proc = subprocess .run (
885+ args ,
886+ cwd = cwd ,
887+ env = self .env (),
888+ stdout = subprocess .PIPE ,
889+ stderr = subprocess .STDOUT ,
890+ check = True ,
891+ errors = "ignore"
892+ )
893+ sys .stdout .write (proc .stdout )
894+
879895 proc .check_returncode ()
880896
881897 def success (self ):
@@ -1110,6 +1126,7 @@ def _parse_options(cls, args, namespace):
11101126 keep_going = False
11111127 list_only = False
11121128 no_action = False
1129+ no_buffering = False
11131130
11141131 for option in ["-k" , "--keep-going" ]:
11151132 while option in args :
@@ -1126,9 +1143,15 @@ def _parse_options(cls, args, namespace):
11261143 args .remove (option )
11271144 no_action = True
11281145
1146+ for option in ["-b" , "--no-buffering" ]:
1147+ while option in args :
1148+ args .remove (option )
1149+ no_buffering = True
1150+
11291151 setattr (namespace , "_keep_going" , keep_going )
11301152 setattr (namespace , "_list_only" , list_only )
11311153 setattr (namespace , "_no_action" , no_action )
1154+ setattr (namespace , "_no_buffering" , no_buffering )
11321155
11331156 @classmethod
11341157 def _parse_compiler_options (cls , args , namespace ):
@@ -1837,6 +1860,7 @@ def __init__(self, args = None):
18371860 self ._keep_going = False
18381861 self ._list_only = False
18391862 self ._no_action = False
1863+ self ._no_buffering = False
18401864
18411865 # Package defaults.
18421866 self ._actions = []
0 commit comments