import org.tianocore.build.global.GlobalData;\r
import org.tianocore.build.global.SurfaceAreaQuery;\r
import org.tianocore.build.id.FpdModuleIdentification;\r
+import org.tianocore.common.definitions.EdkDefinitions;\r
+import org.tianocore.common.logger.EdkLog;\r
import org.w3c.dom.Document;\r
import org.w3c.dom.Element;\r
\r
/** \r
<p><code>FfsProcess</code> is a class to find the corresponding FFS layout. </p>\r
\r
- <p>Property <code>COMMON_FILE</code> specified which file to search. The element\r
- in <code>COMMON_FILE</code> is like following: </p>\r
+ <p>The FFS Layout is like following: </p>\r
\r
<pre>\r
<Ffs type="APPLICATION">\r
///\r
/// mapping from section type to section output file extension\r
///\r
- public static final String[][] sectionExt = { { "EFI_SECTION_FREEFORM_SUBTYPE_GUID", ".sec" },\r
- { "EFI_SECTION_VERSION", ".ver" },\r
- { "EFI_SECTION_USER_INTERFACE", ".ui" },\r
- { "EFI_SECTION_DXE_DEPEX", ".dpx" },\r
- { "EFI_SECTION_PEI_DEPEX", ".dpx" }, \r
- { "EFI_SECTION_PE32", ".pe32" },\r
- { "EFI_SECTION_PIC", ".pic" }, \r
- { "EFI_SECTION_TE", ".tes" },\r
- { "EFI_SECTION_RAW", ".sec" }, \r
- { "EFI_SECTION_COMPRESSION", ".sec" },\r
- { "EFI_SECTION_GUID_DEFINED", ".sec" },\r
- { "EFI_SECTION_COMPATIBILITY16", ".sec" },\r
- { "EFI_SECTION_FIRMWARE_VOLUME_IMAGE", ".sec" } };\r
+ public static final String[][] sectionExt = EdkDefinitions.SectionTypeExtensions;\r
\r
/**\r
search in the type, if componentType is listed in type, return true; \r
}\r
\r
/**\r
- Find the corresponding FFS layout in <code>COMMON_FILE</code> if it\r
- does not specify in module's surface area. \r
+ Find the corresponding FFS layout in <code>FPD</code>. \r
\r
@param buildType Current module's component type\r
@param project Ant project\r
@return whether find the corresponding FFS layout\r
@throws BuildException\r
- If specified COMMON_FILE XML file is not valide.\r
+ If can't find FFS Layout in FPD.\r
**/\r
public boolean initSections(String buildType, Project project, FpdModuleIdentification fpdModuleId) throws BuildException {\r
//\r
// Try to find Ffs layout from FPD file\r
//\r
- SurfaceAreaQuery.push(GlobalData.getFpdBuildOptions());\r
- BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = SurfaceAreaQuery.getFpdFfs();\r
- SurfaceAreaQuery.pop();\r
+ SurfaceAreaQuery saq = new SurfaceAreaQuery(GlobalData.getFpdBuildOptionsMap());\r
+ BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = saq.getFpdFfs();\r
for (int i = 0; i < ffsArray.length; i++) {\r
if (isMatch(ffsArray[i].getFfsKey(), buildType)) {\r
ffsXmlObject = ffsArray[i];\r
// Otherwise report warning message\r
//\r
if (buildType == null) {\r
- System.out.println("Warning: this module doesn't specify a FfsFormatKey. ");\r
+ EdkLog.log(EdkLog.EDK_WARNING, "Warning: this module doesn't specify a FfsFormatKey. ");\r
} else {\r
throw new BuildException("Can't find the FfsFormatKey [" + buildType + "] attribute in the FPD file!"); \r
}\r
}\r
Vector<String> sectionList = new Vector<String>();\r
XmlCursor cursor = null;\r
- try {\r
- cursor = ffsXmlObject.newCursor();\r
- } catch (Exception e) {\r
- return null;\r
- }\r
+\r
+ cursor = ffsXmlObject.newCursor();\r
+\r
int mode = MODE_NONE;\r
Element genffsfileEle = document.createElement("genffsfile");\r
genffsfileEle.setAttribute("outputDir", "${BIN_DIR}");\r
**/\r
private void dealSections(int mode, Document doc, Element root, XmlCursor cursor, Vector<String> list) {\r
String type = cursor.getAttributeText(new QName("EncapsulationType"));\r
- if (type == null) {\r
+ String toolName = cursor.getAttributeText(new QName("ToolName"));\r
+ String sectType = cursor.getAttributeText(new QName("SectionType"));\r
+ if (type == null && sectType == null) {\r
if (cursor.toFirstChild()) {\r
do {\r
if (cursor.getName().getLocalPart().equalsIgnoreCase("Section")) {\r
return;\r
}\r
Element ele;\r
- if (type.equalsIgnoreCase("COMPRESS")) {\r
+ Element toolEle = null;\r
+ if (type.equalsIgnoreCase("COMPRESS") && (toolName == null || toolName.equalsIgnoreCase(""))) {\r
mode = MODE_COMPRESS;\r
//\r
- // <compress compressName = "dummy">\r
- //\r
- ele = doc.createElement("compress");\r
- ele.setAttribute("compressName", "dummy");\r
+ // <gensection sectiontype="EFI_SECTION_COMPRESSION"> \r
+ // \r
+ ele = doc.createElement("gensection");\r
+ ele.setAttribute("sectionType", "EFI_SECTION_COMPRESSION");\r
+ \r
} else {\r
mode = MODE_GUID_DEFINED;\r
//\r
+ // <gensection sectiontype="EFI_SECTION_GUID_DEFINED">\r
+ // \r
+ ele = doc.createElement("gensection");\r
+ if (type != null) {\r
+ if (type.equalsIgnoreCase("COMPRESS")) {\r
+ ele.setAttribute("sectionType", "EFI_SECTION_COMPRESSION");\r
+ }else {\r
+ ele.setAttribute("sectiontype", "EFI_SECTION_GUID_DEFINED"); \r
+ }\r
+ \r
+ } else {\r
+ ele.setAttribute("sectiontype", sectType);\r
+ }\r
+ //\r
// <tool toolName="${OEMTOOLPATH}\toolname"\r
// outputPath = "${DEST_DIR_OUTPUT}">\r
//\r
- ele = doc.createElement("tool");\r
- ele.setAttribute("toolName", "${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "bin"\r
+ toolEle = doc.createElement("tool");\r
+ if (toolName == null || toolName.equalsIgnoreCase("")) {\r
+ toolEle.setAttribute("toolName", "${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "bin"\r
+ File.separatorChar + "GenCRC32Section");\r
- ele.setAttribute("outputPath", "${DEST_DIR_OUTPUT}");\r
+ }else{\r
+ File toolExe = new File(toolName);\r
+ //\r
+ // If <Tool> element exist, add sub element under <tool> . \r
+ // \r
+ if (toolExe.isAbsolute()) {\r
+ toolEle.setAttribute("toolName", toolName);\r
+ } else {\r
+ toolEle.setAttribute("toolName", "${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "bin"\r
+ + File.separatorChar + toolName);\r
+ }\r
+ }\r
+ \r
+ toolEle.setAttribute("outputPath", "${DEST_DIR_OUTPUT}");\r
+ ele.appendChild(toolEle);\r
}\r
if (cursor.toFirstChild()) {\r
do {\r
if (cursor.getName().getLocalPart().equalsIgnoreCase("Section")) {\r
cursor.push();\r
- dealSection(mode, doc, ele, cursor, list);\r
+ if (toolEle == null) {\r
+ dealSection(mode, doc, ele, cursor, list);\r
+ } else {\r
+ dealSection(mode, doc, toolEle, cursor, list);\r
+ }\r
+ \r
cursor.pop();\r
} else if (cursor.getName().getLocalPart().equalsIgnoreCase("Sections")) {\r
cursor.push();\r
- dealSections(mode, doc, ele, cursor, list);\r
+ if (toolEle == null) {\r
+ dealSections(mode, doc, ele, cursor, list);\r
+ } else {\r
+ dealSections(mode, doc, toolEle, cursor, list);\r
+ }\r
+ \r
cursor.pop();\r
}\r
} while (cursor.toNextSibling());\r