+IF NOT EXIST "%EDK_TOOLS_BIN%\EfiRom.exe" goto check_c_tools\r
+IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_c_tools\r
+IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_c_tools\r
+IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_c_tools\r
+IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_c_tools\r
+IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_c_tools\r
+IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools\r
+IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools\r
+IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools\r
+\r
+goto check_build_environment\r
+\r
+:check_c_tools\r
+ echo.\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=1\r
+\r
+ if not defined BASE_TOOLS_PATH (\r
+ if not exist "Source\C\Makefile" (\r
+ if not exist "%EDK_TOOLS_PATH%\Source\C\Makefile" goto no_source_files\r
+ set BASE_TOOLS_PATH=%EDK_TOOLS_PATH%\r
+ ) else (\r
+ set BASE_TOOLS_PATH=%CD%\r
+ )\r
+ )\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
+ 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.\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