]> xenbits.xensource.com Git - ovmf.git/commitdiff
BaseTools: Remove Python2/Python3 detection from toolset.bat
authorRebecca Cran <rebecca@bsdio.com>
Mon, 24 Apr 2023 13:18:59 +0000 (07:18 -0600)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 8 May 2023 19:03:18 +0000 (19:03 +0000)
Since Python3 is now required, we can remove the checks for PYTHON3_ENABLE
and PYTHON3 and simplify the code in toolsetup.bat. Also, remove the
leftover from when we supported freezing Python code.

While here, fix a couple of typos and improve error messages.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
BaseTools/toolsetup.bat

index 25d13d559cd66744b60970ea19dd3058ad09252e..3d13e9fad2867342115ff132e8d9a534499cb512 100755 (executable)
@@ -305,18 +305,8 @@ goto check_build_environment
   )\r
 \r
 :defined_python\r
-if defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (\r
-  goto check_python_available\r
-)\r
-if defined PYTHON3_ENABLE (\r
-  if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
-    set PYTHON_COMMAND=py -3\r
-    goto check_python_available\r
-  ) else (\r
-    goto check_python2\r
-  )\r
-)\r
-if not defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (\r
+\r
+if not defined PYTHON_COMMAND (\r
   set PYTHON_COMMAND=py -3\r
   py -3 %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1\r
   setlocal enabledelayedexpansion\r
@@ -328,56 +318,40 @@ if not defined PYTHON_COMMAND if not defined PYTHON3_ENABLE (
       set PYTHON_COMMAND=\r
       echo.\r
       echo !!! ERROR !!! Binary python tools are missing.\r
-      echo PYTHON_COMMAND, PYTHON3_ENABLE or PYTHON_HOME\r
-      echo Environment variable is not set successfully.\r
-      echo They is required to build or execute the python tools.\r
+      echo PYTHON_COMMAND or PYTHON_HOME\r
+      echo Environment variable is not set correctly.\r
+      echo They are required to build or execute the python tools.\r
       echo.\r
       goto end\r
-    ) else (\r
-      goto check_python2\r
     )\r
-  ) else (\r
-    goto check_freezer_path\r
   )\r
 )\r
 \r
-:check_python2\r
 endlocal\r
+\r
 if defined PYTHON_HOME (\r
   if EXIST "%PYTHON_HOME%" (\r
     set PYTHON_COMMAND=%PYTHON_HOME%\python.exe\r
-    goto check_python_available\r
-  )\r
-)\r
-if defined PYTHONHOME (\r
-  if EXIST "%PYTHONHOME%" (\r
-    set PYTHON_HOME=%PYTHONHOME%\r
-    set PYTHON_COMMAND=%PYTHON_HOME%\python.exe\r
-    goto check_python_available\r
+  ) else (\r
+    echo .\r
+    echo !!! ERROR !!!  PYTHON_HOME="%PYTHON_HOME%" does not exist.\r
+    echo .\r
+    goto end\r
   )\r
 )\r
-echo.\r
-echo !!! ERROR !!!  PYTHON_HOME is not defined or The value of this variable does not exist\r
-echo.\r
-goto end\r
-:check_python_available\r
+\r
 %PYTHON_COMMAND% %BASE_TOOLS_PATH%\Tests\PythonTest.py >PythonCheck.txt 2>&1\r
   setlocal enabledelayedexpansion\r
   set /p PythonCheck=<"PythonCheck.txt"\r
   del PythonCheck.txt\r
   if "!PythonCheck!" NEQ "TRUE" (\r
     echo.\r
-    echo ! ERROR !  "%PYTHON_COMMAND%" is not installed or added to environment variables\r
+    echo ! ERROR !  PYTHON_COMMAND="%PYTHON_COMMAND%" is not installed or added to environment variables\r
     echo.\r
     goto end\r
-  ) else (\r
-    goto check_freezer_path\r
-  )\r
-\r
-\r
+)\r
 \r
-:check_freezer_path\r
-  endlocal\r
+endlocal\r
 \r
   %PYTHON_COMMAND% -c "import edk2basetools" >NUL 2>NUL\r
   if %ERRORLEVEL% EQU 0 (\r
@@ -404,13 +378,7 @@ goto end
 \r
 :print_python_info\r
   echo                PATH = %PATH%\r
-  if defined PYTHON3_ENABLE if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
-    echo      PYTHON3_ENABLE = %PYTHON3_ENABLE%\r
-    echo             PYTHON3 = %PYTHON_COMMAND%\r
-  ) else (\r
-    echo      PYTHON3_ENABLE = FALSE\r
-    echo      PYTHON_COMMAND = %PYTHON_COMMAND%\r
-  )\r
+  echo      PYTHON_COMMAND = %PYTHON_COMMAND%\r
   echo          PYTHONPATH = %PYTHONPATH%\r
   echo.\r
 \r