+:check_build_environment\r
+ if defined BASETOOLS_PYTHON_SOURCE goto VisualStudioAvailable\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
+ if not defined PYTHON_HOME (\r
+ if defined PYTHONHOME (\r
+ set PYTHON_HOME=%PYTHONHOME%\r
+ ) else (\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.\r
+ goto end\r
+ )\r
+ )\r
+\r
+ @REM We have Python, now test for FreezePython application\r
+ if not defined PYTHON_FREEZER_PATH (\r
+ echo.\r
+ echo !!! WARNING !!! PYTHON_FREEZER_PATH environment variable is not set.\r
+ echo Setup environment to run Python scripts directly.\r
+ echo.\r
+ set "PATH=%PATH%;%BASE_TOOLS_PATH%\BinWrappers\WindowsLike"\r
+ )\r
+\r
+ set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python\r
+ set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%\r
+ \r
+ echo PATH = %PATH%\r
+ echo PYTHON_HOME = %PYTHON_HOME%\r
+ echo PYTHONPATH = %PYTHONPATH%\r
+ if defined PYTHON_FREEZER_PATH (\r
+ echo PYTHON_FREEZER_PATH = %PYTHON_FREEZER_PATH%\r
+ )\r
+ echo.\r
+\r
+:VisualStudioAvailable\r
+ if not defined FORCE_REBUILD (\r
+ if not defined REBUILD (\r
+ goto end\r
+ )\r
+ )\r
+ call "%EDK_TOOLS_PATH%\get_vsvars.bat"\r
+ if not defined VCINSTALLDIR (\r
+ @echo.\r
+ @echo !!! ERROR !!!! Cannot find Visual Studio, required to build C tools !!!\r
+ @echo.\r
+ goto end\r
+ )\r
+ if not defined FORCE_REBUILD goto IncrementalBuild\r
+\r
+:CleanAndBuild\r
+ pushd .\r
+ cd %BASE_TOOLS_PATH%\r
+ call nmake cleanall\r
+ del /f /q %BASE_TOOLS_PATH%\Bin\Win32\*.*\r
+ popd\r
+ @REM Let CleanAndBuild fall through to IncrementalBuild\r
+\r
+\r
+:IncrementalBuild\r
+ pushd .\r
+ cd %BASE_TOOLS_PATH%\r
+ call nmake c\r
+ popd\r
+\r
+ if defined PYTHON_FREEZER_PATH (\r
+ echo BUILDING PYTHON TOOLS\r
+ pushd .\r
+ cd %BASE_TOOLS_PATH%\r
+ call nmake python\r
+ popd\r
+ ) else (\r
+ echo.\r
+ echo !!! WARNING !!! Cannot make executable from Python code, executing python scripts instead !!!\r
+ echo.\r
+ )\r
+ goto end\r
+\r
+\r
+:no_source_files\r
+ echo.\r
+ echo !!! ERROR !!! Cannot build BaseTools applications - no source directory located !!!\r
+ echo.\r
+ goto end\r
+\r
+:Usage\r
+ @echo.\r
+ echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]]"\r
+ @echo.\r
+ @echo base_tools_path BaseTools project path, BASE_TOOLS_PATH will be set to this path. \r
+ @echo edk_tools_path EDK_TOOLS_PATH will be set to this path.\r
+ @echo Rebuild If sources are available perform an Incremental build, only \r
+ @echo build those updated tools.\r
+ @echo ForceRebuild If sources are available, rebuild all tools regardless of \r
+ @echo whether they have been updated or not.\r
+ @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.\r
+ @echo.\r