+:check_build_environment\r
+\r
+ if not defined FORCE_REBUILD (\r
+ echo.\r
+ echo Rebuilding of tools is not required. Binaries of the latest,\r
+ echo tested versions of the tools have been tested and included in the\r
+ echo EDK II repository.\r
+ echo.\r
+ echo If you really want to build the tools, use the ForceRebuild option.\r
+ echo.\r
+ goto end\r
+ )\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
+ set PATH=%BASE_TOOLS_PATH%\Bin\Win32;%PATH%\r
+\r
+ set PYTHONPATH=%BASE_TOOLS_PATH%\Source\Python\r
+\r
+ if not defined PYTHON_HOME (\r
+ if defined PYTHONHOME (\r
+ set PYTHON_HOME=%PYTHONHOME%\r
+ ) else (\r
+ echo.\r
+ echo !!! ERROR !!! PYTHON_HOME is required to build or execute the tools, please set it. !!!\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
+ @REM see if we can find FreezePython.ex\r
+ if exist "%PYTHON_HOME%\Tools\cx_Freeze-3.0.3\FreezePython.exe" (\r
+ set PYTHON_FREEZER_PATH=%PYTHON_HOME%\Tools\cx_Freeze-3.0.3\r
+ ) \r
+ if exist "%PYTHON_HOME%\Tools\cx_Freeze\FreezePython.exe" (\r
+ set PYTHON_FREEZER_PATH=%PYTHON_HOME%\Tools\cx_Freeze\r
+ ) \r
+ if exist "C:\cx_Freeze\FreezePython.exe" (\r
+ set PYTHON_FREEZER_PATH=C:\cx_Freeze\r
+ )\r
+ if exist "C:\cx_Freeze-3.0.3" (\r
+ set PYTHON_FREEZER_PATH=C:\cx_Freeze-3.0.3\r
+ )\r
+ if not defined PYTHON_FREEZER_PATH (\r
+ echo.\r
+ echo !!! WARNING !!! Will not be able to compile Python programs to .exe\r
+ echo Will setup environment to run Python scripts directly.\r
+ echo.\r
+ set PYTHONPATH=%BASE_TOOLS_PATH%\Source\Python\r
+ set PATH=%PYTHONPATH%\build;%PYTHONPATH%\GenFds;%PYTHONPATH%\Trim;%PATH%\r
+ set PATHEXT=%PATHEXT%;.py\r
+ )\r
+ )\r
+ \r
+ echo BASE_TOOLS_PATH = %BASE_TOOLS_PATH%\r
+ echo PYTHON_PATH = %PYTHON_PATH%\r
+ echo PYTHON_FREEZER_PATH = %PYTHON_FREEZER_PATH%\r
+ echo.\r
+\r
+ if defined VCINSTALLDIR goto VisualStudioAvailable\r
+ if defined VS71COMNTOOLS (\r
+ call "%VS71COMNTOOLS%\vsvars32.bat"\r
+ ) else (\r
+ if defined VS80COMNTOOLS (\r
+ call "%VS80COMNTOOLS%\vsvars32.bat"\r
+ ) else (\r
+ echo.\r
+ echo !!! ERROR !!!! Cannot find Visual Studio, required to build C tools !!!\r
+ echo.\r
+ goto end\r
+ )\r
+ )\r
+\r
+:VisualStudioAvailable\r
+ if defined FORCE_REBUILD goto CleanAndBuild\r
+ 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