]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/toolsetup.bat
BaseTools: Update windows and linux run scripts file to use Python3
[mirror_edk2.git] / BaseTools / toolsetup.bat
index 1cac3105c2fbb978412e99e926cd2e1b7c713063..811b23051fd9a55280d9f54cd13df39c6deca76e 100755 (executable)
@@ -274,8 +274,7 @@ goto check_build_environment
   echo.\r
 \r
 :check_build_environment\r
-  set PYTHONHASHSEED=0\r
-  if defined BASETOOLS_PYTHON_SOURCE goto VisualStudioAvailable\r
+  set PYTHONHASHSEED=1\r
 \r
   if not defined BASE_TOOLS_PATH (\r
      if not exist "Source\C\Makefile" (\r
@@ -286,24 +285,60 @@ goto check_build_environment
      )\r
   )\r
 \r
-  if not defined PYTHON_HOME (\r
-    if defined PYTHONHOME (\r
-      set PYTHON_HOME=%PYTHONHOME%\r
-    ) else (\r
+:defined_python\r
+if defined PYTHON3_ENABLE (\r
+  if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
+    set PYTHON=py -3\r
+    %PYTHON% --version >NUL 2>&1\r
+    if %ERRORLEVEL% NEQ 0 (\r
       echo.\r
-      echo !!! ERROR !!! Binary python tools are missing. PYTHON_HOME environment variable is not set.\r
-      echo PYTHON_HOME is required to build or execute the python tools.\r
+      echo !!! ERROR !!!  PYTHON3 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
+if defined PYTHON_HOME (\r
+  if EXIST "%PYTHON_HOME%" (\r
+    set PYTHON=%PYTHON_HOME%\python.exe\r
+    goto check_freezer_path\r
+    )\r
+  )\r
+if defined PYTHONHOME (\r
+  if EXIST "%PYTHONHOME%" (\r
+    set PYTHON_HOME=%PYTHONHOME%\r
+    set PYTHON=%PYTHON_HOME%\python.exe\r
+    goto check_freezer_path\r
     )\r
   )\r
+  \r
+  echo.\r
+  echo !!! ERROR !!! Binary python tools are missing.\r
+  echo PYTHON_HOME or PYTHON3_ENABLE environment variable is not set successfully.\r
+  echo PYTHON_HOME or PYTHON3_ENABLE is required to build or execute the python tools.\r
+  echo.\r
+  goto end\r
 \r
+:check_freezer_path\r
+  if defined BASETOOLS_PYTHON_SOURCE goto print_python_info\r
   set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"\r
   set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python\r
   set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%\r
 \r
+:print_python_info\r
   echo                PATH = %PATH%\r
-  echo         PYTHON_HOME = %PYTHON_HOME%\r
+  if "%PYTHON3_ENABLE%" EQU "TRUE" (\r
+    echo      PYTHON3_ENABLE = %PYTHON3_ENABLE%\r
+    echo             PYTHON3 = %PYTHON%\r
+  ) else (\r
+    echo      PYTHON3_ENABLE = %PYTHON3_ENABLE%\r
+    if defined PYTHON_HOME (\r
+      echo         PYTHON_HOME = %PYTHON_HOME%\r
+    )\r
+  )\r
   echo          PYTHONPATH = %PYTHONPATH%\r
   echo.\r
 \r