X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FFrameworkWizard%2Fsrc%2Forg%2Ftianocore%2Fframeworkwizard%2Fplatform%2Fui%2FFpdFileContents.java;h=6ca15710c291dc6b05879f6fad3fb533bf5c1f8c;hp=946a6b64d9d8a4fea1d1d22d6eda493c4062bca6;hb=5342724213d3797764f4deddcaf5677d7340b23a;hpb=ce32083fca6d876a3d0d0339d2ae2dd40e40d02e diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java index 946a6b64d9..6ca15710c2 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java @@ -70,6 +70,7 @@ import org.tianocore.frameworkwizard.packaging.PackageIdentification; public class FpdFileContents { static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0"; + static final String regExpNewLineAndSpaces = "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*"; private PlatformSurfaceAreaDocument fpdd = null; @@ -189,7 +190,7 @@ public class FpdFileContents { return fpdFrameworkModules; } - public void getFrameworkModuleGuid (String fvName, Vector vGuid) { + public void getFrameworkModuleSAByFvBinding (String fvName, Vector vGuid) { if (getFrameworkModulesCount() == 0){ return; } @@ -207,8 +208,15 @@ public class FpdFileContents { String[] fvNames = fvBinding.split(" "); for (int i = 0; i < fvNames.length; ++i) { + // + // BugBug : underscore "_" should not be replaced!!! + // But Fv name FVMAIN from fdf file not consist with FV_MAIN in fpd file. + // if (fvNames[i].equals(fvName) || fvNames[i].replaceAll("_", "").equals(fvName)) { - vGuid.add(moduleSa.getModuleGuid()); + String[] sa = new String[] {moduleSa.getModuleGuid(), moduleSa.getModuleVersion(), + moduleSa.getPackageGuid(), moduleSa.getPackageVersion(), + listToString(moduleSa.getSupArchList())}; + vGuid.add(sa); break; } } @@ -345,10 +353,21 @@ public class FpdFileContents { } cursor.push(); - cursor.toPrevToken(); + while (cursor.hasPrevToken()) { + cursor.toPrevToken(); + if (!cursor.isText()) { + break; + } + String s = cursor.getTextValue(); + if (s.matches(regExpNewLineAndSpaces)) { + continue; + } + } + if (cursor.isComment()) { cursor.removeXml(); } + cursor.pop(); cursor.removeXml(); if (getFrameworkModulesCount() == 0) { @@ -389,7 +408,6 @@ public class FpdFileContents { vMi.add(libMi); } - try { nextPcd:for (int i = 0; i < saaModuleSaPcd.length; ++i) { for (int j = 0; j < vMi.size(); ++j) { @@ -401,16 +419,10 @@ public class FpdFileContents { removePcdData(seqModuleSa, saaModuleSaPcd[i][0], saaModuleSaPcd[i][1]); dataModified = true; } - } - catch (Exception e) { - throw e; - } // // add new Pcd from MSA file to ModuleSA. // - try { - - for (int i = 0; i < vMi.size(); ++i) { + for (int i = 0; i < vMi.size(); ++i) { ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile .getModuleXmlObject(vMi .get(i)); @@ -450,10 +462,6 @@ public class FpdFileContents { } } - } - catch (Exception e){ - throw e; - } return dataModified; } @@ -636,12 +644,44 @@ public class FpdFileContents { return false; } + private boolean multiSourcePcd (String cName, String tsGuidCName, String moduleKey) { + int libCount = getLibraryInstancesCount(moduleKey); + String[][] saaLib = new String[libCount][5]; + getLibraryInstances(moduleKey, saaLib); + ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey); + Vector vMi = new Vector(); + // + // create vector for module & library instance MIs. + // + vMi.add(mi); + for (int j = 0; j < saaLib.length; ++j) { + String libKey = saaLib[j][1] + " " + saaLib[j][2] + " " + saaLib[j][3] + " " + saaLib[j][4]; + ModuleIdentification libMi = WorkspaceProfile.getModuleId(libKey); + vMi.add(libMi); + } + + int pcdSourceCount = 0; + for (int i = 0; i < vMi.size(); ++i) { + if (WorkspaceProfile.pcdInMsa(cName, tsGuidCName, vMi.get(i))) { + pcdSourceCount++; + } + } + + if (pcdSourceCount < 2) { + return false; + } + else { + return true; + } + + } + /**Remove PCDBuildDefinition entries from ModuleSA * @param moduleKey identifier of ModuleSA. * @param consumer where these entries come from. */ public void removePcdData(String moduleKey, ModuleIdentification consumer) { - try { + ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(consumer); if (msa.getPcdCoded() == null) { return; @@ -655,12 +695,15 @@ public class FpdFileContents { ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey); if (moduleSA.getPcdBuildDefinition() != null) { XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor(); + cursor.push(); if (cursor.toFirstChild()) { do { PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor .getObject(); - if (msaPcd.getCName().equals(pcdData.getCName()) - && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) { + String cName = msaPcd.getCName(); + String tsGuidCName = msaPcd.getTokenSpaceGuidCName(); + if (cName.equals(pcdData.getCName()) + && tsGuidCName.equals(pcdData.getTokenSpaceGuidCName()) && !multiSourcePcd(cName, tsGuidCName, moduleKey)) { maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), moduleKey); @@ -669,15 +712,15 @@ public class FpdFileContents { } } while (cursor.toNextSibling()); } + + cursor.pop(); + if (moduleSA.getPcdBuildDefinition().getPcdDataList().size() == 0) { + cursor.removeXml(); + } cursor.dispose(); } } - - } - catch (Exception e){ - e.printStackTrace(); - - } + } // // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch" @@ -718,7 +761,17 @@ public class FpdFileContents { cursor.toNextSibling(); } cursor.push(); - cursor.toPrevToken(); + while (cursor.hasPrevToken()) { + cursor.toPrevToken(); + if (!cursor.isText()) { + break; + } + String s = cursor.getTextValue(); + if (s.matches(regExpNewLineAndSpaces)) { + continue; + } + } + if (cursor.isComment()) { cursor.removeXml(); } @@ -918,14 +971,9 @@ public class FpdFileContents { setFvBinding (moduleSa, newFvNameList.trim()); } - public void updateFvBindingInModuleSA (ModuleIdentification mi, String fvName) { - Vector vSupArchs = new Vector(); - getPlatformDefsSupportedArchs(vSupArchs); - String moduleInfo = mi.getGuid() + " " + mi.getVersion() + " " + mi.getPackageId().getGuid() + " " + mi.getPackageId().getVersion(); - for (int i = 0; i < vSupArchs.size(); ++i) { - String moduleKey = moduleInfo + " " + vSupArchs.get(i); - appendFvBinding (moduleKey, fvName); - } + public void updateFvBindingInModuleSA (String moduleKey, String fvName) { + + appendFvBinding (moduleKey, fvName); } public String getFfsFileNameGuid(String moduleKey){ @@ -1199,15 +1247,24 @@ public class FpdFileContents { pcdConsumer = new ArrayList(); } // + // Check whether this PCD has already added to ModuleSA, if so, just return. + // + String moduleInfo = moduleSa.getModuleGuid().toLowerCase() + " " + moduleSa.getModuleVersion() + + " " + moduleSa.getPackageGuid().toLowerCase() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList()); + for (int i = 0; i < pcdConsumer.size(); ++i) { + String pcdInfo = pcdConsumer.get(i); + if (moduleInfo.equals(pcdInfo.substring(0, pcdInfo.lastIndexOf(" ")))){ + return; + } + } + // // Using existing Pcd type, if this pcd already exists in other ModuleSA // if (pcdConsumer.size() > 0) { itemType = itemType (pcdConsumer.get(0)); } - String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() - + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList()) - + " " + itemType; + String listValue = moduleInfo + " " + itemType; pcdConsumer.add(listValue); dynPcdMap.put(cName + " " + tsGuid, pcdConsumer); @@ -1704,7 +1761,15 @@ public class FpdFileContents { for (int i = 0; i < includeModules.size(); ++i) { cursor.beginElement(elementModule); cursor.insertAttributeWithValue("ModuleGuid", includeModules.get(i)[0]); - cursor.insertAttributeWithValue("BaseName", includeModules.get(i)[1]); + if (!includeModules.get(i)[1].equals("null") && includeModules.get(i)[1].length() != 0) { + cursor.insertAttributeWithValue("ModuleVersion", includeModules.get(i)[1]); + } + cursor.insertAttributeWithValue("PackageGuid", includeModules.get(i)[2]); + if (!includeModules.get(i)[3].equals("null") && includeModules.get(i)[3].length() != 0) { + cursor.insertAttributeWithValue("PackageVersion", includeModules.get(i)[3]); + } + + cursor.insertAttributeWithValue("Arch", includeModules.get(i)[4]); cursor.toEndToken(); cursor.toNextToken(); } @@ -1752,7 +1817,10 @@ public class FpdFileContents { QName elementFvName = new QName (xmlNs, "FvName"); QName elementIncludeModules = new QName(xmlNs, "IncludeModules"); QName attribModuleGuid = new QName("ModuleGuid"); - QName attribBaseName = new QName("BaseName"); + QName attribModuleVersion = new QName("ModuleVersion"); + QName attribPackageGuid = new QName("PackageGuid"); + QName attribPackageVersion = new QName("PackageVersion"); + QName attribArch = new QName("Arch"); if (cursor.toChild(elementUserExts)) { do { @@ -1766,7 +1834,10 @@ public class FpdFileContents { int i = 0; do { saa[i][0] = cursor.getAttributeText(attribModuleGuid); - saa[i][1] = cursor.getAttributeText(attribBaseName); + saa[i][1] = cursor.getAttributeText(attribModuleVersion); + saa[i][2] = cursor.getAttributeText(attribPackageGuid); + saa[i][3] = cursor.getAttributeText(attribPackageVersion); + saa[i][4] = cursor.getAttributeText(attribArch); ++i; }while (cursor.toNextSibling()); }