- Fixed PVCS tracker 484 by merging the GenDll and GenEfi macro in BuildMacro.xml to GenEfi, moving out GenDll and GenEfi macro calling inside macro EFI_SECTION_TE and EFI_SECTION_PE32, and generating the calling of GenEfi macro according to the module type (binary or library).

- Cleaned the coding style of AutoGen.java


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2429 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jwang36
2007-03-08 01:44:17 +00:00
parent 64b41a0710
commit a30ae9faea
3 changed files with 147 additions and 190 deletions

View File

@ -974,16 +974,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
</sequential> </sequential>
</macrodef> </macrodef>
<!--############################################################################
Build Sections
#############################################################################-->
<!-- <!--
DLL Generate efi file
--> -->
<macrodef name="GenDll"> <macrodef name="GenEfi">
<attribute name="FILEPATH"/> <attribute name="FILEPATH"/>
<attribute name="FILENAME"/> <attribute name="FILENAME"/>
<attribute name="FILEEXT"/> <attribute name="FILEEXT" default="efi"/>
<element name="LIB.ARG" optional="yes"/> <element name="LIB.ARG" optional="yes"/>
<element name="LINK.ARG" optional="yes"/> <element name="LINK.ARG" optional="yes"/>
@ -997,102 +994,152 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<fileset dir="${DEST_DIR_OUTPUT}" includes="${OBJECTS}" /> <fileset dir="${DEST_DIR_OUTPUT}" includes="${OBJECTS}" />
</sourcefiles> </sourcefiles>
<targetfiles> <targetfiles>
<file name="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}.dll"/> <file name="${DEST_DIR_DEBUG}/@{FILENAME}.efi"/>
</targetfiles> </targetfiles>
<sequential> <sequential>
<!-- Generate a temporary lib file for object files -->
<cc userdefine="on"> <cc userdefine="on">
<command type="SLINK" cmd="${SLINK}" family="${SLINK_FAMILY}" dpath="${SLINK_DPATH}" <command type="SLINK" cmd="${SLINK}" family="${SLINK_FAMILY}" dpath="${SLINK_DPATH}"
outputFile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}Local.lib" outputFile="${DEST_DIR_OUTPUT}/@{FILENAME}Local.lib"
libpath="${SLINKLIBPATH}" include="${SLINK_INCLUDEPATH}"> libpath="${SLINKLIBPATH}" include="${SLINK_INCLUDEPATH}">
<argument value="${SLINK_FLAGS}"/> <argument value="${SLINK_FLAGS}"/>
<fileset dir="${DEST_DIR_OUTPUT}" includes="${OBJECTS}"/> <fileset dir="${DEST_DIR_OUTPUT}" includes="${OBJECTS}"/>
</command> </command>
</cc> </cc>
<!-- Link the temporary lib file with dependent libraries -->
<cc userdefine="on"> <cc userdefine="on">
<command type="DLINK" cmd="${DLINK}" family="${DLINK_FAMILY}" <command type="DLINK" cmd="${DLINK}" family="${DLINK_FAMILY}"
outputFile="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}.dll" dpath="${DLINK_DPATH}" outputFile="${DEST_DIR_DEBUG}/@{FILENAME}.dll" dpath="${DLINK_DPATH}"
libpath="${DLINK_LIBPATH}" include="${DLINK_INCLUDEPATH}"> libpath="${DLINK_LIBPATH}" include="${DLINK_INCLUDEPATH}">
<argument value="${DLINK_FLAGS}"/> <argument value="${DLINK_FLAGS}"/>
<libset libs="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}Local.lib ${LIBS} ${DLINK_SPATH}"/> <libset libs="${DEST_DIR_OUTPUT}/@{FILENAME}Local.lib ${LIBS} ${DLINK_SPATH}"/>
<LINK.ARG/> <LINK.ARG/>
</command> </command>
</cc> </cc>
<!-- Convert the dll file to efi file -->
<fwimage componentType="${MODULE_TYPE}" outImage="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"
peImage="${DEST_DIR_DEBUG}/@{FILENAME}.dll" time="0"/>
<!-- Copy the efi file to BIN and OUTPUT directory -->
<copy file="${DEST_DIR_OUTPUT}/@{FILENAME}.efi" tofile="${BIN_DIR}/@{FILENAME}.efi" />
<copy file="${DEST_DIR_OUTPUT}/@{FILENAME}.efi" tofile="${DEST_DIR_DEBUG}/@{FILENAME}.efi" />
</sequential> </sequential>
</OnDependency> </OnDependency>
</sequential> </sequential>
</macrodef> </macrodef>
<!-- <!--
EFI Binary
--> -->
<macrodef name="GenEfi"> <macrodef name="Build_Binary">
<attribute name="FILEPATH"/> <attribute name="FILEPATH"/>
<attribute name="FILENAME"/> <attribute name="FILENAME"/>
<attribute name="FILEEXT" default="dll"/> <attribute name="FILEEXT" default="bin"/>
<element name="EXTRA.INC" optional="yes"/>
<element name="EXTRA.ARG" optional="yes"/>
<sequential> <sequential>
<OnDependency> <copy file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
<sourcefiles> tofile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.bin"/>
<file name="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"/> </sequential>
</sourcefiles> </macrodef>
<targetfiles>
<file name="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"/> <!--
</targetfiles> Microcode
-->
<macrodef name="Build_MICROCODE">
<attribute name="FILEPATH"/>
<attribute name="FILENAME"/>
<attribute name="FILEEXT" default="TXT"/>
<sequential> <element name="EXTRA.INC" optional="yes"/>
<fwimage componentType="${MODULE_TYPE}" outImage="${DEST_DIR_OUTPUT}/@{FILENAME}.efi" <element name="EXTRA.ARG" optional="yes"/>
peImage="${DEST_DIR_DEBUG}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}" time="0"/>
</sequential> <sequential>
</OnDependency> <mkdir dir="${TARGET_DIR}/Microcode"/>
<flashmap MCIFile="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}" MCOFILE="${TARGET_DIR}/Microcode/@{FILENAME}.bin"/>
</sequential>
</macrodef>
<!--
Graphics (bmp, ...)
-->
<macrodef name="Build_BMP">
<attribute name="FILEPATH"/>
<attribute name="FILENAME"/>
<attribute name="FILEEXT" default="bmp"/>
<element name="EXTRA.INC" optional="yes"/>
<element name="EXTRA.ARG" optional="yes"/>
<sequential>
<copy file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
tofile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.bin"/>
</sequential>
</macrodef>
<!--
build EFI file
-->
<macrodef name="Build_EFI">
<attribute name="FILEPATH"/>
<attribute name="FILENAME"/>
<attribute name="FILEEXT" default="efi"/>
<element name="EXTRA.INC" optional="yes"/>
<element name="EXTRA.ARG" optional="yes"/>
<sequential>
<mkdir dir="${MODULE_DIR}/@{FILEPATH}" />
<copy file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
tofile="${DEST_DIR_OUTPUT}/${BASE_NAME}.efi"/>
</sequential>
</macrodef>
<!--
Build macro for Apriori
-->
<macrodef name="Build_Apriori">
<attribute name="FILEPATH" default="."/>
<attribute name="FILENAME"/>
<attribute name="FILEEXT" default="apr"/>
<attribute name="GUID"/>
<sequential>
<mkdir dir="${FV_DIR}/Apriori" />
<gensection inputfile="${FV_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
outputfile="${FV_DIR}/Apriori/@{FILENAME}.sec"
sectiontype="EFI_SECTION_RAW"/>
<genffsfile BaseName="@{FILENAME}" ffsATTRIBCHECKSUM="TRUE" ffsFILETYPE="EFI_FV_FILETYPE_FREEFORM"
fileGuid="@{GUID}" moduleType="BASE" outputDir="${FV_DIR}">
<sectFile fileName="${FV_DIR}/Apriori/@{FILENAME}.sec"/>
</genffsfile>
</sequential> </sequential>
</macrodef> </macrodef>
<!-- <!--############################################################################
EFI_SECTION_FREEFORM_SUBTYPE_GUID Build Sections
EFI_SECTION_VERSION #############################################################################-->
EFI_SECTION_USER_INTERFACE
EFI_SECTION_DXE_DEPEX
EFI_SECTION_PEI_DEPEX
EFI_SECTION_PE32
EFI_SECTION_PIC
EFI_SECTION_TE
EFI_SECTION_RAW
EFI_SECTION_COMPRESSION
EFI_SECTION_GUID_DEFINED
EFI_SECTION_COMPATIBILITY16
EFI_SECTION_FIRMWARE_VOLUME_IMAGE
-->
<!-- <!--
EFI_SECTION_PE32 EFI_SECTION_TE
--> -->
<macrodef name="EFI_SECTION_TE"> <macrodef name="EFI_SECTION_TE">
<attribute name="FILEPATH"/> <attribute name="FILEPATH"/>
<attribute name="FILENAME"/> <attribute name="FILENAME"/>
<attribute name="FILEEXT" default="" /> <attribute name="FILEEXT" default="efi" />
<element name="PRE.PROCESS" optional="yes"/> <element name="PRE.PROCESS" optional="yes"/>
<element name="POST.PROCESS" optional="yes"/> <element name="POST.PROCESS" optional="yes"/>
<sequential> <sequential>
<PRE.PROCESS/>
<if>
<not>
<equals arg1="${LIBS}" arg2=""/>
</not>
<then>
<GenDll FILEPATH="." FILENAME="@{FILENAME}" FILEEXT="">
<LIB.ARG></LIB.ARG>
<LINK.ARG></LINK.ARG>
</GenDll>
<GenEfi FILEPATH="." FILENAME="@{FILENAME}" FILEEXT="dll"/>
</then>
</if>
<OnDependency> <OnDependency>
<sourcefiles> <sourcefiles>
<file name="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"/> <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"/>
@ -1102,44 +1149,31 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
</targetfiles> </targetfiles>
<sequential> <sequential>
<copy file="${DEST_DIR_OUTPUT}/@{FILENAME}.efi" tofile="${BIN_DIR}/@{FILENAME}.efi" /> <PRE.PROCESS/>
<copy file="${DEST_DIR_OUTPUT}/@{FILENAME}.efi" tofile="${DEST_DIR_DEBUG}/@{FILENAME}.efi" />
<genteimage Dump="false" Verbose="false" OutputDir="" OutputFile="${DEST_DIR_OUTPUT}/@{FILENAME}.te" InputFile="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"/> <genteimage Dump="false" Verbose="false" OutputDir="" OutputFile="${DEST_DIR_OUTPUT}/@{FILENAME}.te" InputFile="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"/>
<gensection inputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.te" <gensection inputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.te"
outputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.tes" outputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.tes"
sectiontype="EFI_SECTION_TE"/> sectiontype="EFI_SECTION_TE"/>
<POST.PROCESS/> <POST.PROCESS/>
</sequential> </sequential>
</OnDependency> </OnDependency>
</sequential> </sequential>
</macrodef> </macrodef>
<!--
EFI_SECTION_PE32
-->
<macrodef name="EFI_SECTION_PE32"> <macrodef name="EFI_SECTION_PE32">
<attribute name="FILEPATH"/> <attribute name="FILEPATH"/>
<attribute name="FILENAME"/> <attribute name="FILENAME"/>
<attribute name="FILEEXT" default="" /> <attribute name="FILEEXT" default="efi"/>
<element name="PRE.PROCESS" optional="yes"/> <element name="PRE.PROCESS" optional="yes"/>
<element name="POST.PROCESS" optional="yes"/> <element name="POST.PROCESS" optional="yes"/>
<sequential> <sequential>
<PRE.PROCESS/>
<if>
<not>
<!-- TBD ${OBJECTS} -->
<equals arg1="${LIBS}" arg2=""/>
</not>
<then>
<GenDll FILEPATH="." FILENAME="@{FILENAME}" FILEEXT="">
<LIB.ARG></LIB.ARG>
<LINK.ARG></LINK.ARG>
</GenDll>
<GenEfi FILEPATH="." FILENAME="@{FILENAME}" FILEEXT="dll"/>
</then>
</if>
<OnDependency> <OnDependency>
<sourcefiles> <sourcefiles>
<file name="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"/> <file name="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"/>
@ -1149,8 +1183,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
</targetfiles> </targetfiles>
<sequential> <sequential>
<copy file="${DEST_DIR_OUTPUT}/@{FILENAME}.efi" tofile="${BIN_DIR}/@{FILENAME}.efi" /> <PRE.PROCESS/>
<copy file="${DEST_DIR_OUTPUT}/@{FILENAME}.efi" tofile="${DEST_DIR_DEBUG}/@{FILENAME}.efi" />
<gensection inputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.efi" <gensection inputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.efi"
outputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.pe32" outputfile="${DEST_DIR_OUTPUT}/@{FILENAME}.pe32"
sectiontype="EFI_SECTION_PE32"/> sectiontype="EFI_SECTION_PE32"/>
@ -1415,95 +1449,4 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
</sequential> </sequential>
</macrodef> </macrodef>
<!--
Binary
-->
<macrodef name="Build_Binary">
<attribute name="FILEPATH"/>
<attribute name="FILENAME"/>
<attribute name="FILEEXT" default="bin"/>
<element name="EXTRA.INC" optional="yes"/>
<element name="EXTRA.ARG" optional="yes"/>
<sequential>
<copy file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
tofile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.bin"/>
</sequential>
</macrodef>
<!--
Microcode
-->
<macrodef name="Build_MICROCODE">
<attribute name="FILEPATH"/>
<attribute name="FILENAME"/>
<attribute name="FILEEXT" default="TXT"/>
<element name="EXTRA.INC" optional="yes"/>
<element name="EXTRA.ARG" optional="yes"/>
<sequential>
<mkdir dir="${TARGET_DIR}/Microcode"/>
<flashmap MCIFile="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}" MCOFILE="${TARGET_DIR}/Microcode/@{FILENAME}.bin"/>
</sequential>
</macrodef>
<!--
Graphics (bmp, ...)
-->
<macrodef name="Build_BMP">
<attribute name="FILEPATH"/>
<attribute name="FILENAME"/>
<attribute name="FILEEXT" default="bmp"/>
<element name="EXTRA.INC" optional="yes"/>
<element name="EXTRA.ARG" optional="yes"/>
<sequential>
<copy file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
tofile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.bin"/>
</sequential>
</macrodef>
<!--
build EFI file
-->
<macrodef name="Build_EFI">
<attribute name="FILEPATH"/>
<attribute name="FILENAME"/>
<attribute name="FILEEXT" default="efi"/>
<element name="EXTRA.INC" optional="yes"/>
<element name="EXTRA.ARG" optional="yes"/>
<sequential>
<mkdir dir="${MODULE_DIR}/@{FILEPATH}" />
<copy file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
tofile="${DEST_DIR_OUTPUT}/${BASE_NAME}.efi"/>
</sequential>
</macrodef>
<!--
Build macro for Apriori
-->
<macrodef name="Build_Apriori">
<attribute name="FILEPATH" default="."/>
<attribute name="FILENAME"/>
<attribute name="FILEEXT" default="apr"/>
<attribute name="GUID"/>
<sequential>
<mkdir dir="${FV_DIR}/Apriori" />
<gensection inputfile="${FV_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
outputfile="${FV_DIR}/Apriori/@{FILENAME}.sec"
sectiontype="EFI_SECTION_RAW"/>
<genffsfile BaseName="@{FILENAME}" ffsATTRIBCHECKSUM="TRUE" ffsFILETYPE="EFI_FV_FILETYPE_FREEFORM"
fileGuid="@{GUID}" moduleType="BASE" outputDir="${FV_DIR}">
<sectFile fileName="${FV_DIR}/Apriori/@{FILENAME}.sec"/>
</genffsfile>
</sequential>
</macrodef>
</project> </project>

