[PATCH v1] BaseTools: toolsetup.bat always execute PYTHON_HOME


Guo, Gua
 

From: Gua Guo <gua.guo@...>

Ideally behavior is like below order that can support one local build
machine, clone multiple Edk2, some of edk2 repo use old tag and
some of edk2 repo use new tag, they can both support on one machine.

1. if defined PYTHON_COMMAND only
- use PYTHON_COMMAND =3D user assigned
2. if not defined PYTHON_COMMAND, auto detect py -3
- use PYTHON_COMMAND =3D py -3
3. if defined PYTHON_COMMAND and PYTHON_HOME, use PYTHON_COMMAND
- use PYTHON_COMMAND =3D user assigned
4. if defined PYTHON_HOME only,
- use PYTHON_COMMAND =3D %PYTHON_HOME%/python.exe

SCRIPT_ERROR should return for paraent batch file to consume
for error handle.

Cc: Rebecca Cran <rebecca@...>
Cc: Liming Gao <gaoliming@...>
Cc: Bob Feng <bob.c.feng@...>
Cc: Yuwei Chen <yuwei.chen@...>
Signed-off-by: Gua Guo <gua.guo@...>
---
BaseTools/toolsetup.bat | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat
index 9521f67c02..8aef28192e 100755
--- a/BaseTools/toolsetup.bat
+++ b/BaseTools/toolsetup.bat
@@ -313,23 +313,25 @@ if not defined PYTHON_COMMAND (
)=0D
)=0D
=0D
-if defined PYTHON_HOME (=0D
- if EXIST "%PYTHON_HOME%" (=0D
- set PYTHON_COMMAND=3D%PYTHON_HOME%\python.exe=0D
- ) else (=0D
- echo .=0D
- echo !!! ERROR !!! PYTHON_HOME=3D"%PYTHON_HOME%" does not exist.=0D
- echo .=0D
- goto end=0D
+if not defined PYTHON_COMMAND (=0D
+ if defined PYTHON_HOME (=0D
+ if EXIST "%PYTHON_HOME%" (=0D
+ set PYTHON_COMMAND=3D%PYTHON_HOME%\python.exe=0D
+ ) else (=0D
+ echo .=0D
+ echo !!! ERROR !!! PYTHON_HOME=3D"%PYTHON_HOME%" does not exist.=0D
+ echo .=0D
+ goto end=0D
+ )=0D
)=0D
-)=0D
=0D
-%PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py %PYTHON_VER_MAJOR% =
%PYTHON_VER_MINOR% >NUL 2>NUL=0D
-if %ERRORLEVEL% EQU 1 (=0D
- echo.=0D
- echo !!! ERROR !!! Python %PYTHON_VER_MAJOR%.%PYTHON_VER_MINOR% or newer=
is required.=0D
- echo.=0D
- goto end=0D
+ %PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py %PYTHON_VER_MAJOR=
% %PYTHON_VER_MINOR% >NUL 2>NUL=0D
+ if %ERRORLEVEL% EQU 1 (=0D
+ echo.=0D
+ echo !!! ERROR !!! Python %PYTHON_VER_MAJOR%.%PYTHON_VER_MINOR% or new=
er is required.=0D
+ echo.=0D
+ goto end=0D
+ )=0D
)=0D
if %ERRORLEVEL% NEQ 0 (=0D
echo.=0D
@@ -447,5 +449,4 @@ set VS2015=3D
set VSTool=3D=0D
set PYTHON_VER_MAJOR=3D=0D
set PYTHON_VER_MINOR=3D=0D
-set SCRIPT_ERROR=3D=0D
popd=0D
--=20
2.39.2.windows.1

Join {devel@edk2.groups.io to automatically receive all group messages.