From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web12.4066.1617260817225482702 for ; Thu, 01 Apr 2021 00:06:57 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: yuwei.chen@intel.com) IronPort-SDR: X4dVixSaeDEZ2artN/0agtMDg2izJejgajZ+PNaWafJtKOxcyFCFbNeOOBCHo9pvIaUkJSV4GL XbtwU1+ECrmg== X-IronPort-AV: E=McAfee;i="6000,8403,9940"; a="192271976" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="192271976" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 00:06:56 -0700 IronPort-SDR: dTg9webop7K9sZNq7iUbt9gx87kcYW6Mi3ovCf8/MuS4/WJttJGWBc0V9thrOMMsG+Uj/aXynA Ucgl5mM4oeXQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="419056613" Received: from yuweipc.ccr.corp.intel.com ([10.239.158.34]) by orsmga008.jf.intel.com with ESMTP; 01 Apr 2021 00:06:47 -0700 From: "Yuwei Chen" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Wenyi Xie Subject: [PATCH 1/1] Basetools: Keep StdErr in screen when StdOut in file Date: Thu, 1 Apr 2021 15:06:46 +0800 Message-Id: <20210401070646.708-1-yuwei.chen@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Liming Gao Cc: Wenyi Xie Signed-off-by: Yuwei Chen --- 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