View File

@ -371,19 +371,24 @@ public class ModuleBuildFileGenerator {
FileProcess fileProcess = new FileProcess(); FileProcess fileProcess = new FileProcess();
fileProcess.init(project, includes, document); fileProcess.init(project, includes, document);
// boolean isBinaryModule = fpdModuleId.getModule().isBinary();
// Initialize some properties by user boolean isLibraryModule = fpdModuleId.getModule().isLibrary();
//
Element initEle = document.createElement("Build_Init"); if (!isBinaryModule) {
Element initIncEle = document.createElement("EXTRA.INC"); //
for (int i = 0; i < includes.length; i++) { // Initialize some properties by user
Element includeEle = document.createElement("includepath"); //
includeEle.setAttribute("path", includes[i]); Element initEle = document.createElement("Build_Init");
initIncEle.appendChild(includeEle); Element initIncEle = document.createElement("EXTRA.INC");
for (int i = 0; i < includes.length; i++) {
Element includeEle = document.createElement("includepath");
includeEle.setAttribute("path", includes[i]);
initIncEle.appendChild(includeEle);
}
initEle.appendChild(initIncEle);
root.appendChild(initEle);
} }
initEle.appendChild(initIncEle);
root.appendChild(initEle);
String moduleDir = project.getProperty("MODULE_DIR"); String moduleDir = project.getProperty("MODULE_DIR");
// //
@ -421,10 +426,9 @@ public class ModuleBuildFileGenerator {
} }
// //
// Parse AutoGen.c & AutoGen.h // Don't build AutoGen.c for library and binary module
// //
if (!fpdModuleId.getModule().isLibrary() if (!isLibraryModule && !isBinaryModule) {
&& !fpdModuleId.getModule().isBinary()) {
fileProcess.parseFile(project.getProperty("DEST_DIR_DEBUG") + File.separatorChar + "AutoGen.c", null, root, false); fileProcess.parseFile(project.getProperty("DEST_DIR_DEBUG") + File.separatorChar + "AutoGen.c", null, root, false);
} }
@ -470,6 +474,18 @@ public class ModuleBuildFileGenerator {
if (sectiontype.equalsIgnoreCase("EFI_SECTION_RAW") && project.getProperty("MODULE_TYPE").equalsIgnoreCase("SEC")) { if (sectiontype.equalsIgnoreCase("EFI_SECTION_RAW") && project.getProperty("MODULE_TYPE").equalsIgnoreCase("SEC")) {
sectiontype += "_SEC"; sectiontype += "_SEC";
} }
if ((sectiontype.equalsIgnoreCase("EFI_SECTION_PE32") ||
sectiontype.equalsIgnoreCase("EFI_SECTION_TE"))
&& !fpdModuleId.getModule().isLibrary()
&& !fpdModuleId.getModule().isBinary()) {
//
// Generate code to generate efi file
//
Element ele = document.createElement("GenEfi");
ele.setAttribute("FILEPATH", ".");
ele.setAttribute("FILENAME", "${BASE_NAME}");
root.appendChild(ele);
}
Element ele = document.createElement(sectiontype); Element ele = document.createElement(sectiontype);
ele.setAttribute("FILEPATH", "."); ele.setAttribute("FILEPATH", ".");
ele.setAttribute("FILENAME", "${BASE_NAME}"); ele.setAttribute("FILENAME", "${BASE_NAME}");

View File

@ -1107,8 +1107,7 @@ public class AutoGen {
fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n"); fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");
fileBuffer.append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n"); fileBuffer.append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
fileBuffer.append(" }\r\n"); fileBuffer.append(" }\r\n");
fileBuffer fileBuffer.append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
.append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
} else { } else {
fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n"); fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n"); fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n");
@ -1591,8 +1590,7 @@ public class AutoGen {
case CommonDefinition.ModuleTypePeiCore: case CommonDefinition.ModuleTypePeiCore:
case CommonDefinition.ModuleTypePeim: case CommonDefinition.ModuleTypePeim:
fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n"); fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
fileBuffer fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
break; break;
case CommonDefinition.ModuleTypeDxeCore: case CommonDefinition.ModuleTypeDxeCore: