Fix cleanall can't clean all genereated files. Now .i files generated by VfrCompile...
[mirror_edk2.git] / Tools / Conf / BuildMacro.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 -->
12 <project name="common">
13 <!--
14 Macro for intialize some properties. This Macro build will be called before source file build.
15 -->
16 <macrodef name="Build_Init">
17 <sequential>
18 <var name="OBJECTS" value="" />
19 <var name="SDB_FILES" value="" />
20 </sequential>
21 </macrodef>
22
23
24 <!--
25 macro definitions for building files with different types
26 -->
27 <!--
28 C Code
29 -->
30 <macrodef name="Build_CCode">
31 <attribute name="FILEPATH"/>
32 <attribute name="FILENAME"/>
33 <attribute name="FILEEXT" default="c"/>
34
35 <element name="EXTRA.INC" optional="yes"/>
36 <element name="EXTRA.ARG" optional="yes"/>
37
38 <sequential>
39 <var name="FILE_BASENAME" value="@{FILENAME}" />
40 <var name="FILE_PATH" value="@{FILEPATH}" />
41 <mkdir dir="${DEST_DIR_OUTPUT}/@{FILEPATH}"/>
42
43 <if>
44 <available type="file" file="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj"/>
45 <then>
46 <makedeps DepsFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}.dep">
47 <input file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
48 <input file="${DEST_DIR_DEBUG}/AutoGen.h"/>
49 <EXTRA.INC/>
50 </makedeps>
51 </then>
52 </if>
53
54 <OnDependency>
55 <sourcefiles>
56 <file ListFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}.dep"/>
57 </sourcefiles>
58 <targetfiles>
59 <file Name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj"/>
60 </targetfiles>
61
62 <sequential>
63 <cc userdefine="on">
64 <command type="CC" cmd="${CC}" workdir="${DEST_DIR_OUTPUT}" family="${CC_FAMILY}"
65 outputFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj">
66 <EXTRA.INC/>
67 <argument value="${CC_FLAGS}"/>
68 <EXTRA.ARG/>
69 <fileset casesensitive="on" file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
70 </command>
71 </cc>
72 </sequential>
73 </OnDependency>
74 <!-- Since fileset can't scan file start with ./, remove ./ in previous. -->
75 <if>
76 <equals arg1="@{FILEPATH}" arg2="." />
77 <then>
78 <var name="OBJECTS" value="${OBJECTS} @{FILENAME}.obj" />
79 </then>
80 <else>
81 <var name="OBJECTS" value="${OBJECTS} @{FILEPATH}/@{FILENAME}.obj" />
82 </else>
83 </if>
84 </sequential>
85 </macrodef>
86
87
88 <macrodef name="Build_AUTOGEN">
89 <attribute name="FILEPATH"/>
90 <attribute name="FILENAME"/>
91 <attribute name="FILEEXT" default="c"/>
92
93 <element name="EXTRA.INC" optional="yes"/>
94 <element name="EXTRA.ARG" optional="yes"/>
95
96 <sequential>
97 <var name="FILE_BASENAME" value="@{FILENAME}" />
98 <var name="FILE_PATH" value="@{FILEPATH}" />
99 <mkdir dir="${DEST_DIR_OUTPUT}/@{FILEPATH}"/>
100
101 <if>
102 <available type="file" file="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj"/>
103 <then>
104 <makedeps DepsFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}.dep">
105 <input file="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
106 <input file="${DEST_DIR_DEBUG}/AutoGen.h"/>
107 <EXTRA.INC/>
108 </makedeps>
109 </then>
110 </if>
111
112 <OnDependency>
113 <sourcefiles>
114 <file ListFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}.dep"/>
115 </sourcefiles>
116 <targetfiles>
117 <file Name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj"/>
118 </targetfiles>
119
120 <sequential>
121 <cc userdefine="on">
122 <command type="CC" cmd="${CC}" workdir="${DEST_DIR_OUTPUT}" family="${CC_FAMILY}"
123 outputFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj">
124 <EXTRA.INC/>
125 <argument value="${CC_FLAGS}"/>
126 <EXTRA.ARG/>
127 <fileset casesensitive="on" file="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
128 </command>
129 </cc>
130 </sequential>
131 </OnDependency>
132 <!-- Since fileset can't scan file start with ./, remove ./ in previous. -->
133 <if>
134 <equals arg1="@{FILEPATH}" arg2="." />
135 <then>
136 <var name="OBJECTS" value="${OBJECTS} @{FILENAME}.obj" />
137 </then>
138 <else>
139 <var name="OBJECTS" value="${OBJECTS} @{FILEPATH}/@{FILENAME}.obj" />
140 </else>
141 </if>
142 </sequential>
143 </macrodef>
144
145 <macrodef name="Build_DPX">
146 <attribute name="FILEPATH"/>
147 <attribute name="FILENAME"/>
148 <attribute name="FILEEXT" default="dxs"/>
149
150 <element name="EXTRA.INC" optional="yes"/>
151 <element name="EXTRA.ARG" optional="yes"/>
152
153
154 <sequential>
155 <var name="FILE_BASENAME" value="@{FILENAME}" />
156 <var name="FILE_PATH" value="@{FILEPATH}" />
157 <mkdir dir="${DEST_DIR_OUTPUT}/@{FILEPATH}"/>
158
159 <OnDependency>
160 <sourcefiles>
161 <file name="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
162 </sourcefiles>
163 <targetfiles>
164 <file name="${DEST_DIR_OUTPUT}/${BASE_NAME}.depex"/>
165 </targetfiles>
166
167 <sequential>
168 <cc userdefine="on">
169 <command type="CC" cmd="${CC}" workdir="${DEST_DIR_OUTPUT}/@{FILEPATH}" family="${CC_FAMILY}"
170 outputFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.i">
171 <EXTRA.INC/>
172 <argument value="${PP_FLAGS}"/>
173 <fileset casesensitive="on" file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
174 </command>
175 </cc>
176
177 <gendepex inputFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.i" outputFile="${DEST_DIR_OUTPUT}/${BASE_NAME}.depex"/>
178 </sequential>
179 </OnDependency>
180 </sequential>
181 </macrodef>
182
183 <macrodef name="Build_ASM">
184 <attribute name="FILEPATH"/>
185 <attribute name="FILENAME"/>
186 <attribute name="FILEEXT" default="asm"/>
187
188 <element name="EXTRA.INC" optional="yes"/>
189 <element name="EXTRA.ARG" optional="yes"/>
190
191 <!-- Dispath ASM file, there are three type.
192 asm - Build_Assembly
193 S - Build_Gcc_Assembly
194 s - Build_Ipf_Assembly -->
195 <sequential>
196 <if>
197 <equals arg1="@{FILEEXT}" arg2="asm" />
198 <then>
199 <Build_Assembly FILEPATH="@{FILEPATH}" FILENAME="@{FILENAME}" FILEEXT="@{FILEEXT}">
200 <EXTRA.INC.1><EXTRA.INC /></EXTRA.INC.1>
201 <EXTRA.ARG.1><EXTRA.ARG /></EXTRA.ARG.1>
202 </Build_Assembly>
203 </then>
204 <elseif>
205 <equals arg1="@{FILEEXT}" arg2="S" />
206 <then>
207 <Build_Gcc_Assembly FILEPATH="@{FILEPATH}" FILENAME="@{FILENAME}" FILEEXT="@{FILEEXT}">
208 <EXTRA.INC.1><EXTRA.INC /></EXTRA.INC.1>
209 <EXTRA.ARG.1><EXTRA.ARG /></EXTRA.ARG.1>
210 </Build_Gcc_Assembly>
211 </then>
212 </elseif>
213 <elseif>
214 <equals arg1="@{FILEEXT}" arg2="s" />
215 <then>
216 <Build_IPF_Assembly_Code FILEPATH="@{FILEPATH}" FILENAME="@{FILENAME}" FILEEXT="@{FILEEXT}">
217 <EXTRA.INC.1><EXTRA.INC /></EXTRA.INC.1>
218 <EXTRA.ARG.1><EXTRA.ARG /></EXTRA.ARG.1>
219 </Build_IPF_Assembly_Code>
220 </then>
221 </elseif>
222 </if>
223 </sequential>
224 </macrodef>
225
226 <!--
227 IA32/x64 Assembly
228 -->
229 <macrodef name="Build_Assembly">
230 <attribute name="FILEPATH"/>
231 <attribute name="FILENAME"/>
232 <attribute name="FILEEXT" default="asm"/>
233
234 <element name="EXTRA.INC.1" optional="yes"/>
235 <element name="EXTRA.ARG.1" optional="yes"/>
236
237 <sequential>
238 <var name="FILE_BASENAME" value="@{FILENAME}" />
239 <var name="FILE_PATH" value="@{FILEPATH}" />
240 <mkdir dir="${DEST_DIR_OUTPUT}/@{FILEPATH}"/>
241
242 <OnDependency>
243 <sourcefiles>
244 <file Name="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
245 </sourcefiles>
246 <targetfiles>
247 <file Name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj"/>
248 </targetfiles>
249
250 <sequential>
251 <cc userdefine="on">
252 <command type="PP" cmd="${PP}" workdir="${DEST_DIR_OUTPUT}/@{FILEPATH}" family="${PP_FAMILY}">
253 <EXTRA.INC.1/>
254 <argument value="${PP_FLAGS}"/>
255 <fileset casesensitive="on" file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
256 </command>
257 </cc>
258
259 <replaceregexp file="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.i"
260 match="^(#line +1 +.*@{FILEPATH}/@{FILENAME}\.@{FILEEXT}&quot;).+\1"
261 replace=";"
262 flags="gs"/>
263 <replaceregexp file="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.i"
264 match="^(#line .*)$"
265 replace="; \1"
266 byline="true"/>
267 <replaceregexp file="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.i"
268 match="([^_a-zA-Z])0x([0-9a-fA-F]+)"
269 replace="\10\2h"
270 flags="g"
271 byline="true"/>
272
273 <cc userdefine="on">
274 <command type="ASM" cmd="${ASM}" workdir="${DEST_DIR_OUTPUT}" family="${ASM_FAMILY}"
275 outputFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj">
276 <EXTRA.INC.1/>
277
278 <argument value="${ASM_FLAGS}"/>
279 <EXTRA.ARG.1/>
280
281 <fileset casesensitive="on" file="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.i"/>
282 </command>
283 </cc>
284 </sequential>
285 </OnDependency>
286 <!-- Since fileset can't scan file start with ./, remove ./ in previous. -->
287 <if>
288 <equals arg1="@{FILEPATH}" arg2="." />
289 <then>
290 <var name="OBJECTS" value="${OBJECTS} @{FILENAME}.obj" />
291 </then>
292 <else>
293 <var name="OBJECTS" value="${OBJECTS} @{FILEPATH}/@{FILENAME}.obj" />
294 </else>
295 </if>
296 </sequential>
297 </macrodef>
298
299 <!--
300 Build GCC assembly code
301 -->
302 <macrodef name="Build_Gcc_Assembly">
303 <attribute name="FILEPATH"/>
304 <attribute name="FILENAME"/>
305 <attribute name="FILEEXT" default="asm"/>
306
307 <element name="EXTRA.INC.1" optional="yes"/>
308 <element name="EXTRA.ARG.1" optional="yes"/>
309
310 <sequential>
311 <var name="FILE_BASENAME" value="@{FILENAME}" />
312 <var name="FILE_PATH" value="@{FILEPATH}" />
313 <mkdir dir="${DEST_DIR_OUTPUT}/@{FILEPATH}"/>
314
315 <OnDependency>
316 <sourcefiles>
317 <file Name="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
318 </sourcefiles>
319 <targetfiles>
320 <file Name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj"/>
321 </targetfiles>
322
323 <sequential>
324 <cc userdefine="on">
325 <command type="ASM" cmd="${ASM}" workdir="${DEST_DIR_OUTPUT}" family="${ASM_FAMILY}"
326 outputFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj">
327 <EXTRA.INC.1/>
328
329 <argument value="${ASM_FLAGS}"/>
330 <EXTRA.ARG.1/>
331
332 <fileset casesensitive="on" file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
333 </command>
334 </cc>
335 </sequential>
336 </OnDependency>
337 <!-- Since fileset can't scan file start with ./, remove ./ in previous. -->
338 <if>
339 <equals arg1="@{FILEPATH}" arg2="." />
340 <then>
341 <var name="OBJECTS" value="${OBJECTS} @{FILENAME}.obj" />
342 </then>
343 <else>
344 <var name="OBJECTS" value="${OBJECTS} @{FILEPATH}/@{FILENAME}.obj" />
345 </else>
346 </if>
347 </sequential>
348 </macrodef>
349
350 <!--
351 IPF Assembly
352 -->
353 <macrodef name="Build_IPF_Assembly_Code">
354 <attribute name="FILEPATH"/>
355 <attribute name="FILENAME"/>
356 <attribute name="FILEEXT" default="s"/>
357
358 <element name="EXTRA.INC.1" optional="yes"/>
359 <element name="EXTRA.ARG.1" optional="yes"/>
360
361 <sequential>
362 <mkdir dir="${DEST_DIR_OUTPUT}/@{FILEPATH}"/>
363
364 <if>
365 <available type="file" file="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj"/>
366 <then>
367 <makedeps DepsFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}.dep">
368 <input file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
369 <EXTRA.INC.1/>
370 </makedeps>
371 </then>
372 </if>
373
374 <OnDependency>
375 <sourcefiles>
376 <file listfile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}.dep"/>
377 </sourcefiles>
378 <targetfiles>
379 <file name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj"/>
380 </targetfiles>
381
382 <sequential>
383 <cc userdefine="on">
384 <command type="PP" cmd="${PP}" workdir="${DEST_DIR_OUTPUT}/@{FILEPATH}" family="${PP_FAMILY}">
385 <EXTRA.INC.1/>
386 <argument value="${PP_FLAGS}"/>
387 <fileset casesensitive="on" file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
388 </command>
389 </cc>
390
391 <cc userdefine="on">
392 <command type="ASM" cmd="${ASM}" workdir="${DEST_DIR_OUTPUT}" family="${ASM_FAMILY}"
393 includepathDelimiter="-I" outputDelimiter="-o"
394 outputFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj">
395 <EXTRA.INC.1/>
396 <argument value="${ASM_FLAGS}"/>
397 <EXTRA.ARG.1/>
398 <fileset casesensitive="on" file="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.i"/>
399 </command>
400 </cc>
401 </sequential>
402 </OnDependency>
403 <!-- Since fileset can't scan file start with ./, remove ./ in previous. -->
404 <if>
405 <equals arg1="@{FILEPATH}" arg2="." />
406 <then>
407 <var name="OBJECTS" value="${OBJECTS} @{FILENAME}.obj" />
408 </then>
409 <else>
410 <var name="OBJECTS" value="${OBJECTS} @{FILEPATH}/@{FILENAME}.obj" />
411 </else>
412 </if>
413 </sequential>
414 </macrodef>
415
416
417 <macrodef name="Build_IPF_PP_Code">
418 <attribute name="FILEPATH"/>
419 <attribute name="FILENAME"/>
420 <attribute name="FILEEXT" default="i"/>
421
422 <element name="EXTRA.INC" optional="yes"/>
423 <element name="EXTRA.ARG" optional="yes"/>
424
425 <sequential>
426 <mkdir dir="${DEST_DIR_OUTPUT}/@{FILEPATH}"/>
427
428 <cc userdefine="on">
429 <command type="ASM" includepathDelimiter="-I">
430 <includepath path="${WORKSPACE_DIR}"/>
431 <includepath path="${MODULE_DIR}"/>
432 <includepath path="${MODULE_DIR}/${ARCH}"/>
433 <EXTRA.INC/>
434
435 <argument value="${ASM_FLAGS}"/>
436 <EXTRA.ARG/>
437 <OutputFile File="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj"/>
438
439 <fileset casesensitive="on" file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
440 </command>
441 </cc>
442 </sequential>
443 </macrodef>
444
445
446 <!--
447 Library private HashMap map = new HashMap();
448 -->
449 <macrodef name="Build_Library">
450 <attribute name="FILENAME" />
451 <attribute name="FILEEXT" default="obj"/>
452
453 <sequential>
454 <var name="FILE_BASENAME" value="@{FILENAME}" />
455 <var name="FILE_PATH" value="." />
456 <mkdir dir="${BIN_DIR}"/>
457
458 <OnDependency>
459 <sourcefiles>
460 <fileset dir="${DEST_DIR_OUTPUT}" includes="${OBJECTS}" />
461 </sourcefiles>
462 <targetfiles>
463 <file name="${BIN_DIR}/@{FILENAME}.lib"/>
464 </targetfiles>
465
466 <sequential>
467 <cc userdefine="on">
468 <command type="SLINK" cmd="${SLINK}" family="${SLINK_FAMILY}"
469 outputFile="${BIN_DIR}/@{FILENAME}.lib">
470 <argument value="${SLINK_FLAGS}"/>
471
472 <fileset dir="${DEST_DIR_OUTPUT}" includes="${OBJECTS}"/>
473 </command>
474 </cc>
475 </sequential>
476 </OnDependency>
477 </sequential>
478 </macrodef>
479
480 <!--
481 Unicode -> .sdb
482 -->
483 <macrodef name="Build_UNI">
484 <attribute name="FILEPATH"/>
485 <attribute name="FILENAME"/>
486 <attribute name="FILEEXT" default="uni"/>
487
488 <element name="EXTRA.INC" optional="yes"/>
489 <element name="EXTRA.ARG" optional="yes"/>
490
491 <sequential>
492 <mkdir dir="${DEST_DIR_OUTPUT}/@{FILEPATH}"/>
493
494 <OnDependency>
495 <sourcefiles>
496 <file name="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
497 </sourcefiles>
498 <targetfiles>
499 <file name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.sdb"/>
500 </targetfiles>
501
502 <sequential>
503 <strgather commandtype="parse" newdatabase="true">
504 <database name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.sdb"/>
505 <EXTRA.INC/>
506 <EXTRA.ARG/>
507 <inputfile name="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
508 </strgather>
509 </sequential>
510 </OnDependency>
511
512 <var name="SDB_FILES" value="${SDB_FILES}, ${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.sdb"/>
513 </sequential>
514 </macrodef>
515
516 <!--
517 .sdb(s) -> .c, .h -> .obj
518 -->
519 <macrodef name="Build_Unicode_Database">
520 <attribute name="FILEPATH"/>
521 <attribute name="FILENAME"/>
522 <attribute name="FILEEXT" default="sdb"/>
523
524 <element name="EXTRA.INC" optional="yes"/>
525 <element name="EXTRA.ARG" optional="yes"/>
526
527 <sequential>
528 <var name="FILE_BASENAME" value="@{FILENAME}" />
529 <var name="FILE_PATH" value="@{FILEPATH}" />
530 <OnDependency>
531 <sourcefiles>
532 <file list="${SDB_FILES}"/>
533 <file list="${SOURCE_FILES}"/>
534 </sourcefiles>
535 <targetfiles>
536 <file name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.sdb"/>
537 </targetfiles>
538
539 <sequential>
540 <strgather commandtype="scan" outputdatabase="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.sdb" verbose="read">
541 <skipext name=".uni"/>
542 <skipext name=".h"/>
543 <database list="${SDB_FILES}"/>
544 <inputfile name="${SOURCE_FILES}"/>
545 </strgather>
546 </sequential>
547 </OnDependency>
548
549 <OnDependency>
550 <sourcefiles>
551 <file name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.sdb"/>
552 </sourcefiles>
553 <targetfiles>
554 <file name="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}StrDefs.h"/>
555 <file name="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}Strings.hpk"/>
556 <file name="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}Strings.c"/>
557 </targetfiles>
558
559 <sequential>
560 <strgather basename="@{FILENAME}Strings" commandtype="dump"
561 outputdefines="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}StrDefs.h"
562 outputhpk="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}Strings.hpk"
563 outputstring="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}Strings.c">
564 <database name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.sdb"/>
565 </strgather>
566 </sequential>
567 </OnDependency>
568
569 <OnDependency>
570 <sourcefiles>
571 <file name="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}Strings.c"/>
572 </sourcefiles>
573 <targetfiles>
574 <file name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}Strings.obj"/>
575 </targetfiles>
576
577 <sequential>
578 <cc userdefine="on">
579 <command type="CC" cmd="${CC}" workdir="${DEST_DIR_OUTPUT}" family="${CC_FAMILY}"
580 includepathDelimiter="-I"
581 outputFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}Strings.obj">
582 <argument value="${CC_FLAGS}"/>
583 <EXTRA.INC />
584 <fileset casesensitive="on" file="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}Strings.c"/>
585 </command>
586 </cc>
587 </sequential>
588 </OnDependency>
589 <!-- The Module contain Unicode file need those flags -->
590 <var name="CC_FLAGS" value="${CC_FLAGS} /DSTRING_ARRAY_NAME=${BASE_NAME}Strings /FI${DEST_DIR_DEBUG}/${BASE_NAME}StrDefs.h" />
591
592 <!-- Since fileset can't scan file start with ./, remove ./ in previous. -->
593 <if>
594 <equals arg1="@{FILEPATH}" arg2="." />
595 <then>
596 <var name="OBJECTS" value="${OBJECTS} @{FILENAME}Strings.obj" />
597 </then>
598 <else>
599 <var name="OBJECTS" value="${OBJECTS} @{FILEPATH}/@{FILENAME}Strings.obj" />
600 </else>
601 </if>
602 </sequential>
603 </macrodef>
604
605 <!--
606 Vfr
607 -->
608 <macrodef name="Build_VFR">
609 <attribute name="FILEPATH"/>
610 <attribute name="FILENAME"/>
611 <attribute name="FILEEXT" default="vfr"/>
612
613 <element name="EXTRA.INC" optional="yes"/>
614 <element name="EXTRA.ARG" optional="yes"/>
615
616 <sequential>
617 <mkdir dir="${DEST_DIR_DEBUG}/@{FILEPATH}"/>
618
619 <if>
620 <available type="file" file="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj"/>
621 <then>
622 <makedeps DepsFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}.dep">
623 <input file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
624 <EXTRA.INC/>
625 </makedeps>
626 </then>
627 </if>
628
629 <OnDependency>
630 <sourcefiles>
631 <file listfile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}.dep"/>
632 </sourcefiles>
633 <targetfiles>
634 <file name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj"/>
635 </targetfiles>
636
637 <sequential>
638 <vfrcompile createIfrBinFile="on" createListFile="on" outPutDir="${DEST_DIR_DEBUG}/@{FILEPATH}" vfrFile="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}">
639 <EXTRA.INC/>
640 </vfrcompile>
641
642 <cc userdefine="on">
643 <command type="CC" cmd="${CC}" workdir="${DEST_DIR_OUTPUT}"
644 includepathDelimiter="-I" family="${CC_FAMILY}"
645 outputFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.obj" >
646 <argument value="${CC_FLAGS}"/>
647 <EXTRA.INC/>
648 <EXTRA.ARG/>
649 <fileset casesensitive="on" file="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}.c"/>
650 </command>
651 </cc>
652 </sequential>
653 </OnDependency>
654 <!-- Since fileset can't scan file start with ./, remove ./ in previous. -->
655 <if>
656 <equals arg1="@{FILEPATH}" arg2="." />
657 <then>
658 <var name="OBJECTS" value="${OBJECTS} @{FILENAME}.obj" />
659 </then>
660 <else>
661 <var name="OBJECTS" value="${OBJECTS} @{FILEPATH}/@{FILENAME}.obj" />
662 </else>
663 </if>
664 </sequential>
665 </macrodef>
666
667 <!--
668 DUMMY
669 -->
670 <macrodef name="Build_DUMMY">
671 <attribute name="FILEPATH"/>
672 <attribute name="FILENAME"/>
673 <attribute name="FILEEXT"/>
674
675 <element name="EXTRA.INC" optional="yes"/>
676 <element name="EXTRA.ARG" optional="yes"/>
677
678 <sequential>
679 <echo message="Ignoring ${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
680 </sequential>
681 </macrodef>
682
683 <!--############################################################################
684 Build Sections
685 #############################################################################-->
686 <!--
687 DLL
688 -->
689 <macrodef name="GenDll">
690 <attribute name="FILEPATH"/>
691 <attribute name="FILENAME"/>
692 <attribute name="FILEEXT"/>
693
694 <element name="LIB.ARG" optional="yes"/>
695 <element name="LINK.ARG" optional="yes"/>
696
697 <sequential>
698 <var name="FILE_BASENAME" value="@{FILENAME}" />
699 <var name="FILE_PATH" value="@{FILEPATH}" />
700 <OnDependency>
701 <sourcefiles>
702 <file list="${LIBS}"/>
703 <fileset dir="${DEST_DIR_OUTPUT}" includes="${OBJECTS}" />
704 </sourcefiles>
705 <targetfiles>
706 <file name="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}.dll"/>
707 </targetfiles>
708
709 <sequential>
710 <cc userdefine="on">
711 <command type="SLINK" cmd="${SLINK}" family="${SLINK_FAMILY}"
712 outputFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}Local.lib">
713 <argument value="${SLINK_FLAGS}"/>
714
715 <fileset dir="${DEST_DIR_OUTPUT}" includes="${OBJECTS}"/>
716 </command>
717 </cc>
718 <cc userdefine="on">
719 <command type="DLINK" cmd="${DLINK}" family="${DLINK_FAMILY}"
720 outputFile="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}.dll" >
721 <argument value="${DLINK_FLAGS}"/>
722 <libset libs="${LIBS}"/>
723 <libset libs="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}Local.lib"/>
724 <libset libs="${DLINK_SPATH}" />
725 <LINK.ARG/>
726 </command>
727 </cc>
728 </sequential>
729 </OnDependency>
730 </sequential>
731 </macrodef>
732
733 <!--
734 EFI
735 -->
736 <macrodef name="GenEfi">
737 <attribute name="FILEPATH"/>
738 <attribute name="FILENAME"/>
739 <attribute name="FILEEXT" default="dll"/>
740
741 <sequential>
742 <OnDependency>
743 <sourcefiles>
744 <file name="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
745 </sourcefiles>
746 <targetfiles>
747 <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"/>
748 </targetfiles>
749
750 <sequential>
751 <fwimage componentType="${MODULE_TYPE}" outImage="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"
752 peImage="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}" time="0"/>
753 </sequential>
754 </OnDependency>
755 </sequential>
756 </macrodef>
757
758 <!--
759 EFI_SECTION_FREEFORM_SUBTYPE_GUID
760 EFI_SECTION_VERSION
761 EFI_SECTION_USER_INTERFACE
762 EFI_SECTION_DXE_DEPEX
763 EFI_SECTION_PEI_DEPEX
764 EFI_SECTION_PE32
765 EFI_SECTION_PIC
766 EFI_SECTION_TE
767 EFI_SECTION_RAW
768 EFI_SECTION_COMPRESSION
769 EFI_SECTION_GUID_DEFINED
770 EFI_SECTION_COMPATIBILITY16
771 EFI_SECTION_FIRMWARE_VOLUME_IMAGE
772 -->
773 <!--
774 EFI_SECTION_PE32
775 -->
776
777 <macrodef name="EFI_SECTION_TE">
778 <attribute name="FILEPATH"/>
779 <attribute name="FILENAME"/>
780 <attribute name="FILEEXT" default="" />
781
782 <element name="PRE.PROCESS" optional="yes"/>
783 <element name="POST.PROCESS" optional="yes"/>
784
785 <sequential>
786 <PRE.PROCESS/>
787 <if>
788 <not>
789 <equals arg1="${LIBS}" arg2=""/>
790 </not>
791
792 <then>
793 <GenDll FILEPATH="." FILENAME="@{FILENAME}" FILEEXT="">
794 <LIB.ARG></LIB.ARG>
795 <LINK.ARG></LINK.ARG>
796 </GenDll>
797
798 <GenEfi FILEPATH="." FILENAME="@{FILENAME}" FILEEXT="dll"/>
799 </then>
800 </if>
801
802 <OnDependency>
803 <sourcefiles>
804 <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"/>
805 </sourcefiles>
806 <targetfiles>
807 <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.tes"/>
808 </targetfiles>
809
810 <sequential>
811 <copy file="${DEST_DIR_OUTPUT}/@{FILENAME}.efi" tofile="${BIN_DIR}/@{FILENAME}.efi" />
812 <copy file="${DEST_DIR_OUTPUT}/@{FILENAME}.efi" tofile="${DEST_DIR_DEBUG}/@{FILENAME}.efi" />
813 <genteimage Dump="false" Verbose="false" OutputDir="" OutputFile="${DEST_DIR_OUTPUT}/@{FILENAME}.te" InputFile="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"/>
814 <copy file="${DEST_DIR_OUTPUT}/@{FILENAME}.te" tofile="${BIN_DIR}/@{FILENAME}.te" />
815 <gensection inputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.te"
816 outputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.tes"
817 sectiontype="EFI_SECTION_TE"/>
818 <POST.PROCESS/>
819 </sequential>
820 </OnDependency>
821 </sequential>
822 </macrodef>
823
824 <macrodef name="EFI_SECTION_PE32">
825 <attribute name="FILEPATH"/>
826 <attribute name="FILENAME"/>
827 <attribute name="FILEEXT" default="" />
828
829 <element name="PRE.PROCESS" optional="yes"/>
830 <element name="POST.PROCESS" optional="yes"/>
831
832 <sequential>
833 <PRE.PROCESS/>
834 <if>
835 <not>
836 <!-- TBD ${OBJECTS} -->
837 <equals arg1="${LIBS}" arg2=""/>
838 </not>
839
840 <then>
841 <GenDll FILEPATH="." FILENAME="@{FILENAME}" FILEEXT="">
842 <LIB.ARG></LIB.ARG>
843 <LINK.ARG></LINK.ARG>
844 </GenDll>
845
846 <GenEfi FILEPATH="." FILENAME="@{FILENAME}" FILEEXT="dll"/>
847 </then>
848 </if>
849
850 <OnDependency>
851 <sourcefiles>
852 <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"/>
853 </sourcefiles>
854 <targetfiles>
855 <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.pe32"/>
856 </targetfiles>
857
858 <sequential>
859 <copy file="${DEST_DIR_OUTPUT}/@{FILENAME}.efi" tofile="${BIN_DIR}/@{FILENAME}.efi" />
860
861 <gensection inputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"
862 outputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.pe32"
863 sectiontype="EFI_SECTION_PE32"/>
864
865 <POST.PROCESS/>
866 </sequential>
867 </OnDependency>
868 <copy file="${DEST_DIR_OUTPUT}/@{FILENAME}.efi" tofile="${DEST_DIR_DEBUG}/@{FILENAME}.efi" />
869 </sequential>
870 </macrodef>
871
872 <!--
873 EFI_SECTION_VERSION
874 -->
875 <macrodef name="EFI_SECTION_VERSION">
876 <attribute name="FILEPATH"/>
877 <attribute name="FILENAME"/>
878 <attribute name="FILEEXT" default="" />
879 <attribute name="VERSION" default="0000"/>
880
881 <element name="PRE.PROCESS" optional="yes"/>
882 <element name="POST.PROCESS" optional="yes"/>
883
884 <sequential>
885 <if>
886 <not>
887 <available type="file" file="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.ver"/>
888 </not>
889
890 <then>
891 <PRE.PROCESS/>
892 <gensection outputfile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.ver"
893 versionnum="@{VERSION}"
894 sectiontype="EFI_SECTION_VERSION"/>
895 <POST.PROCESS/>
896 </then>
897 </if>
898 </sequential>
899 </macrodef>
900
901 <!--
902 EFI_SECTION_USER_INTERFACE
903 -->
904 <macrodef name="EFI_SECTION_USER_INTERFACE">
905 <attribute name="FILEPATH"/>
906 <attribute name="FILENAME"/>
907 <attribute name="FILEEXT" default="" />
908 <attribute name="UI" default="${BASE_NAME}"/>
909
910 <element name="PRE.PROCESS" optional="yes"/>
911 <element name="POST.PROCESS" optional="yes"/>
912
913 <sequential>
914 <if>
915 <not>
916 <available type="file" file="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.ui"/>
917 </not>
918
919 <then>
920 <PRE.PROCESS/>
921 <gensection interfacestring="@{UI}"
922 outputfile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.ui"
923 sectiontype="EFI_SECTION_USER_INTERFACE"/>
924 <POST.PROCESS/>
925 </then>
926 </if>
927 </sequential>
928 </macrodef>
929
930 <!--
931 EFI_SECTION_DXE_DEPEX
932 -->
933 <macrodef name="EFI_SECTION_DXE_DEPEX">
934 <attribute name="FILEPATH"/>
935 <attribute name="FILENAME"/>
936 <attribute name="FILEEXT" default="dxs"/>
937
938 <element name="PRE.PROCESS" optional="yes"/>
939 <element name="POST.PROCESS" optional="yes"/>
940
941 <sequential>
942 <PRE.PROCESS/>
943
944 <if>
945 <available type="file" file="${DEST_DIR_OUTPUT}/@{FILENAME}.depex"/>
946 <then>
947 <OnDependency>
948 <sourcefiles>
949 <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.depex"/>
950 </sourcefiles>
951 <targetfiles>
952 <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.dpx"/>
953 </targetfiles>
954 <sequential>
955 <gensection inputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.depex"
956 outputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.dpx"
957 sectiontype="EFI_SECTION_DXE_DEPEX"/>
958 </sequential>
959 </OnDependency>
960 </then>
961 <else>
962 <if>
963 <not>
964 <available type="file" file="${DEST_DIR_OUTPUT}/@{FILENAME}.dpx"/>
965 </not>
966 <then>
967 <touch file="${DEST_DIR_OUTPUT}/@{FILENAME}.dpx"/>
968 </then>
969 </if>
970 </else>
971 </if>
972
973 <POST.PROCESS/>
974 </sequential>
975 </macrodef>
976
977 <!--
978 EFI_SECTION_PEI_DEPEX
979 -->
980 <macrodef name="EFI_SECTION_PEI_DEPEX">
981 <attribute name="FILEPATH"/>
982 <attribute name="FILENAME"/>
983 <attribute name="FILEEXT" default="dxs"/>
984
985 <element name="PRE.PROCESS" optional="yes"/>
986 <element name="POST.PROCESS" optional="yes"/>
987 <sequential>
988 <PRE.PROCESS/>
989 <if>
990 <available type="file" file="${DEST_DIR_OUTPUT}/@{FILENAME}.depex"/>
991 <then>
992 <OnDependency>
993 <sourcefiles>
994 <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.depex"/>
995 </sourcefiles>
996 <targetfiles>
997 <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.dpx"/>
998 </targetfiles>
999
1000 <sequential>
1001 <gensection inputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.depex"
1002 outputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.dpx"
1003 sectiontype="EFI_SECTION_PEI_DEPEX"/>
1004 </sequential>
1005 </OnDependency>
1006
1007 </then>
1008 <else>
1009 <if>
1010 <not>
1011 <available type="file" file="${DEST_DIR_OUTPUT}/@{FILENAME}.dpx"/>
1012 </not>
1013 <then>
1014 <touch file="${DEST_DIR_OUTPUT}/@{FILENAME}.dpx"/>
1015 </then>
1016 </if>
1017 </else>
1018 </if>
1019 <POST.PROCESS/>
1020 </sequential>
1021 </macrodef>
1022
1023
1024 <!--
1025 EFI_SECTION_RAW
1026 -->
1027 <macrodef name="EFI_SECTION_RAW">
1028 <attribute name="FILEPATH"/>
1029 <attribute name="FILENAME"/>
1030 <attribute name="FILEEXT" default="bin"/>
1031
1032 <element name="PRE.PROCESS" optional="yes"/>
1033 <element name="POST.PROCESS" optional="yes"/>
1034
1035 <sequential>
1036 <OnDependency>
1037 <sourcefiles>
1038 <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.@{FILEEXT}"/>
1039 </sourcefiles>
1040 <targetfiles>
1041 <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.sec"/>
1042 </targetfiles>
1043
1044 <sequential>
1045 <PRE.PROCESS/>
1046 <gensection inputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.@{FILEEXT}"
1047 outputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.sec"
1048 sectiontype="EFI_SECTION_RAW"/>
1049 <POST.PROCESS/>
1050 </sequential>
1051 </OnDependency>
1052 </sequential>
1053 </macrodef>
1054
1055 <!--
1056 EFI_SECTION_FIRMWARE_VOLUME_IMAGE
1057 -->
1058 <macrodef name="EFI_SECTION_FIRMWARE_VOLUME_IMAGE">
1059 <attribute name="FILEPATH"/>
1060 <attribute name="FILENAME"/>
1061 <attribute name="FILEEXT" default="fv"/>
1062
1063 <element name="PRE.PROCESS" optional="yes"/>
1064 <element name="POST.PROCESS" optional="yes"/>
1065
1066 <sequential>
1067 <OnDependency>
1068 <sourcefiles>
1069 <file name="${FV_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/>
1070 </sourcefiles>
1071 <targetfiles>
1072 <file name="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}fv.sec"/>
1073 </targetfiles>
1074
1075 <sequential>
1076 <PRE.PROCESS/>
1077
1078 <copy file="${FV_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
1079 tofile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
1080 overwrite="true"/>
1081 <gensection inputfile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
1082 outputfile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}fv.sec"
1083 sectiontype="EFI_SECTION_FIRMWARE_VOLUME_IMAGE"/>
1084
1085 <POST.PROCESS/>
1086 </sequential>
1087 </OnDependency>
1088 </sequential>
1089 </macrodef>
1090
1091 <!--
1092 Binary
1093 -->
1094 <macrodef name="Build_Binary">
1095 <attribute name="FILEPATH"/>
1096 <attribute name="FILENAME"/>
1097 <attribute name="FILEEXT" default="bin"/>
1098
1099 <element name="EXTRA.INC" optional="yes"/>
1100 <element name="EXTRA.ARG" optional="yes"/>
1101
1102 <sequential>
1103 <copy file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
1104 tofile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.bin"/>
1105 </sequential>
1106 </macrodef>
1107
1108 <!--
1109 Graphics (bmp, ...)
1110 -->
1111 <macrodef name="Build_Graphics">
1112 <attribute name="FILEPATH"/>
1113 <attribute name="FILENAME"/>
1114 <attribute name="FILEEXT" default="bmp"/>
1115
1116 <element name="EXTRA.INC" optional="yes"/>
1117 <element name="EXTRA.ARG" optional="yes"/>
1118
1119 <sequential>
1120 <mkdir dir="${MODULE_DIR}/@{FILEPATH}" />
1121 <copy file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
1122 tofile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.bin"/>
1123 </sequential>
1124 </macrodef>
1125 <macrodef name="Build_EFI">
1126 <attribute name="FILEPATH"/>
1127 <attribute name="FILENAME"/>
1128 <attribute name="FILEEXT" default="efi"/>
1129
1130 <element name="EXTRA.INC" optional="yes"/>
1131 <element name="EXTRA.ARG" optional="yes"/>
1132
1133 <sequential>
1134 <mkdir dir="${MODULE_DIR}/@{FILEPATH}" />
1135 <copy file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
1136 tofile="${DEST_DIR_OUTPUT}/${BASE_NAME}.efi"/>
1137 </sequential>
1138 </macrodef>
1139 </project>