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=9e2f955599a4130847bee90aac003e4b48a78ad6;hpb=98c207975ec9acc2a4a65fe8c5e3e4f5ab824349;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 9e2f955599..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) { @@ -2698,9 +2743,28 @@ public class FpdFileContents { while (li.hasNext()) { FvImagesDocument.FvImages.FvImage fi = li.next(); updateFvImageNamesInFvImage (fi, oldFvName, newFvName); + if (fi.getFvImageNamesList().size() == 0) { + li.remove(); + } } } + 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. @@ -2712,18 +2776,13 @@ public class FpdFileContents { if (cursor.toChild(qFvImageNames)) { do { - if (cursor.getTextValue().equals(oldFvName)){ + String xmlValue = cursor.getTextValue(); + if (xmlValue.equals(oldFvName)){ if (newFvName != null) { cursor.setTextValue(newFvName); } else { - if (fi.getFvImageNamesList().size() == 1) { - removeElement(fi); - break; - } - else { - cursor.removeXml(); - } + cursor.removeXml(); } } }while (cursor.toNextSibling(qFvImageNames)); @@ -2732,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(); @@ -2849,6 +2929,46 @@ 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); + removeFvImageNameValue (fi, optName); + } + } + /**Add name-value pair to FvImage element with type. * @param fvName FV name to add name-value pair. * @param type FvImage attribute. @@ -2856,6 +2976,7 @@ public class FpdFileContents { * @param value */ public void setTypedNamedFvImageNameValue (String fvName, String type, String name, String value) { + boolean fvImageExists = false; if (getfpdFlash().getFvImages() == null) { return; } @@ -2872,8 +2993,15 @@ public class FpdFileContents { if (!fi.getFvImageNamesList().contains(fvName)) { continue; } + fvImageExists = true; setFvImagesFvImageNameValue (fi, name, value, null); } + + if (!fvImageExists) { + HashMap map = new HashMap(); + map.put(name, value); + genFvImagesFvImage(new String[]{fvName}, type, map); + } } /**Add to all FvImage elements with type, the name-value pair. @@ -2897,6 +3025,24 @@ public class FpdFileContents { } setFvImagesFvImageNameValue (fi, name, value, null); } + + } + + 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. @@ -2907,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; } @@ -2951,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 */ @@ -2967,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(); @@ -2975,6 +3172,7 @@ public class FpdFileContents { m.put(nv.getName(), nv.getValue()); } } + cursor.dispose(); } /**