]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/toolsetup.bat
OvmfPkg/Csm/LegacyBiosDxe: Fix Legacy16GetTableAddress call for E820 data
[mirror_edk2.git] / BaseTools / toolsetup.bat
index 1cac3105c2fbb978412e99e926cd2e1b7c713063..23dae40b209489243fdebe61a3c2636c008941ee 100755 (executable)
@@ -6,14 +6,7 @@
 @REM Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 @REM (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 @REM\r
-@REM This program and the accompanying materials are licensed and made available\r
-@REM under the terms and conditions of the BSD License which accompanies this\r
-@REM distribution.  The full text of the license may be found at:\r
-@REM   http://opensource.org/licenses/bsd-license.php\r
-@REM\r
-@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR\r
-@REM IMPLIED.\r
+@REM SPDX-License-Identifier: BSD-2-Clause-Patent\r
 @REM\r
 \r
 @echo off\r
@@ -270,12 +263,11 @@ goto check_build_environment
 \r
 :check_c_tools\r
   echo.\r
-  echo !!! ERROR !!! Binary C tools are missing. They are requried to be built from BaseTools Source.\r
+  echo !!! ERROR !!! Binary C tools are missing. They are required to be built from BaseTools Source.\r
   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 +278,92 @@ 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 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
+  set PYTHON_COMMAND=py -3\r
+  py -3 %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
+    if not defined PYTHON_HOME if not defined PYTHONHOME (\r
+      endlocal\r
+      set PYTHON_COMMAND=\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 !!! 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.\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
+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
+  )\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
+%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.\r
+    goto end\r
+  ) else (\r
+    goto check_freezer_path\r
+  )\r
+\r
+:check_freezer_path\r
+  endlocal\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 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          PYTHONPATH = %PYTHONPATH%\r
   echo.\r
 \r