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