X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Tools%2FSource%2FFrameworkWizard%2Fsrc%2Forg%2Ftianocore%2Fframeworkwizard%2Fplatform%2Fui%2FFpdFileContents.java;h=b54715b877b59818e794350476983db9db1bc764;hb=73d9b1c494ac88a0e875a047fb3f11aa91e87c4d;hp=c80d758f284f0b3ca92dc051fc6f80aa0a283485;hpb=b411fc1f316b0a67474ca727afcd813329513c46;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 c80d758f28..b54715b877 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 @@ -91,6 +91,11 @@ public class FpdFileContents { private HashMap defaultPcdValue = new HashMap(); + private String itemType (String pcdInfo) { + + return pcdInfo.substring(pcdInfo.lastIndexOf(" ") + 1); + } + /** * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings. */ @@ -251,12 +256,22 @@ public class FpdFileContents { } public ModuleSADocument.ModuleSA getModuleSA(String key) { - String[] s = key.split(" "); + if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) { removeElement(getfpdFrameworkModules()); fpdFrameworkModules = null; return null; } + String[] s = key.split(" "); + String archsInKey = ""; + if (s.length > 4) { + for (int i = 4; i < s.length; ++i) { + archsInKey += s[i]; + archsInKey += " "; + } + archsInKey = archsInKey.trim(); + } + ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator(); while(li.hasNext()) { ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next(); @@ -271,13 +286,17 @@ public class FpdFileContents { continue; } } - //ToDo add arch check for s[4] + //ToDo add arch check . if (moduleSa.getSupArchList() != null) { - if (!listToString(moduleSa.getSupArchList()).equals(s[4])) { - continue; + if (listToString(moduleSa.getSupArchList()).equals(archsInKey)) { + return moduleSa; + } + } + else { + if (archsInKey.length() == 0) { + return moduleSa; } } - return moduleSa; } } return null; @@ -360,17 +379,22 @@ public class FpdFileContents { 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); + } + try { nextPcd:for (int i = 0; i < saaModuleSaPcd.length; ++i) { - if (WorkspaceProfile.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], mi)){ - continue; - } - 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); - if (WorkspaceProfile.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], libMi)) { + + for (int j = 0; j < vMi.size(); ++j) { + ModuleIdentification nextMi = vMi.get(j); + if (WorkspaceProfile.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], nextMi)) { continue nextPcd; } } @@ -379,7 +403,7 @@ public class FpdFileContents { } } catch (Exception e) { - + throw e; } // // add new Pcd from MSA file to ModuleSA. @@ -405,9 +429,6 @@ public class FpdFileContents { } } - Map m = new HashMap(); - m.put("ModuleSurfaceArea", msa); - SurfaceAreaQuery.setDoc(m); PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, vMi.get(i)); PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs); if (spdPcd == null) { @@ -541,6 +562,9 @@ public class FpdFileContents { do { PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject(); if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) { + // + // change item type while not updating dynPcdData???? + // pcdData.setItemType(PcdItemTypes.Enum.forString(itemType)); if(pcdData.getDatumType().equals("VOID*")) { pcdData.setMaxDatumSize(new Integer(maxSize)); @@ -1177,8 +1201,8 @@ public class FpdFileContents { // Using existing Pcd type, if this pcd already exists in other ModuleSA // if (pcdConsumer.size() > 0) { - String[] valPart = pcdConsumer.get(0).split(" "); - itemType = valPart[5]; + + itemType = itemType (pcdConsumer.get(0)); } String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList()) @@ -2606,7 +2630,7 @@ public class FpdFileContents { } } - public void AddFvImageFvImageNames (String[] fvNames) { + public void addFvImageFvImageNames (String[] fvNames) { FvImagesDocument.FvImages fis = getfpdFlash().getFvImages(); if (fis == null || fis.getFvImageList() == null) { genFvImagesFvImage (fvNames, "ImageName", null); @@ -2617,14 +2641,35 @@ public class FpdFileContents { while (li.hasNext()) { FvImagesDocument.FvImages.FvImage fi = li.next(); if (fi.getType().toString().equals("ImageName")) { - for (int i = 0; i < fvNames.length; ++i) { - fi.addFvImageNames(fvNames[i]); - } + addFvImageNamesInFvImage (fi, fvNames); return; } } - genFvImagesFvImage (fvNames, "ImageName", null); + genFvImagesFvImage (fvNames, "ImageName", null); + } + + public void addFvImageNamesInFvImage (FvImagesDocument.FvImages.FvImage fi, String[] fvNames) { + for (int i = 0; i < fvNames.length; ++i) { + fi.addFvImageNames(fvNames[i]); + } + } + + public void addFvImageNamesInFvImage (int i, String[] fvNames) { + XmlObject o = getfpdFlash().getFvImages(); + if (o == null) { + return; + } + XmlCursor cursor = o.newCursor(); + QName qFvImage = new QName(xmlNs, "FvImage"); + if (cursor.toChild(qFvImage)) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(qFvImage); + } + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject(); + addFvImageNamesInFvImage(fi, fvNames); + } + cursor.dispose(); } public void genFvImagesFvImage(String[] names, String types, Map options) { @@ -2704,6 +2749,22 @@ public class FpdFileContents { } } + public void updateFvImageNamesInFvImage (int i, String oldFvName, String newFvName) { + XmlObject o = getfpdFlash().getFvImages(); + if (o == null) { + return; + } + XmlCursor cursor = o.newCursor(); + QName qFvImage = new QName(xmlNs, "FvImage"); + if (cursor.toChild(qFvImage)) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(qFvImage); + } + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject(); + updateFvImageNamesInFvImage (fi, oldFvName, newFvName); + } + cursor.dispose(); + } /** * @param fi * @param oldFvName The FV Name to be replaced. @@ -2721,7 +2782,7 @@ public class FpdFileContents { cursor.setTextValue(newFvName); } else { - cursor.removeXml(); + cursor.removeXml(); } } }while (cursor.toNextSibling(qFvImageNames)); @@ -2730,6 +2791,27 @@ public class FpdFileContents { cursor.dispose(); } + /**update the Type attribute of ith FvImage with new type. + * @param i + * @param type + */ + public void updateFvImagesFvImageType (int i, String type) { + XmlObject o = getfpdFlash().getFvImages(); + if (o == null) { + return; + } + XmlCursor cursor = o.newCursor(); + QName qFvImage = new QName(xmlNs, "FvImage"); + if (cursor.toChild(qFvImage)) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(qFvImage); + } + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject(); + fi.setType(FvImageTypes.Enum.forString(type)); + } + cursor.dispose(); + } + public void updateFvImagesFvImage(int i, String[] names, String types, Map options){ XmlObject o = getfpdFlash().getFvImages(); @@ -2847,19 +2929,43 @@ public class FpdFileContents { } } + public void removeFvImageNameValue (int i, String attributeName) { + XmlObject o = getfpdFlash().getFvImages(); + if (o == null) { + return; + } + XmlCursor cursor = o.newCursor(); + QName qFvImage = new QName(xmlNs, "FvImage"); + if (cursor.toChild(qFvImage)) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(qFvImage); + } + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject(); + removeFvImageNameValue (fi, attributeName); + } + cursor.dispose(); + } + /**Remove from fi the attribute pair with attributeName in FvImageOptions. + * @param fi + * @param attributeName + */ + public void removeFvImageNameValue (FvImagesDocument.FvImages.FvImage fi, String attributeName) { + if (fi.getFvImageOptions() != null && fi.getFvImageOptions().getNameValueList() != null) { + ListIterator li = fi.getFvImageOptions().getNameValueList().listIterator(); + while (li.hasNext()) { + FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next(); + if (nv.getName().equals(attributeName)) { + li.remove(); + } + } + } + } + public void removeTypedNamedFvImageNameValue (String fvName, String type, String optName) { Vector vFvImage = getFvImagesFvImageWithName(fvName, type); for (int i = 0; i < vFvImage.size(); ++i) { FvImagesDocument.FvImages.FvImage fi = vFvImage.get(i); - if (fi.getFvImageOptions() != null && fi.getFvImageOptions().getNameValueList() != null) { - ListIterator li = fi.getFvImageOptions().getNameValueList().listIterator(); - while (li.hasNext()) { - FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next(); - if (nv.getName().equals(optName)) { - li.remove(); - } - } - } + removeFvImageNameValue (fi, optName); } } @@ -2922,6 +3028,23 @@ public class FpdFileContents { } + public void setFvImagesFvImageNameValue (int i, String name, String value) { + XmlObject o = getfpdFlash().getFvImages(); + if (o == null) { + return; + } + XmlCursor cursor = o.newCursor(); + QName qFvImage = new QName(xmlNs, "FvImage"); + if (cursor.toChild(qFvImage)) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(qFvImage); + } + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject(); + setFvImagesFvImageNameValue (fi, name, value, null); + } + cursor.dispose(); + } + /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before. * @param fi * @param name @@ -2930,6 +3053,12 @@ public class FpdFileContents { */ public void setFvImagesFvImageNameValue (FvImagesDocument.FvImages.FvImage fi, String name, String value, String newName) { if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null) { + FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.addNewFvImageOptions().addNewNameValue(); + nv.setName(name); + nv.setValue(value); + if (newName != null) { + nv.setName(newName); + } return; } @@ -2974,6 +3103,50 @@ public class FpdFileContents { } } } + + public int getFvImagePosInFvImages (String fvNameList, String type) { + XmlObject o = getfpdFlash().getFvImages(); + if (o == null) { + return -1; + } + + int pos = -1; + String[] fvNameArray = fvNameList.trim().split(" "); + Vector vFvNames = new Vector(); + + + XmlCursor cursor = o.newCursor(); + QName qFvImage = new QName(xmlNs, "FvImage"); + if (cursor.toChild(qFvImage)) { + do { + pos++; + vFvNames.removeAllElements(); + for (int i = 0; i < fvNameArray.length; ++i) { + vFvNames.add(fvNameArray[i]); + } + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject(); + if (!fi.getType().toString().equals(type)) { + continue; + } + if (fi.getFvImageNamesList() == null || fi.getFvImageNamesList().size() != vFvNames.size()) { + continue; + } + ListIterator li = fi.getFvImageNamesList().listIterator(); + while (li.hasNext()) { + String name = li.next(); + vFvNames.remove(name); + } + if (vFvNames.size() == 0) { + cursor.dispose(); + return pos; + } + + }while (cursor.toNextSibling(qFvImage)); + + } + cursor.dispose(); + return -1; + } /**Get FvImage Options for FvImage i * @param i the ith FvImage */ @@ -2990,6 +3163,7 @@ public class FpdFileContents { } FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject(); if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null){ + cursor.dispose(); return; } ListIterator li = fi.getFvImageOptions().getNameValueList().listIterator(); @@ -2998,6 +3172,7 @@ public class FpdFileContents { m.put(nv.getName(), nv.getValue()); } } + cursor.dispose(); } /**