[edk2-devel] [PATCH 1/1] Basetools: Keep StdErr in screen when StdOut in file

Yuwei Chen yuwei.chen at intel.com
Thu Apr 1 07:06:46 UTC 2021


Currently, when using GCC toolchain and loging the StdOut into files,
the StdErr will also be logged into files without shown in screen.
This patch fixes this issue.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3278

Cc: Bob Feng <bob.c.feng at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Cc: Wenyi Xie <xiewenyi2 at huawei.com>
Signed-off-by: Yuwei Chen <yuwei.chen at intel.com>
---
 BaseTools/Source/Python/build/build.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index c4cfe38ad96a..a8210479d851 100755
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -233,7 +233,10 @@ def LaunchCommand(Command, WorkingDir,ModuleAuto = None):
     EndOfProcedure = None
     try:
         # launch the command
-        Proc = MakeSubProc(Command, stdout=PIPE, stderr=STDOUT, env=os.environ, cwd=WorkingDir, bufsize=-1, shell=True)
+        if ModuleAuto.ToolChainFamily == TAB_COMPILER_MSFT:
+            Proc = MakeSubProc(Command, stdout=PIPE, stderr=STDOUT, env=os.environ, cwd=WorkingDir, bufsize=-1, shell=True)
+        else:
+            Proc = MakeSubProc(Command, stdout=PIPE, stderr=PIPE, env=os.environ, cwd=WorkingDir, bufsize=-1, shell=True)
 
         # launch two threads to read the STDOUT and STDERR
         EndOfProcedure = Event()
@@ -244,6 +247,11 @@ def LaunchCommand(Command, WorkingDir,ModuleAuto = None):
             StdOutThread.setDaemon(False)
             StdOutThread.start()
 
+        if Proc.stderr:
+            StdErrThread = Thread(target=ReadMessage, args=(Proc.stderr, EdkLogger.quiet, EndOfProcedure,Proc.ProcOut))
+            StdErrThread.setName("STDERR-Redirector")
+            StdErrThread.setDaemon(False)
+            StdErrThread.start()
 
         # waiting for program exit
         Proc.wait()
@@ -260,6 +268,9 @@ def LaunchCommand(Command, WorkingDir,ModuleAuto = None):
     if Proc.stdout:
         StdOutThread.join()
 
+    if Proc.stderr:
+        StdErrThread.join()
+
     # check the return code of the program
     if Proc.returncode != 0:
         if not isinstance(Command, type("")):
-- 
2.27.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#73602): https://edk2.groups.io/g/devel/message/73602
Mute This Topic: https://groups.io/mt/81770276/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list