--- /dev/null
+@rem #/*++\r
+@rem # \r
+@rem # Copyright (c) 2007, Intel Corporation \r
+@rem # All rights reserved. This program and the accompanying materials \r
+@rem # are licensed and made available under the terms and conditions of the BSD License \r
+@rem # which accompanies this 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 IMPLIED. \r
+@rem # \r
+@rem # Module Name:\r
+@rem # \r
+@rem # build.bat\r
+@rem # \r
+@rem # Abstract:\r
+@rem # \r
+@rem # This script provides single module build, clean and find function\r
+@rem # based on module name.\r
+@rem # \r
+@rem # The auto-generated module.list file records all module names \r
+@rem # described in the current platform.dsc.\r
+@rem # \r
+@rem #--*/ \r
+\r
+@echo off\r
+\r
+setlocal\r
+@rem initilize local variable\r
+set FUNCTION=build\r
+set MODULE=\r
+set UPDATE=\r
+set VERBOSE=\r
+\r
+:parse\r
+if /I "%1"=="/c" (\r
+ set FUNCTION=clean\r
+ shift\r
+ goto parse\r
+)\r
+if /I "%1"=="clean" (\r
+ set FUNCTION=clean\r
+ shift\r
+ goto parse\r
+)\r
+if /I "%1"=="/r" (\r
+ set FUNCTION=rebuild\r
+ shift\r
+ goto parse\r
+)\r
+if /I "%1"=="/h" (\r
+ set FUNCTION=usage\r
+ shift\r
+ goto parse\r
+)\r
+if /I "%1"=="/?" (\r
+ set FUNCTION=usage\r
+ shift\r
+ goto parse\r
+)\r
+if /I "%1"=="/f" (\r
+ set FUNCTION=find\r
+ shift\r
+ goto parse\r
+)\r
+if /I "%1"=="/a" (\r
+ set UPDATE=TRUE\r
+ shift\r
+ goto parse\r
+)\r
+if /I "%1"=="/v" (\r
+ set VERBOSE=TRUE\r
+ shift\r
+ goto parse\r
+)\r
+if not "%1"=="" (\r
+ set MODULE=%1\r
+ shift\r
+ goto parse\r
+) else (\r
+ @rem no other paramters\r
+ if "%FUNCTION%"=="rebuild" goto build\r
+ goto %FUNCTION%\r
+)\r
+\r
+:build\r
+set StartTime=%time%\r
+@rem if no input, build all\r
+if "%MODULE%"=="" (\r
+ if "%FUNCTION%"=="rebuild" (\r
+ nmake -nologo -f Makefile clean\r
+ )\r
+ nmake -nologo -f Makefile all\r
+ goto endtime\r
+)\r
+@rem then try to build special targets: all, fast, tools.\r
+if /I "%MODULE%"=="all" (\r
+ @rem build all modules and tools.\r
+ if "%FUNCTION%"=="rebuild" (\r
+ nmake -nologo -f Makefile cleanall\r
+ )\r
+ nmake -nologo -f Makefile all\r
+ goto endtime\r
+)\r
+if /I "%MODULE%"=="fast" (\r
+ @rem build fast target to skip FV=NULL modules.\r
+ if "%FUNCTION%"=="rebuild" (\r
+ nmake -nologo -f Makefile clean\r
+ )\r
+ nmake -nologo -f Makefile fast\r
+ goto endtime\r
+)\r
+if /I "%MODULE%"=="tools" (\r
+ @rem build all tools.\r
+ if "%FUNCTION%"=="rebuild" (\r
+ nmake -nologo -f Makefile cleantools\r
+ )\r
+ nmake -nologo -f Makefile build_tools\r
+ echo.\r
+ echo All tools are built.\r
+ goto endtime\r
+)\r
+@rem build single module, update build makefiles\r
+if "%FUNCTION%"=="rebuild" (\r
+ nmake -nologo -f module.mak %MODULE%Clean 2>NUL\r
+)\r
+nmake -nologo -f Makefile flashmap > NUL 2>&1\r
+nmake -nologo -f Makefile makefiles\r
+if errorlevel 1 goto builderror\r
+@rem check whether input module name is described in current dsc file. \r
+findstr /I /C:" %MODULE% " module.list > NUL\r
+if errorlevel 1 (\r
+ echo.\r
+ echo.\r
+ findstr /I /C:"%MODULE%" module.list > NUL\r
+ if errorlevel 1 goto finderror\r
+ for /F %%A in ('findstr /I /C:"%MODULE%" module.list') do echo %%A\r
+ echo.\r
+ echo Warning!!! Your specified module name can't be found. \r
+ echo One of the above modules may be what you want to build.\r
+ goto end\r
+)\r
+@rem build this module\r
+nmake -nologo -f module.mak %MODULE%Build \r
+echo.\r
+if "%FUNCTION%"=="rebuild" (\r
+ echo Module %MODULE% is rebuilt.\r
+) else (\r
+ echo Module %MODULE% is built.\r
+)\r
+:endtime\r
+@rem output build time.\r
+set EndTime=%time%\r
+echo.\r
+echo Start time %StartTime%\r
+echo End time %EndTime%\r
+goto end\r
+\r
+:clean\r
+@rem if no input, default clean all build directories.\r
+if "%MODULE%"=="" (\r
+ nmake -nologo -f Makefile clean\r
+ goto end\r
+)\r
+@rem first try to clean special tasks: all, modules and tools\r
+if /I "%MODULE%"=="all" (\r
+ nmake -nologo -f Makefile cleanall\r
+ goto end\r
+)\r
+if /I "%MODULE%"=="modules" (\r
+ nmake -nologo -f Makefile cleanbuilds\r
+ goto end\r
+)\r
+if /I "%MODULE%"=="tools" (\r
+ nmake -nologo -f Makefile cleantools\r
+ goto end\r
+)\r
+@rem clean single module \r
+@rem check whether input module name is in module.list file. \r
+if not exist module.list (\r
+ echo Module list info doesn't exist.\r
+ echo Processing dsc file to generate module list info.\r
+ nmake -nologo -f Makefile flashmap > NUL 2>&1\r
+ nmake -nologo -f Makefile makefiles > error.log 2>&1\r
+ if errorlevel 1 goto builderror\r
+)\r
+findstr /I /C:" %MODULE% " module.list > NUL\r
+if errorlevel 1 (\r
+ echo.\r
+ findstr /I /C:"%MODULE%" module.list > NUL\r
+ if errorlevel 1 goto finderror\r
+ for /F %%A in ('findstr /I /C:"%MODULE%" module.list') do echo %%A\r
+ echo.\r
+ echo Warning!!! Your specified module name can't be found. \r
+ echo One of the above modules may be what you want to clean. \r
+ goto end\r
+)\r
+@rem clean this module \r
+nmake -nologo -f module.mak %MODULE%Clean 2>NUL\r
+echo.\r
+echo Module %MODULE% is cleaned.\r
+goto end\r
+\r
+:find\r
+@rem find match module name by subname.\r
+if "%UPDATE%"=="TRUE" (\r
+ echo Processing dsc file to update module list info.\r
+ nmake -nologo -f Makefile flashmap > NUL 2>&1\r
+ nmake -nologo -f Makefile makefiles > error.log 2>&1\r
+ if errorlevel 1 goto builderror\r
+)\r
+if not exist module.list (\r
+ echo Module list info doesn't exist.\r
+ echo Processing dsc file to generate module list info.\r
+ nmake -nologo -f Makefile flashmap > NUL 2>&1\r
+ nmake -nologo -f Makefile makefiles > error.log 2>&1\r
+ if errorlevel 1 goto builderror\r
+)\r
+if "%MODULE%"=="" (\r
+ @rem display all\r
+ echo.\r
+ if "%VERBOSE%"=="TRUE" ( \r
+ type module.list\r
+ ) else (\r
+ @rem only output module name without module.inf file name\r
+ for /F %%A in (module.list) do echo %%A\r
+ )\r
+) else (\r
+ @rem display match module name\r
+ echo.\r
+ if "%VERBOSE%"=="TRUE" (\r
+ findstr /I /C:"%MODULE%" module.list\r
+ if errorlevel 1 goto notfind\r
+ ) else (\r
+ findstr /I /C:"%MODULE%" module.list > NUL\r
+ if errorlevel 1 goto notfind\r
+ for /F %%A in ('findstr /I /C:"%MODULE%" module.list') do echo %%A\r
+ )\r
+)\r
+goto end\r
+\r
+:usage\r
+echo build or clean single module based on module name after tools are built.\r
+echo.\r
+echo build [/r] [/c] [/f] [/h] [modulename]\r
+echo.\r
+echo build [/r] [modulename]\r
+echo build single module, such as build DxeMain.\r
+echo If /r is specified, the target will be rebuit after cleaned first.\r
+echo if no input modulename or modulename is all, then build all\r
+echo Specail build targets: all, fast, tools.\r
+echo These special targets may not exist in your tip main makefile.\r
+echo build - build all tools and modules\r
+echo build all - build all tools and modules\r
+echo build fast - build all without FV=NULL modules\r
+echo build tools - build all tools.\r
+echo.\r
+echo build /c [modulename]\r
+echo build clean [modulename]\r
+echo remove the temp generated files for single module \r
+echo if no input modulename, then clean all\r
+echo Specail clean targets: all, modules, tools.\r
+echo These special targets may not exist in your tip main makefile.\r
+echo build /c - clean up all build directories\r
+echo build /c all - clean up all build directories and binary dirs.\r
+echo build /c modules - clean up all build directories except for tools.\r
+echo build /c tools - clean up only tools directory.\r
+echo.\r
+echo build /f [/a] [/v] [subname]\r
+echo find all matched modulename with the sub string of module name.\r
+echo option /a re-processes dsc files to update module name list.\r
+echo option /v outputs module name and module.inf file name both.\r
+echo.\r
+echo build /h\r
+echo build /?\r
+echo display help information. \r
+echo.\r
+goto end\r
+\r
+:notfind\r
+echo Warning!!! Your specified module name can't be found.\r
+echo Try to use /f /a options to update module name list.\r
+goto end\r
+\r
+:finderror\r
+echo Warning!!! Your specified module name can't be found.\r
+echo Try to use /f to find modules that you want to build.\r
+echo Or use /h to get the helpinfo of this script.\r
+goto end\r
+\r
+:builderror\r
+if exist error.log type error.log\r
+echo.\r
+if not exist Tools\ProcessDsc.exe (\r
+ echo.\r
+ echo Error!!! Build tools may not be ready. Try to build tools first.\r
+ echo.\r
+)\r
+del module.* > NUL 2>&1\r
+goto end\r
+\r
+:end\r
+if exist error.log del error.log\r
+echo on\r