X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2FFfsProcess.java;h=9371c7e6d5de8c9493d8b97aaa3dc270e0df4ba6;hp=dbbddba3db107067a46c712e43b14bc1162e51d4;hb=52cbbdbc1680859f5303150d0699a1ebfaa485a4;hpb=878ddf1fc3540a715f63594ed22b6929e881afb4 diff --git a/Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java b/Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java index dbbddba3db..9371c7e6d5 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java +++ b/Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java @@ -26,6 +26,10 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlObject; +import org.tianocore.BuildOptionsDocument; +import org.tianocore.build.global.GlobalData; +import org.tianocore.build.global.SurfaceAreaQuery; +import org.tianocore.build.id.FpdModuleIdentification; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -60,6 +64,8 @@ public class FfsProcess { /// Xml Document Node for corresponding FFS layout /// private Node ffs; + + private BuildOptionsDocument.BuildOptions.Ffs ffsXmlObject; /// /// ANT script to call GenFfs @@ -131,51 +137,42 @@ public class FfsProcess { @throws BuildException If specified COMMON_FILE XML file is not valide. **/ - public boolean initSections(String buildType, Project project) throws BuildException { + public boolean initSections(String buildType, Project project, FpdModuleIdentification fpdModuleId) throws BuildException { // - // first try to sections defined in PLATFORM level + // Firstly, try to find in ModuleSA // - +// BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = SurfaceAreaQuery.getModuleFfs(); +// for (int i = 0; i < ffsArray.length; i++) { +// if (isMatch(ffsArray[i].getFfsKey(), buildType)) { +// ffsXmlObject = ffsArray[i]; +// return true; +// } +// } + // - // if module specify sections itself, it's okay - // otherwise find sections from WORKSPACE default setting with - // ComponentType + // secondly, try to sections defined in PLATFORM level // - if (ffs == null) { - File file = new File(project.getProperty("COMMON_FILE")); - // - // if common file is not existed, just return - // - if (!file.exists()) { - return false; + SurfaceAreaQuery.push(GlobalData.getFpdBuildOptions()); + BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = SurfaceAreaQuery.getFpdFfs(); + SurfaceAreaQuery.pop(); + for (int i = 0; i < ffsArray.length; i++) { + if (isMatch(ffsArray[i].getFfsKey(), buildType)) { + ffsXmlObject = ffsArray[i]; + return true; } - DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance(); - try { - DocumentBuilder dombuilder = domfac.newDocumentBuilder(); - InputStream is = new FileInputStream(file); - Document doc = dombuilder.parse(is); - Element root = doc.getDocumentElement(); - NodeList items = root.getChildNodes(); - for (int i = 0; i < items.getLength(); i++) { - Node node = items.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE) { - String nodeName = node.getNodeName(); - if (nodeName.equalsIgnoreCase("Ffs")) { - NamedNodeMap attr = node.getAttributes(); - Node type = attr.getNamedItem("type"); - if (type != null) { - if (isMatch(type.getTextContent(), buildType)) { - ffs = node; - return true; - } - } - } - } - } - } catch (Exception e) { - throw new BuildException("Parse COMMON_FILE [" + file.getPath() + "] error!\n" + e.getMessage()); + } + + // + // If FfsFormatKey is not null, report exception and fail build + // Otherwise report warning message + // + if (buildType == null) { + System.out.println("Warning: this module doesn't specify a FfsFormatKey. "); } + else { + throw new BuildException("Can't find FfsFormatKey [" + buildType + "] in FPD file. "); } + if (ffs == null) { return false; } else { @@ -194,22 +191,30 @@ public class FfsProcess { **/ public String[] getGenSectionElements(Document document, String basename, String guid, String targetFilename) { this.basename = basename; - if (ffs == null) { + if (ffs == null && ffsXmlObject == null) { return new String[0]; } Vector sectionList = new Vector(); XmlCursor cursor = null; try { - cursor = XmlObject.Factory.parse(ffs).newCursor(); + if (ffsXmlObject == null) { + cursor = XmlObject.Factory.parse(ffs).newCursor(); + } + else { + cursor = ffsXmlObject.newCursor(); + } } catch (Exception e) { return null; } int mode = MODE_NONE; Element root = document.createElement("genffsfile"); root.setAttribute("outputDir", "${BIN_DIR}"); + root.setAttribute("moduleType", "${MODULE_TYPE}"); root.setAttribute("BaseName", basename); root.setAttribute("fileGuid", guid); - cursor.toFirstChild(); + if (ffsXmlObject == null) { + cursor.toFirstChild(); + } if (cursor.toFirstChild()) { do { if (cursor.getName().getLocalPart().equalsIgnoreCase("Attribute")) { @@ -243,7 +248,7 @@ public class FfsProcess { outofdateEle.appendChild(sourceEle); Element targetEle = document.createElement("targetfiles"); Element fileEle = document.createElement("file"); - fileEle.setAttribute("name", "${BIN_DIR}\\" + targetFilename); + fileEle.setAttribute("name", "${BIN_DIR}" + File.separatorChar + targetFilename); targetEle.appendChild(fileEle); outofdateEle.appendChild(targetEle); Element sequentialEle = document.createElement("sequential"); @@ -315,7 +320,7 @@ public class FfsProcess { // outputPath = "${DEST_DIR_OUTPUT}"> // ele = doc.createElement("tool"); - ele.setAttribute("toolName", "${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "Bin" + ele.setAttribute("toolName", "${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "bin" + File.separatorChar + "GenCRC32Section"); ele.setAttribute("outputPath", "${DEST_DIR_OUTPUT}"); } @@ -365,7 +370,7 @@ public class FfsProcess { } /** - Get the corresponding section file suffix. + Get the corresponding section file suffix. @param type Section type @return Corresponding section file extension