X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Tools%2FSource%2FFrameworkWizard%2Fsrc%2Forg%2Ftianocore%2Fframeworkwizard%2Fplatform%2Fui%2FFpdFileContents.java;h=26d3d694c952860db0552209be4884e74d9ad846;hb=a0783edc77ae576d8032461935362f43293bc467;hp=b89f967fa3e53000e18993fbbb172b84a1e35dce;hpb=ac66fadf6fae5f54b17fb50728a82ffb32b829fa;p=mirror_edk2.git 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 b89f967fa3..26d3d694c9 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,7 +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 regNewLineAndSpaces = "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*"; + static final String regExpNewLineAndSpaces = "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*"; private PlatformSurfaceAreaDocument fpdd = null; @@ -190,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; } @@ -208,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; } } @@ -352,7 +359,7 @@ public class FpdFileContents { break; } String s = cursor.getTextValue(); - if (s.matches(regNewLineAndSpaces)) { + if (s.matches(regExpNewLineAndSpaces)) { continue; } } @@ -401,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) { @@ -413,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)); @@ -462,10 +462,6 @@ public class FpdFileContents { } } - } - catch (Exception e){ - throw e; - } return dataModified; } @@ -648,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; @@ -672,8 +700,10 @@ public class FpdFileContents { 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); @@ -690,12 +720,7 @@ public class FpdFileContents { cursor.dispose(); } } - - } - catch (Exception e){ - e.printStackTrace(); - - } + } // // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch" @@ -742,7 +767,7 @@ public class FpdFileContents { break; } String s = cursor.getTextValue(); - if (s.matches(regNewLineAndSpaces)) { + if (s.matches(regExpNewLineAndSpaces)) { continue; } } @@ -946,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){ @@ -1227,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); @@ -1732,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(); } @@ -1780,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 { @@ -1794,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()); } @@ -1854,6 +1897,138 @@ public class FpdFileContents { } + private boolean versionEqual (String v1, String v2) { + + if ((v1 == null || v1.length() == 0 || v1.equalsIgnoreCase("null")) + && (v2 == null || v2.length() == 0 || v2.equalsIgnoreCase("null"))) { + return true; + } + + if (v1 != null && v1.equals(v2)) { + return true; + } + + return false; + } + + public boolean moduleInBuildOptionsUserExtensions (String fvName, String moduleGuid, String moduleVersion, String packageGuid, String packageVersion, String arch) { + boolean inList = false; + if (getUserExtsIncModCount(fvName) > 0) { + + XmlCursor cursor = getfpdBuildOpts().newCursor(); + QName elementUserExts = new QName (xmlNs, "UserExtensions"); + QName attribUserId = new QName ("UserID"); + QName elementFvName = new QName (xmlNs, "FvName"); + QName elementIncludeModules = new QName(xmlNs, "IncludeModules"); + QName attribModuleGuid = new QName("ModuleGuid"); + 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 { + cursor.push(); + if (cursor.getAttributeText(attribUserId).equals("IMAGES")) { + cursor.toChild(elementFvName); + String elementName = cursor.getTextValue(); + if (elementName.equals(fvName)) { + cursor.toNextSibling(elementIncludeModules); + if (cursor.toFirstChild()) { + + do { + String mg = cursor.getAttributeText(attribModuleGuid); + String mv = cursor.getAttributeText(attribModuleVersion); + String pg = cursor.getAttributeText(attribPackageGuid); + String pv = cursor.getAttributeText(attribPackageVersion); + String ar = cursor.getAttributeText(attribArch); + if (!moduleGuid.equalsIgnoreCase(mg)) { + continue; + } + if (!packageGuid.equalsIgnoreCase(pg)) { + continue; + } + if (!arch.equalsIgnoreCase(ar)) { + continue; + } + if (!versionEqual(moduleVersion, mv)) { + continue; + } + if (!versionEqual(packageVersion, pv)) { + continue; + } + inList = true; + break; + }while (cursor.toNextSibling()); + } + break; + } + } + cursor.pop(); + }while (cursor.toNextSibling(elementUserExts)); + } + cursor.dispose(); + } + return inList; + } + + public void removeModuleInBuildOptionsUserExtensions (String fvName, String moduleGuid, String moduleVersion, String packageGuid, String packageVersion, String arch) { + if (getUserExtsIncModCount(fvName) > 0) { + + XmlCursor cursor = getfpdBuildOpts().newCursor(); + QName elementUserExts = new QName (xmlNs, "UserExtensions"); + QName attribUserId = new QName ("UserID"); + QName elementFvName = new QName (xmlNs, "FvName"); + QName elementIncludeModules = new QName(xmlNs, "IncludeModules"); + QName attribModuleGuid = new QName("ModuleGuid"); + 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 { + cursor.push(); + if (cursor.getAttributeText(attribUserId).equals("IMAGES")) { + cursor.toChild(elementFvName); + String elementName = cursor.getTextValue(); + if (elementName.equals(fvName)) { + cursor.toNextSibling(elementIncludeModules); + if (cursor.toFirstChild()) { + + do { + String mg = cursor.getAttributeText(attribModuleGuid); + String mv = cursor.getAttributeText(attribModuleVersion); + String pg = cursor.getAttributeText(attribPackageGuid); + String pv = cursor.getAttributeText(attribPackageVersion); + String ar = cursor.getAttributeText(attribArch); + if (!moduleGuid.equalsIgnoreCase(mg)) { + continue; + } + if (!packageGuid.equalsIgnoreCase(pg)) { + continue; + } + if (!arch.equalsIgnoreCase(ar)) { + continue; + } + if (!versionEqual(moduleVersion, mv)) { + continue; + } + if (!versionEqual(packageVersion, pv)) { + continue; + } + cursor.removeXml(); + }while (cursor.toNextSibling()); + } + break; + } + } + cursor.pop(); + }while (cursor.toNextSibling(elementUserExts)); + } + cursor.dispose(); + } + } public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) { UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();