]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Sample/Platform/X64/Build/build.bat
Add some EDK build configuration files and EDK DSC file as the templates to build...
[mirror_edk2.git] / EdkCompatibilityPkg / Sample / Platform / X64 / Build / build.bat
1 @rem #/*++
2 @rem #
3 @rem # Copyright (c) 2007, Intel Corporation
4 @rem # All rights reserved. This program and the accompanying materials
5 @rem # are licensed and made available under the terms and conditions of the BSD License
6 @rem # which accompanies this distribution. The full text of the license may be found at
7 @rem # http://opensource.org/licenses/bsd-license.php
8 @rem #
9 @rem # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 @rem # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 @rem #
12 @rem # Module Name:
13 @rem #
14 @rem # build.bat
15 @rem #
16 @rem # Abstract:
17 @rem #
18 @rem # This script provides single module build, clean and find function
19 @rem # based on module name.
20 @rem #
21 @rem # The auto-generated module.list file records all module names
22 @rem # described in the current platform.dsc.
23 @rem #
24 @rem #--*/
25
26 @echo off
27
28 setlocal
29 @rem initilize local variable
30 set FUNCTION=build
31 set MODULE=
32 set UPDATE=
33 set VERBOSE=
34
35 :parse
36 if /I "%1"=="/c" (
37 set FUNCTION=clean
38 shift
39 goto parse
40 )
41 if /I "%1"=="clean" (
42 set FUNCTION=clean
43 shift
44 goto parse
45 )
46 if /I "%1"=="/r" (
47 set FUNCTION=rebuild
48 shift
49 goto parse
50 )
51 if /I "%1"=="/h" (
52 set FUNCTION=usage
53 shift
54 goto parse
55 )
56 if /I "%1"=="/?" (
57 set FUNCTION=usage
58 shift
59 goto parse
60 )
61 if /I "%1"=="/f" (
62 set FUNCTION=find
63 shift
64 goto parse
65 )
66 if /I "%1"=="/a" (
67 set UPDATE=TRUE
68 shift
69 goto parse
70 )
71 if /I "%1"=="/v" (
72 set VERBOSE=TRUE
73 shift
74 goto parse
75 )
76 if not "%1"=="" (
77 set MODULE=%1
78 shift
79 goto parse
80 ) else (
81 @rem no other paramters
82 if "%FUNCTION%"=="rebuild" goto build
83 goto %FUNCTION%
84 )
85
86 :build
87 set StartTime=%time%
88 @rem if no input, build all
89 if "%MODULE%"=="" (
90 if "%FUNCTION%"=="rebuild" (
91 nmake -nologo -f Makefile clean
92 )
93 nmake -nologo -f Makefile all
94 goto endtime
95 )
96 @rem then try to build special targets: all, fast, tools.
97 if /I "%MODULE%"=="all" (
98 @rem build all modules and tools.
99 if "%FUNCTION%"=="rebuild" (
100 nmake -nologo -f Makefile cleanall
101 )
102 nmake -nologo -f Makefile all
103 goto endtime
104 )
105 if /I "%MODULE%"=="fast" (
106 @rem build fast target to skip FV=NULL modules.
107 if "%FUNCTION%"=="rebuild" (
108 nmake -nologo -f Makefile clean
109 )
110 nmake -nologo -f Makefile fast
111 goto endtime
112 )
113 if /I "%MODULE%"=="tools" (
114 @rem build all tools.
115 if "%FUNCTION%"=="rebuild" (
116 nmake -nologo -f Makefile cleantools
117 )
118 nmake -nologo -f Makefile build_tools
119 echo.
120 echo All tools are built.
121 goto endtime
122 )
123 @rem build single module, update build makefiles
124 if "%FUNCTION%"=="rebuild" (
125 nmake -nologo -f module.mak %MODULE%Clean 2>NUL
126 )
127 nmake -nologo -f Makefile flashmap > NUL 2>&1
128 nmake -nologo -f Makefile makefiles
129 if errorlevel 1 goto builderror
130 @rem check whether input module name is described in current dsc file.
131 findstr /I /C:" %MODULE% " module.list > NUL
132 if errorlevel 1 (
133 echo.
134 echo.
135 findstr /I /C:"%MODULE%" module.list > NUL
136 if errorlevel 1 goto finderror
137 for /F %%A in ('findstr /I /C:"%MODULE%" module.list') do echo %%A
138 echo.
139 echo Warning!!! Your specified module name can't be found.
140 echo One of the above modules may be what you want to build.
141 goto end
142 )
143 @rem build this module
144 nmake -nologo -f module.mak %MODULE%Build
145 echo.
146 if "%FUNCTION%"=="rebuild" (
147 echo Module %MODULE% is rebuilt.
148 ) else (
149 echo Module %MODULE% is built.
150 )
151 :endtime
152 @rem output build time.
153 set EndTime=%time%
154 echo.
155 echo Start time %StartTime%
156 echo End time %EndTime%
157 goto end
158
159 :clean
160 @rem if no input, default clean all build directories.
161 if "%MODULE%"=="" (
162 nmake -nologo -f Makefile clean
163 goto end
164 )
165 @rem first try to clean special tasks: all, modules and tools
166 if /I "%MODULE%"=="all" (
167 nmake -nologo -f Makefile cleanall
168 goto end
169 )
170 if /I "%MODULE%"=="modules" (
171 nmake -nologo -f Makefile cleanbuilds
172 goto end
173 )
174 if /I "%MODULE%"=="tools" (
175 nmake -nologo -f Makefile cleantools
176 goto end
177 )
178 @rem clean single module
179 @rem check whether input module name is in module.list file.
180 if not exist module.list (
181 echo Module list info doesn't exist.
182 echo Processing dsc file to generate module list info.
183 nmake -nologo -f Makefile flashmap > NUL 2>&1
184 nmake -nologo -f Makefile makefiles > error.log 2>&1
185 if errorlevel 1 goto builderror
186 )
187 findstr /I /C:" %MODULE% " module.list > NUL
188 if errorlevel 1 (
189 echo.
190 findstr /I /C:"%MODULE%" module.list > NUL
191 if errorlevel 1 goto finderror
192 for /F %%A in ('findstr /I /C:"%MODULE%" module.list') do echo %%A
193 echo.
194 echo Warning!!! Your specified module name can't be found.
195 echo One of the above modules may be what you want to clean.
196 goto end
197 )
198 @rem clean this module
199 nmake -nologo -f module.mak %MODULE%Clean 2>NUL
200 echo.
201 echo Module %MODULE% is cleaned.
202 goto end
203
204 :find
205 @rem find match module name by subname.
206 if "%UPDATE%"=="TRUE" (
207 echo Processing dsc file to update module list info.
208 nmake -nologo -f Makefile flashmap > NUL 2>&1
209 nmake -nologo -f Makefile makefiles > error.log 2>&1
210 if errorlevel 1 goto builderror
211 )
212 if not exist module.list (
213 echo Module list info doesn't exist.
214 echo Processing dsc file to generate module list info.
215 nmake -nologo -f Makefile flashmap > NUL 2>&1
216 nmake -nologo -f Makefile makefiles > error.log 2>&1
217 if errorlevel 1 goto builderror
218 )
219 if "%MODULE%"=="" (
220 @rem display all
221 echo.
222 if "%VERBOSE%"=="TRUE" (
223 type module.list
224 ) else (
225 @rem only output module name without module.inf file name
226 for /F %%A in (module.list) do echo %%A
227 )
228 ) else (
229 @rem display match module name
230 echo.
231 if "%VERBOSE%"=="TRUE" (
232 findstr /I /C:"%MODULE%" module.list
233 if errorlevel 1 goto notfind
234 ) else (
235 findstr /I /C:"%MODULE%" module.list > NUL
236 if errorlevel 1 goto notfind
237 for /F %%A in ('findstr /I /C:"%MODULE%" module.list') do echo %%A
238 )
239 )
240 goto end
241
242 :usage
243 echo build or clean single module based on module name after tools are built.
244 echo.
245 echo build [/r] [/c] [/f] [/h] [modulename]
246 echo.
247 echo build [/r] [modulename]
248 echo build single module, such as build DxeMain.
249 echo If /r is specified, the target will be rebuit after cleaned first.
250 echo if no input modulename or modulename is all, then build all
251 echo Specail build targets: all, fast, tools.
252 echo These special targets may not exist in your tip main makefile.
253 echo build - build all tools and modules
254 echo build all - build all tools and modules
255 echo build fast - build all without FV=NULL modules
256 echo build tools - build all tools.
257 echo.
258 echo build /c [modulename]
259 echo build clean [modulename]
260 echo remove the temp generated files for single module
261 echo if no input modulename, then clean all
262 echo Specail clean targets: all, modules, tools.
263 echo These special targets may not exist in your tip main makefile.
264 echo build /c - clean up all build directories
265 echo build /c all - clean up all build directories and binary dirs.
266 echo build /c modules - clean up all build directories except for tools.
267 echo build /c tools - clean up only tools directory.
268 echo.
269 echo build /f [/a] [/v] [subname]
270 echo find all matched modulename with the sub string of module name.
271 echo option /a re-processes dsc files to update module name list.
272 echo option /v outputs module name and module.inf file name both.
273 echo.
274 echo build /h
275 echo build /?
276 echo display help information.
277 echo.
278 goto end
279
280 :notfind
281 echo Warning!!! Your specified module name can't be found.
282 echo Try to use /f /a options to update module name list.
283 goto end
284
285 :finderror
286 echo Warning!!! Your specified module name can't be found.
287 echo Try to use /f to find modules that you want to build.
288 echo Or use /h to get the helpinfo of this script.
289 goto end
290
291 :builderror
292 if exist error.log type error.log
293 echo.
294 if not exist Tools\ProcessDsc.exe (
295 echo.
296 echo Error!!! Build tools may not be ready. Try to build tools first.
297 echo.
298 )
299 del module.* > NUL 2>&1
300 goto end
301
302 :end
303 if exist error.log del error.log
304 echo on