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=9e2f955599a4130847bee90aac003e4b48a78ad6;hp=a8191aba5fe91cdd14d43fe735cdf4ed3900d6f1;hb=98c207975ec9acc2a4a65fe8c5e3e4f5ab824349;hpb=f3b0ed9a12ec287bb336b9672a0937667f1958ec 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 a8191aba5f..9e2f955599 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 @@ -40,6 +40,7 @@ import org.tianocore.FrameworkModulesDocument; import org.tianocore.IntermediateOutputType; import org.tianocore.LibrariesDocument; import org.tianocore.ModuleSADocument; +import org.tianocore.ModuleSaBuildOptionsDocument; import org.tianocore.ModuleSurfaceAreaDocument; import org.tianocore.OptionDocument; import org.tianocore.OptionsDocument; @@ -56,10 +57,11 @@ import org.tianocore.LicenseDocument; import org.tianocore.PlatformHeaderDocument; import org.tianocore.SkuInfoDocument; import org.tianocore.UserDefinedAntTasksDocument; -import org.tianocore.frameworkwizard.platform.ui.global.GlobalData; +import org.tianocore.UserExtensionsDocument; +import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile; import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery; -import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification; -import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification; +import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; +import org.tianocore.frameworkwizard.packaging.PackageIdentification; /** This class processes fpd file contents such as add remove xml elements. @@ -85,7 +87,9 @@ public class FpdFileContents { private DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs = null; - public static HashMap> dynPcdMap = null; + private HashMap> dynPcdMap = null; + + private HashMap defaultPcdValue = new HashMap(); /** * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings. @@ -95,17 +99,19 @@ public class FpdFileContents { dynPcdMap = new HashMap>(); List l = getfpdFrameworkModules().getModuleSAList(); if (l == null) { + removeElement(getfpdFrameworkModules()); + fpdFrameworkModules = null; return; } ListIterator li = l.listIterator(); while (li.hasNext()) { - ModuleSADocument.ModuleSA msa = li.next(); - if (msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null) { + ModuleSADocument.ModuleSA moduleSa = li.next(); + if (moduleSa.getPcdBuildDefinition() == null || moduleSa.getPcdBuildDefinition().getPcdDataList() == null) { continue; } - String ModuleInfo = msa.getModuleGuid() + " " + msa.getModuleVersion() + - " " + msa.getPackageGuid() + " " + msa.getPackageVersion(); - List lp = msa.getPcdBuildDefinition().getPcdDataList(); + String ModuleInfo = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() + + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList()); + List lp = moduleSa.getPcdBuildDefinition().getPcdDataList(); ListIterator lpi = lp.listIterator(); while (lpi.hasNext()) { PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = lpi.next(); @@ -122,6 +128,10 @@ public class FpdFileContents { } } } + + public ArrayList getDynPcdMapValue(String key) { + return dynPcdMap.get(key); + } /** Constructor to create a new spd file **/ @@ -174,8 +184,36 @@ public class FpdFileContents { return fpdFrameworkModules; } + public void getFrameworkModuleGuid (String fvName, Vector vGuid) { + if (getFrameworkModulesCount() == 0){ + return; + } + + ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator(); + while(li.hasNext()) { + ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next(); + if (moduleSa.getModuleSaBuildOptions() == null) { + continue; + } + String fvBinding = moduleSa.getModuleSaBuildOptions().getFvBinding(); + if (fvBinding == null) { + continue; + } + + String[] fvNames = fvBinding.split(" "); + for (int i = 0; i < fvNames.length; ++i) { + if (fvNames[i].equals(fvName) || fvNames[i].replaceAll("_", "").equals(fvName)) { + vGuid.add(moduleSa.getModuleGuid()); + break; + } + } + } + } + public int getFrameworkModulesCount() { - if (getfpdFrameworkModules().getModuleSAList() == null){ + if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){ + removeElement(getfpdFrameworkModules()); + fpdFrameworkModules = null; return 0; } return getfpdFrameworkModules().getModuleSAList().size(); @@ -189,53 +227,80 @@ public class FpdFileContents { ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator(); int i = 0; while(li.hasNext()) { - ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next(); - saa[i][1] = msa.getModuleGuid(); - saa[i][2] = msa.getModuleVersion(); + ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next(); + saa[i][0] = moduleSa.getModuleGuid(); + saa[i][1] = moduleSa.getModuleVersion(); - saa[i][3] = msa.getPackageGuid(); - saa[i][4] = msa.getPackageVersion(); -// saa[i][4] = listToString(msa.getSupArchList()); + saa[i][2] = moduleSa.getPackageGuid(); + saa[i][3] = moduleSa.getPackageVersion(); + saa[i][4] = listToString(moduleSa.getSupArchList()); ++i; } } + public void getFrameworkModuleInfo(int i, String[] sa) { + ModuleSADocument.ModuleSA msa = getModuleSA(i); + if (msa == null) { + return; + } + sa[0] = msa.getModuleGuid(); + sa[1] = msa.getModuleVersion(); + sa[2] = msa.getPackageGuid(); + sa[3] = msa.getPackageVersion(); + sa[4] = listToString(msa.getSupArchList()); + } + public ModuleSADocument.ModuleSA getModuleSA(String key) { String[] s = key.split(" "); - if (getfpdFrameworkModules().getModuleSAList() == null) { + if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) { + removeElement(getfpdFrameworkModules()); + fpdFrameworkModules = null; return null; } ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator(); while(li.hasNext()) { - ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next(); - if (msa.getModuleGuid().equals(s[0]) && msa.getPackageGuid().equals(s[2])) { - if (msa.getModuleVersion() != null) { - if (!msa.getModuleVersion().equals(s[1])) { + ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next(); + if (moduleSa.getModuleGuid().equalsIgnoreCase(s[0]) && moduleSa.getPackageGuid().equalsIgnoreCase(s[2])) { + if (moduleSa.getModuleVersion() != null) { + if (!moduleSa.getModuleVersion().equals(s[1])) { continue; } } - else{ - if (s[1] != null) { + if (moduleSa.getPackageVersion() != null) { + if (!moduleSa.getPackageVersion().equals(s[3])) { continue; } } - if (msa.getPackageVersion() != null) { - if (!msa.getPackageVersion().equals(s[3])) { + //ToDo add arch check for s[4] + if (moduleSa.getSupArchList() != null) { + if (!listToString(moduleSa.getSupArchList()).equals(s[4])) { continue; } } - else{ - if (s[3] != null) { - continue; - } - } - return msa; + return moduleSa; } } return null; } + + private ModuleSADocument.ModuleSA getModuleSA(int i) { + ModuleSADocument.ModuleSA moduleSa = null; + if (fpdRoot.getFrameworkModules() == null) { + return null; + } + XmlCursor cursor = fpdRoot.getFrameworkModules().newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject(); + } + cursor.dispose(); + return moduleSa; + } + public void removeModuleSA(int i) { - XmlObject o = getfpdFrameworkModules(); + XmlObject o = fpdRoot.getFrameworkModules(); if (o == null) { return; } @@ -250,112 +315,347 @@ public class FpdFileContents { // ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject(); String moduleInfo = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() + " " + - moduleSa.getPackageGuid()+ " " + moduleSa.getPackageVersion(); + moduleSa.getPackageGuid()+ " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList()); PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef = moduleSa.getPcdBuildDefinition(); - if (pcdBuildDef != null) { - maintainDynPcdMap(pcdBuildDef, moduleInfo); + if (pcdBuildDef != null && pcdBuildDef.getPcdDataList() != null) { + ListIterator li = pcdBuildDef.getPcdDataList().listIterator(); + while(li.hasNext()) { + PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next(); + maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), moduleInfo); + } + } + + cursor.push(); + cursor.toPrevToken(); + if (cursor.isComment()) { + cursor.removeXml(); } + cursor.pop(); cursor.removeXml(); + if (getFrameworkModulesCount() == 0) { + cursor.toParent(); + cursor.removeXml(); + } } cursor.dispose(); } - private void maintainDynPcdMap(PcdBuildDefinitionDocument.PcdBuildDefinition o, String moduleInfo) { - XmlCursor cursor = o.newCursor(); - boolean fromLibInstance = false; - if (!cursor.toFirstChild()){ - return; + public boolean adjustPcd (int seqModuleSa) throws Exception { + boolean dataModified = false; + ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa); + int pcdCount = getPcdDataCount(seqModuleSa); + String[][] saaModuleSaPcd = new String[pcdCount][7]; + getPcdData(seqModuleSa, saaModuleSaPcd); + String mg = moduleSa.getModuleGuid(); + String mv = moduleSa.getModuleVersion(); + String pg = moduleSa.getPackageGuid(); + String pv = moduleSa.getPackageVersion(); + String arch = listToString(moduleSa.getSupArchList()); + // + // delete pcd in ModuleSA but not in MSA files any longer. + // + String moduleKey = mg + " " + mv + " " + pg + " " + pv + " " + arch; + int libCount = getLibraryInstancesCount(moduleKey); + String[][] saaLib = new String[libCount][5]; + getLibraryInstances(moduleKey, saaLib); + ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey); + Vector vMi = new Vector(); + vMi.add(mi); + 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)) { + continue nextPcd; + } + } + removePcdData(seqModuleSa, saaModuleSaPcd[i][0], saaModuleSaPcd[i][1]); + dataModified = true; + } + } + catch (Exception e) { + } // - // deal with first child, same process in the while loop below for siblings. + // add new Pcd from MSA file to ModuleSA. // - PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject(); - String pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(); + try { + + for (int i = 0; i < vMi.size(); ++i) { + ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile + .getModuleXmlObject(vMi + .get(i)); + if (msa.getPcdCoded() == null || msa.getPcdCoded().getPcdEntryList() == null) { + continue; + } + ListIterator li = msa.getPcdCoded().getPcdEntryList().listIterator(); + msaPcdIter:while (li.hasNext()) { + PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry) li.next(); + ArrayList al = getDynPcdMapValue(msaPcd.getCName() + " " + msaPcd.getTokenSpaceGuidCName()); + if (al != null) { + for (int j = 0; j < al.size(); ++j) { + if (al.get(j).contains(moduleKey)) { + continue msaPcdIter; + } + } + } + + 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) { + // + // ToDo Error + // + throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module " + + mi.getName()); + } + // + // AddItem to ModuleSA PcdBuildDefinitions + // + String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() + : msaPcd.getDefaultValue(); + + genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), + msaPcd.getPcdItemType().toString(), spdPcd.getDatumType() + "", defaultVal, moduleSa); + dataModified = true; + } + + } + } + catch (Exception e){ + throw e; + } + + return dataModified; + } + + private void maintainDynPcdMap(String pcdKey, String moduleInfo) { + ArrayList al = dynPcdMap.get(pcdKey); + if (al == null) { + return; + } + String[] s = moduleInfo.split(" "); for(int i = 0; i < al.size(); ++i){ - if (al.get(i).startsWith(moduleInfo)){ - fromLibInstance = true; + String consumer = al.get(i); + if (consumer.contains(s[0]) && consumer.contains(s[2])){ + String[] consumerPart = consumer.split(" "); + if (!consumerPart[4].equals(s[4])) { + continue; + } + al.remove(consumer); break; } } - al.remove(moduleInfo + " " + pcdData.getItemType().toString()); + if (al.size() == 0) { + defaultPcdValue.remove(pcdKey); dynPcdMap.remove(pcdKey); + String[] s1 = pcdKey.split(" "); + removeDynamicPcdBuildData(s1[0], s1[1]); + } + + } + // + // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch" + // + public int getPcdDataCount (int i){ + ModuleSADocument.ModuleSA msa = getModuleSA(i); + + if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){ + return 0; } + return msa.getPcdBuildDefinition().getPcdDataList().size(); + + } + + public void getPcdData (int i, String[][] saa) { + ModuleSADocument.ModuleSA msa = getModuleSA(i); - if (pcdData.getItemType().toString().equals("DYNAMIC")) { - if (dynPcdMap.get(pcdKey) == null) { - removeDynamicPcdBuildData(pcdData.getCName(), pcdData.getTokenSpaceGuidCName()); + if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){ + return; + } + ListIteratorli = msa.getPcdBuildDefinition().getPcdDataList().listIterator(); + for (int k = 0; k < saa.length; ++k) { + PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next(); + saa[k][0] = pcdData.getCName(); + saa[k][1] = pcdData.getTokenSpaceGuidCName(); + saa[k][2] = pcdData.getItemType()+""; + saa[k][3] = pcdData.getToken().toString(); + saa[k][4] = pcdData.getMaxDatumSize()+""; + saa[k][5] = pcdData.getDatumType()+""; + saa[k][6] = pcdData.getValue(); + + } + } + + public void removePcdData (int seqModuleSa, String cName, String tsGuid) { + ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa); + if (moduleSa == null || moduleSa.getPcdBuildDefinition() == null){ + return; + } + + String mg = moduleSa.getModuleGuid(); + String mv = moduleSa.getModuleVersion(); + String pg = moduleSa.getPackageGuid(); + String pv = moduleSa.getPackageVersion(); + String arch = listToString(moduleSa.getSupArchList()); + String moduleKey = mg + " " + mv + " " + pg + " " + pv + " " + arch; + + XmlCursor cursor = moduleSa.getPcdBuildDefinition().newCursor(); + if (cursor.toFirstChild()){ + + do { + PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject(); + if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) { + maintainDynPcdMap(cName + " " + tsGuid, moduleKey); + if (getPcdDataCount(seqModuleSa) == 1) { + cursor.toParent(); + } + cursor.removeXml(); + break; + } } + while(cursor.toNextSibling()); + } - if (fromLibInstance){ - cursor.removeXml(); + cursor.dispose(); + } + + public void updatePcdData (String key, String cName, String tsGuid, String itemType, String maxSize, String value){ + ModuleSADocument.ModuleSA moduleSa = getModuleSA(key); + if (moduleSa == null || moduleSa.getPcdBuildDefinition() == null){ + return; } - while(cursor.toNextSibling()) { - fromLibInstance = false; - pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject(); - // - // remove each pcd record from dynPcdMap - // - pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(); - al = dynPcdMap.get(pcdKey); - for(int i = 0; i < al.size(); ++i){ - if (al.get(i).startsWith(moduleInfo)){ - fromLibInstance = true; + + XmlCursor cursor = moduleSa.getPcdBuildDefinition().newCursor(); + if (cursor.toFirstChild()){ + do { + PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject(); + if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) { + pcdData.setItemType(PcdItemTypes.Enum.forString(itemType)); + if(pcdData.getDatumType().equals("VOID*")) { + pcdData.setMaxDatumSize(new Integer(maxSize)); + } + pcdData.setValue(value); + defaultPcdValue.put(cName + " " + tsGuid, value); break; } } - al.remove(moduleInfo + " " + pcdData.getItemType().toString()); - if (al.size() == 0) { - dynPcdMap.remove(pcdKey); + while(cursor.toNextSibling()); + } + cursor.dispose(); + } + + /**Get original Pcd info from MSA & SPD files. + * @param mi ModuleIdentification from which MSA & SPD come + * @param cName PCD cName + * @param sa Results: HelpText, Original item type. + * @return + */ + public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String tsGuid, String[] sa) throws Exception{ + try { + + ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi); + if (msa.getPcdCoded() == null) { + return false; } - if (pcdData.getItemType().toString().equals("DYNAMIC")) { - // - // First check whether this is the only consumer of this dyn pcd. - // - if (dynPcdMap.get(pcdKey) == null) { + Map m = new HashMap(); + m.put("ModuleSurfaceArea", msa); + SurfaceAreaQuery.setDoc(m); + PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi); + // + // First look through MSA pcd entries. + // + List l = msa.getPcdCoded().getPcdEntryList(); + ListIterator li = l.listIterator(); + while(li.hasNext()) { + PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next(); + if (!msaPcd.getCName().equals(cName)) { + continue; + } + if (!msaPcd.getTokenSpaceGuidCName().equals(tsGuid)) { + continue; + } + PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs); + if (spdPcd == null) { // - // delete corresponding entry in DynamicPcdBuildData + // ToDo Error // - removeDynamicPcdBuildData(pcdData.getCName(), pcdData.getTokenSpaceGuidCName()); + throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName()); } + // + // Get Pcd help text and original item type. + // + sa[0] = spdPcd.getHelpText() + msaPcd.getHelpText(); + sa[1] = msaPcd.getPcdItemType()+""; + return true; } - if (fromLibInstance){ - cursor.removeXml(); - } + + } - } - // - // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer" - // - public int getPcdDataCount(String key){ - ModuleSADocument.ModuleSA msa = getModuleSA(key); - if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){ - return 0; + catch (Exception e){ + e.printStackTrace(); + throw e; } - return msa.getPcdBuildDefinition().getPcdDataList().size(); + + return false; } - public void getPcdData(String key, String[][] saa) { - ModuleSADocument.ModuleSA msa = getModuleSA(key); - if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){ - return; + /**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; + } + + List l = msa.getPcdCoded().getPcdEntryList(); + ListIterator li = l.listIterator(); + + while(li.hasNext()) { + PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next(); + ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey); + if (moduleSA.getPcdBuildDefinition() != null) { + XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor(); + if (cursor.toFirstChild()) { + do { + PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor + .getObject(); + if (msaPcd.getCName().equals(pcdData.getCName()) + && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) { + + maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), + moduleKey); + cursor.removeXml(); + break; + } + } while (cursor.toNextSibling()); + } + cursor.dispose(); + } + } + } - ListIteratorli = msa.getPcdBuildDefinition().getPcdDataList().listIterator(); - for (int i = 0; i < saa.length; ++i) { - PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next(); - saa[i][0] = pcdData.getCName(); - saa[i][1] = pcdData.getTokenSpaceGuidCName(); - saa[i][2] = pcdData.getItemType().toString(); - saa[i][3] = pcdData.getToken().toString(); - saa[i][4] = pcdData.getDatumType().toString(); - saa[i][5] = pcdData.getValue(); + catch (Exception e){ + e.printStackTrace(); } } // - // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer" + // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch" // public int getLibraryInstancesCount(String key) { ModuleSADocument.ModuleSA msa = getModuleSA(key); @@ -381,18 +681,34 @@ public class FpdFileContents { } } - public void removeLibraryInstances(String key) { + public void removeLibraryInstance(String key, int i) { ModuleSADocument.ModuleSA msa = getModuleSA(key); if (msa == null || msa.getLibraries() == null){ return ; } XmlCursor cursor = msa.getLibraries().newCursor(); - cursor.removeXml(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.push(); + cursor.toPrevToken(); + if (cursor.isComment()) { + cursor.removeXml(); + } + cursor.pop(); + cursor.removeXml(); + if (getLibraryInstancesCount(key) == 0) { + cursor.toParent(); + cursor.removeXml(); + } + } + cursor.dispose(); } - public void genLibraryInstance(String mg, String mv, String pg, String pv, String key) { + public void genLibraryInstance(ModuleIdentification libMi, String key) { ModuleSADocument.ModuleSA msa = getModuleSA(key); if (msa == null){ msa = getfpdFrameworkModules().addNewModuleSA(); @@ -402,7 +718,26 @@ public class FpdFileContents { libs = msa.addNewLibraries(); } + String mn = libMi.getName(); + String mg = libMi.getGuid(); + String mv = libMi.getVersion(); + String pn = libMi.getPackageId().getName(); + String pg = libMi.getPackageId().getGuid(); + String pv = libMi.getPackageId().getVersion(); LibrariesDocument.Libraries.Instance instance = libs.addNewInstance(); + XmlCursor cursor = instance.newCursor(); + try{ + String comment = "Pkg: " + pn + " Mod: " + mn + + " Path: " + libMi.getPath().substring(System.getenv("WORKSPACE").length() + 1); + cursor.insertComment(comment); + } + catch (Exception e){ + e.printStackTrace(); + } + finally { + cursor.dispose(); + } + instance.setModuleGuid(mg); instance.setModuleVersion(mv); instance.setPackageGuid(pg); @@ -411,31 +746,169 @@ public class FpdFileContents { } public String getFvBinding(String moduleKey){ - ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); - if (msa == null || msa.getModuleSaBuildOptions() == null) { + ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey); + return getFvBinding (moduleSa); + } + + public String getFvBinding (ModuleSADocument.ModuleSA moduleSa) { + if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null) { return null; } - return msa.getModuleSaBuildOptions().getFvBinding(); + return moduleSa.getModuleSaBuildOptions().getFvBinding(); + } + + public void setFvBinding(ModuleSADocument.ModuleSA moduleSa, String fvBinding) { + if (moduleSa == null ) { + return; + } + if (fvBinding == null || fvBinding.length() == 0) { + if(moduleSa.getModuleSaBuildOptions() != null){ + moduleSa.getModuleSaBuildOptions().unsetFvBinding(); + } + } + else { + if(moduleSa.getModuleSaBuildOptions() == null){ + moduleSa.addNewModuleSaBuildOptions().setFvBinding(fvBinding); + return; + } + moduleSa.getModuleSaBuildOptions().setFvBinding(fvBinding); + } } public void setFvBinding(String moduleKey, String fvBinding){ - ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); - if (msa == null ) { + ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey); + setFvBinding (moduleSa, fvBinding); + } + + private int fvBindingForModuleSA (ModuleSADocument.ModuleSA moduleSa, String fvName) { + if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) { + return -1; + } + + String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding(); + String[] fvNamesArray = fvNameList.split(" "); + int occursAt = -1; + for (int i = 0; i < fvNamesArray.length; ++i) { + if (fvNamesArray[i].equals(fvName)) { + occursAt = i; + break; + } + } + return occursAt; + } + + public void removeFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) { + if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) { return; } - if(msa.getModuleSaBuildOptions() == null){ - msa.addNewModuleSaBuildOptions().setFvBinding(fvBinding); + + String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding(); + String[] fvNamesArray = fvNameList.split(" "); + int occursAt = -1; + for (int i = 0; i < fvNamesArray.length; ++i) { + if (fvNamesArray[i].equals(fvName)) { + occursAt = i; + break; + } + } + // jump over where the input fvName occurs in the original Fv list. + if (occursAt != -1) { + String newFvNameList = " "; + for (int i = 0; i < fvNamesArray.length; ++i) { + if (i == occursAt) { + continue; + } + newFvNameList += fvNamesArray[i]; + } + setFvBinding (moduleSa, newFvNameList.trim()); + } + + } + + /** + * @param fvName The FV name that to be removed from FvBinding List. + */ + public void removeFvBindingAll (String fvName) { + if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){ + removeElement(getfpdFrameworkModules()); + fpdFrameworkModules = null; return; } - msa.getModuleSaBuildOptions().setFvBinding(fvBinding); + + Iterator li = getfpdFrameworkModules().getModuleSAList().iterator(); + while (li.hasNext()) { + ModuleSADocument.ModuleSA moduleSa = li.next(); + removeFvBinding (moduleSa, fvName); + } + } + + public void appendFvBindingAll (String fvName) { + if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){ + removeElement(getfpdFrameworkModules()); + fpdFrameworkModules = null; + return; + } + + Iterator li = getfpdFrameworkModules().getModuleSAList().iterator(); + while (li.hasNext()) { + ModuleSADocument.ModuleSA moduleSa = li.next(); + appendFvBinding (moduleSa, fvName); + } + } + + public void appendFvBindingFor (String oldFvName, String newFvName) { + if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){ + removeElement(getfpdFrameworkModules()); + fpdFrameworkModules = null; + return; + } + + Iterator li = getfpdFrameworkModules().getModuleSAList().iterator(); + while (li.hasNext()) { + ModuleSADocument.ModuleSA moduleSa = li.next(); + String fvBinding = getFvBinding (moduleSa); + if (fvBinding != null && fvBindingForModuleSA (moduleSa, oldFvName) >= 0) { + appendFvBinding (moduleSa, newFvName); + } + } + } + + public void appendFvBinding (String moduleKey, String fvName) { + ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey); + appendFvBinding (moduleSa, fvName); + } + + public void appendFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) { + if (moduleSa == null) { + return; + } + + if (moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) { + setFvBinding(moduleSa, fvName); + return; + } + + String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding(); + String newFvNameList = fvNameList + " " + fvName; + 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 String getFfsFileNameGuid(String moduleKey){ - ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); - if (msa == null || msa.getModuleSaBuildOptions() == null) { + ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey); + if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null) { return null; } - return msa.getModuleSaBuildOptions().getFfsFileNameGuid(); + return moduleSa.getModuleSaBuildOptions().getFfsFileNameGuid(); } public void setFfsFileNameGuid(String moduleKey, String fileGuid){ @@ -444,10 +917,21 @@ public class FpdFileContents { return; } if(msa.getModuleSaBuildOptions() == null){ - msa.addNewModuleSaBuildOptions().setFfsFileNameGuid(fileGuid); - return; + msa.addNewModuleSaBuildOptions(); + } - msa.getModuleSaBuildOptions().setFfsFileNameGuid(fileGuid); + ModuleSaBuildOptionsDocument.ModuleSaBuildOptions msaBuildOpts= msa.getModuleSaBuildOptions(); + if (fileGuid != null) { + msaBuildOpts.setFfsFileNameGuid(fileGuid); + } + else{ + XmlCursor cursor = msaBuildOpts.newCursor(); + if (cursor.toChild(xmlNs, "FfsFileNameGuid")) { + cursor.removeXml(); + } + cursor.dispose(); + } + } public String getFfsFormatKey(String moduleKey){ @@ -467,12 +951,25 @@ public class FpdFileContents { msa.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey); return; } - msa.getModuleSaBuildOptions().setFvBinding(ffsKey); + msa.getModuleSaBuildOptions().setFfsFormatKey(ffsKey); + } + + public void setModuleSAForceDebug(int i, boolean dbgEnable) { + ModuleSADocument.ModuleSA moduleSa = getModuleSA(i); + moduleSa.setForceDebug(dbgEnable); + } + + public boolean getModuleSAForceDebug (int i) { + ModuleSADocument.ModuleSA moduleSa = getModuleSA(i); + if (moduleSa.getForceDebug() == true) { + return true; + } + return false; } public void getModuleSAOptions(String moduleKey, String[][] saa) { ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); - if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null + if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) { return ; } @@ -486,12 +983,16 @@ public class FpdFileContents { saa[i][0] = listToString(opt.getBuildTargets()); } saa[i][1] = opt.getToolChainFamily(); + saa[i][2] = opt.getTagName(); + saa[i][3] = opt.getToolCode(); + if (opt.getSupArchList() != null){ - saa[i][2] = listToString(opt.getSupArchList()); - + saa[i][4] = listToString(opt.getSupArchList()); } - saa[i][3] = opt.getToolCode(); - saa[i][4] = opt.getTagName(); + else { + saa[i][4] = ""; + } + saa[i][5] = opt.getStringValue(); ++i; @@ -500,7 +1001,7 @@ public class FpdFileContents { public int getModuleSAOptionsCount(String moduleKey){ ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); - if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null + if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) { return 0; } @@ -556,21 +1057,23 @@ public class FpdFileContents { * @param mi * @param moduleSa if null, generate a new ModuleSA. */ - public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, ModuleSADocument.ModuleSA moduleSa){ + public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, String arch, ModuleSADocument.ModuleSA moduleSa) throws Exception { //ToDo add Arch filter try { - ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi); + if (moduleSa == null) { + moduleSa = genModuleSA(mi, arch); + } + + ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi); if (msa.getPcdCoded() == null) { return; } - if (moduleSa == null) { - moduleSa = genModuleSA(mi); - } + Map m = new HashMap(); m.put("ModuleSurfaceArea", msa); SurfaceAreaQuery.setDoc(m); - PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null); + PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi); // // Implementing InitializePlatformPcdBuildDefinitions // @@ -583,30 +1086,30 @@ public class FpdFileContents { // // ToDo Error // - break; + throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module " + mi.getName()); } // // AddItem to ModuleSA PcdBuildDefinitions // String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue(); + genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa); } } catch (Exception e){ - e.printStackTrace(); + + throw e; } } private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) { - Map m = new HashMap(); PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null; for (int i = 0; i < depPkgs.length; ++i) { - m.put("PackageSurfaceArea", GlobalData.getPackageXmlObject(depPkgs[i])); - SurfaceAreaQuery.setDoc(m); - XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations(); + + XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations(depPkgs[i]); if (xo == null) { continue; } @@ -629,18 +1132,36 @@ public class FpdFileContents { return null; } - private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi) { - PackageIdentification pi = GlobalData.getPackageForModule(mi); + private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi, String arch) { + PackageIdentification pi = WorkspaceProfile.getPackageForModule(mi); ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA(); + XmlCursor cursor = msa.newCursor(); + try{ + String comment = "Mod: " + mi.getName() + " Type: " + SurfaceAreaQuery.getModuleType(mi) + " Path: " + + mi.getPath().substring(System.getenv("WORKSPACE").length() + 1); + cursor.insertComment(comment); + } + catch(Exception e){ + e.printStackTrace(); + } + finally { + cursor.dispose(); + } msa.setModuleGuid(mi.getGuid()); msa.setModuleVersion(mi.getVersion()); msa.setPackageGuid(pi.getGuid()); msa.setPackageVersion(pi.getVersion()); + if (arch != null) { + Vector v = new Vector(); + v.add(arch); + msa.setSupArchList(v); + } return msa; } - private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) { + private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) + throws PcdItemTypeConflictException, PcdValueMalFormed{ if (moduleSa.getPcdBuildDefinition() == null){ moduleSa.addNewPcdBuildDefinition(); } @@ -652,39 +1173,18 @@ public class FpdFileContents { if (pcdConsumer == null) { pcdConsumer = new ArrayList(); } + // + // 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]; + } String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() - + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList()) + " " + itemType; pcdConsumer.add(listValue); dynPcdMap.put(cName + " " + tsGuid, pcdConsumer); - // - // Special dynamic type, if this pcd already exists in other ModuleSA - // - if (itemType.equals("DYNAMIC")) { - - ListIterator li = pcdConsumer.listIterator(); - while(li.hasNext()) { - String value = li.next().toString(); - String[] valuePart= value.split(" "); - if (!valuePart[4].equals("DYNAMIC")) { - //ToDo error for same pcd, other type than dynamic - pcdConsumer.remove(listValue); - return; - } - } - } - else { - ListIterator li = pcdConsumer.listIterator(); - while(li.hasNext()) { - String value = li.next().toString(); - String[] valuePart= value.split(" "); - if (valuePart[4].equals("DYNAMIC")) { - //ToDo error for same pcd, other type than non-dynamic - pcdConsumer.remove(listValue); - return; - } - } - } PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData(); fpdPcd.setCName(cName); @@ -693,6 +1193,51 @@ public class FpdFileContents { fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType)); fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType)); + if (defaultVal != null){ + fpdPcd.setValue(defaultVal); + } + else { + if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) { + fpdPcd.setValue("0"); + } + if (dataType.equals("BOOLEAN")){ + fpdPcd.setValue("FALSE"); + } + if (dataType.equals("VOID*")) { + fpdPcd.setValue(""); + } + } + // + // Using existing pcd value, if this pcd already exists in other moduleSa. + // + if (defaultPcdValue.get(cName + " " + tsGuid) == null) { + defaultPcdValue.put(cName + " " + tsGuid, fpdPcd.getValue()); + } + else { + fpdPcd.setValue(defaultPcdValue.get(cName + " " + tsGuid)); + } + + if (dataType.equals("UINT8")){ + fpdPcd.setMaxDatumSize(1); + } + if (dataType.equals("UINT16")) { + fpdPcd.setMaxDatumSize(2); + } + if (dataType.equals("UINT32")) { + fpdPcd.setMaxDatumSize(4); + } + if (dataType.equals("UINT64")){ + fpdPcd.setMaxDatumSize(8); + } + if (dataType.equals("BOOLEAN")){ + fpdPcd.setMaxDatumSize(1); + } + if (dataType.equals("VOID*")) { + int maxSize = setMaxSizeForPointer(fpdPcd.getValue()); + fpdPcd.setMaxDatumSize(maxSize); + } + + if (itemType.equals("DYNAMIC") || itemType.equals("DYNAMIC_EX")) { ArrayList al = LookupDynamicPcdBuildDefinition(cName + " " + tsGuid); // @@ -703,44 +1248,10 @@ public class FpdFileContents { addDynamicPcdBuildData(cName, token, tsGuid, itemType, dataType, defaultVal); } } - else { - if (defaultVal != null){ - fpdPcd.setValue(defaultVal); - } - else { - if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) { - fpdPcd.setValue("0"); - } - if (dataType.equals("BOOLEAN")){ - fpdPcd.setValue("false"); - } - if (dataType.equals("VOID*")) { - fpdPcd.setValue(""); - } - } - if (dataType.equals("UINT8")){ - fpdPcd.setMaxDatumSize(1); - } - if (dataType.equals("UINT16")) { - fpdPcd.setMaxDatumSize(2); - } - if (dataType.equals("UINT32")) { - fpdPcd.setMaxDatumSize(4); - } - if (dataType.equals("UINT64")){ - fpdPcd.setMaxDatumSize(8); - } - if (dataType.equals("BOOLEAN")){ - fpdPcd.setMaxDatumSize(1); - } - if (dataType.equals("VOID*")) { - int maxSize = setMaxSizeForPointer(fpdPcd.getValue()); - fpdPcd.setMaxDatumSize(maxSize); - } - } + } - private int setMaxSizeForPointer(String datum) { + public int setMaxSizeForPointer(String datum) throws PcdValueMalFormed{ if (datum == null) { return 0; } @@ -760,6 +1271,7 @@ public class FpdFileContents { (end > datum.length())|| ((start == end) && (datum.length() > 0))) { //ToDo Error handling here + throw new PcdValueMalFormed (datum); } strValue = datum.substring(start + 1, end); @@ -770,7 +1282,7 @@ public class FpdFileContents { if ((start > end) || (end > datum.length())|| ((start == end) && (datum.length() > 0))) { - + throw new PcdValueMalFormed (datum); } strValue = datum.substring(start + 1, end); return strValue.length(); @@ -790,8 +1302,8 @@ public class FpdFileContents { if (value > 0xFF) { // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+ -// "it is byte array in fact. But the element of %s exceed the byte range", - +// "it must be a byte array. But the element of %s exceed the byte range", + throw new PcdValueMalFormed (datum); } } return strValueArray.length; @@ -803,7 +1315,7 @@ public class FpdFileContents { // "2) ANSIC string: like \"xxx\";\r\n"+ // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+ // "but the datum in seems does not following above format!", - return -1; + throw new PcdValueMalFormed (datum); } } @@ -816,18 +1328,22 @@ public class FpdFileContents { private ArrayList LookupPlatformPcdData(String pcdKey) { - return dynPcdMap.get("pcdKey"); + return dynPcdMap.get(pcdKey); } public int getDynamicPcdBuildDataCount() { - if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) { + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; return 0; } return getfpdDynPcdBuildDefs().getPcdBuildDataList().size(); } public void getDynamicPcdBuildData(String[][] saa) { - if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) { + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; return ; } List l = getfpdDynPcdBuildDefs().getPcdBuildDataList(); @@ -845,7 +1361,8 @@ public class FpdFileContents { } } - private void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal) { + public void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal) + throws PcdValueMalFormed{ DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData(); dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType)); dynPcdData.setCName(cName); @@ -900,19 +1417,28 @@ public class FpdFileContents { } } - private void removeDynamicPcdBuildData(String cName, String tsGuid) { - XmlObject o = getfpdDynPcdBuildDefs(); + public void removeDynamicPcdBuildData(String cName, String tsGuid) { + XmlObject o = fpdRoot.getDynamicPcdBuildDefinitions(); + if (o == null) { + return; + } XmlCursor cursor = o.newCursor(); if (cursor.toFirstChild()) { - DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = - (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); - while (!(pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid))) { - cursor.toNextSibling(); - pcdBuildData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); + do { + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = + (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); + if (pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid)) { + + if (getDynamicPcdBuildDataCount() == 1) { + cursor.toParent(); + } + cursor.removeXml(); + cursor.dispose(); + return; + } } - - cursor.removeXml(); + while (cursor.toNextSibling()); } cursor.dispose(); } @@ -920,7 +1446,8 @@ public class FpdFileContents { // Get the Sku Info count of ith dyn pcd element. // public int getDynamicPcdSkuInfoCount(int i){ - if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + if (fpdRoot.getDynamicPcdBuildDefinitions() == null || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null + || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) { return 0; } @@ -944,6 +1471,8 @@ public class FpdFileContents { public void getDynamicPcdSkuInfos(int i, String[][] saa){ if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; return; } @@ -981,6 +1510,8 @@ public class FpdFileContents { public String getDynamicPcdBuildDataValue(int i){ String value = null; if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; return value; } @@ -1004,6 +1535,8 @@ public class FpdFileContents { public String getDynamicPcdBuildDataVpdOffset(int i){ String vpdOffset = null; if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; return vpdOffset; } @@ -1026,6 +1559,8 @@ public class FpdFileContents { public void removeDynamicPcdBuildDataSkuInfo(int i) { if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; return; } @@ -1052,9 +1587,9 @@ public class FpdFileContents { // public void genDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, String hiiDefault, String vpdOffset, String value, int i) { - if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { - return; - } +// if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { +// return; +// } XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor(); if (cursor.toFirstChild()) { @@ -1081,9 +1616,9 @@ public class FpdFileContents { public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, String hiiDefault, String vpdOffset, String value, int i){ - if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { - return; - } +// if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { +// return; +// } XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor(); if (cursor.toFirstChild()) { @@ -1113,15 +1648,6 @@ public class FpdFileContents { } } - public void removePcdDataFromLibraryInstance(String moduleKey, String libInstanceKey){ - ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey); - // - // should better maintain pcd from lib instance only, but maintain all is acceptable now. - // - maintainDynPcdMap(moduleSa.getPcdBuildDefinition(), libInstanceKey); - - } - public BuildOptionsDocument.BuildOptions getfpdBuildOpts() { if (fpdBuildOpts == null) { fpdBuildOpts = fpdRoot.addNewBuildOptions(); @@ -1129,6 +1655,153 @@ public class FpdFileContents { return fpdBuildOpts; } + public void genBuildOptionsUserExtensions(String fvName, String outputFileName, Vector includeModules) { + QName elementFvName = new QName (xmlNs, "FvName"); + QName elementIncludeModules = new QName(xmlNs, "IncludeModules"); + QName elementInfFileName = new QName(xmlNs, "InfFileName"); + QName elementModule = new QName(xmlNs, "Module"); + + UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions(); + userExts.setUserID("IMAGES"); + userExts.setIdentifier(new BigInteger("1")); + XmlCursor cursor = userExts.newCursor(); + cursor.toEndToken(); + + cursor.beginElement(elementFvName); + cursor.insertChars(fvName); + cursor.toNextToken(); + + cursor.beginElement(elementInfFileName); + cursor.insertChars(fvName + ".inf"); + cursor.toNextToken(); + + cursor.beginElement(elementIncludeModules); + 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]); + cursor.toEndToken(); + cursor.toNextToken(); + } + cursor.dispose(); + } + + public int getUserExtsIncModCount (String fvName) { + if (getfpdBuildOpts().getUserExtensionsList() == null) { + return -1; + } + ListIterator li = getfpdBuildOpts().getUserExtensionsList().listIterator(); + QName elementIncludeModules = new QName(xmlNs, "IncludeModules"); + while (li.hasNext()) { + UserExtensionsDocument.UserExtensions ues = li.next(); + if (!ues.getUserID().equals("IMAGES")) { + continue; + } + XmlCursor cursor = ues.newCursor(); + cursor.toFirstChild(); + String elementName = cursor.getTextValue(); + if (elementName.equals(fvName)) { + cursor.toNextSibling(elementIncludeModules); + if (cursor.toFirstChild()) { + int i = 1; + for (i = 1; cursor.toNextSibling(); ++i); + cursor.dispose(); + return i; + } + cursor.dispose(); + return 0; + } + cursor.dispose(); + } + return -1; + } + + public void getUserExtsIncMods(String fvName, String[][] saa) { + if (getfpdBuildOpts().getUserExtensionsList() == null) { + return; + } + + 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 attribBaseName = new QName("BaseName"); + + 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()) { + int i = 0; + do { + saa[i][0] = cursor.getAttributeText(attribModuleGuid); + saa[i][1] = cursor.getAttributeText(attribBaseName); + ++i; + }while (cursor.toNextSibling()); + } + break; + } + } + cursor.pop(); + }while (cursor.toNextSibling(elementUserExts)); + } + cursor.dispose(); + + } + + public void updateBuildOptionsUserExtensions (String oldFvName, String newFvName) { + if (getfpdBuildOpts().getUserExtensionsList() == null) { + return; + } + ListIterator li = getfpdBuildOpts().getUserExtensionsList().listIterator(); + while (li.hasNext()) { + UserExtensionsDocument.UserExtensions ues = li.next(); + if (!ues.getUserID().equals("IMAGES")) { + continue; + } + XmlCursor cursor = ues.newCursor(); + cursor.toFirstChild(); + String elementName = cursor.getTextValue(); + if (elementName.equals(oldFvName)) { + cursor.setTextValue(newFvName); + } + cursor.dispose(); + } + + } + + public void removeBuildOptionsUserExtensions (String fvName) { + if (getfpdBuildOpts().getUserExtensionsList() == null) { + return; + } + + ListIterator li = getfpdBuildOpts().getUserExtensionsList().listIterator(); + while (li.hasNext()) { + UserExtensionsDocument.UserExtensions ues = li.next(); + if (!ues.getUserID().equals("IMAGES")) { + continue; + } + XmlCursor cursor = ues.newCursor(); + cursor.toFirstChild(); + String elementName = cursor.getTextValue(); + if (elementName.equals(fvName)) { + cursor.toParent(); + cursor.removeXml(); + cursor.dispose(); + return; + } + cursor.dispose(); + } + + } + + public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) { UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks(); if (udats == null) { @@ -1141,12 +1814,20 @@ public class FpdFileContents { private void setBuildOptionsUserDefAntTask(String id, String fileName, String execOrder, AntTaskDocument.AntTask at) { at.setId(new Integer(id)); + XmlCursor cursor = at.newCursor(); if (fileName != null){ at.setFilename(fileName); } + else if (cursor.toChild(xmlNs, "Filename")) { + cursor.removeXml(); + } if (execOrder != null) { at.setAntCmdOptions(execOrder); } + else if (cursor.toChild(xmlNs, "AntCmdOptions")) { + cursor.removeXml(); + } + cursor.dispose(); } public void removeBuildOptionsUserDefAntTask(int i) { @@ -1160,6 +1841,10 @@ public class FpdFileContents { cursor.toNextSibling(); } cursor.removeXml(); + if (getBuildOptionsUserDefAntTaskCount() == 0) { + cursor.toParent(); + cursor.removeXml(); + } } cursor.dispose(); } @@ -1228,7 +1913,14 @@ public class FpdFileContents { opt.setTagName(tagName); opt.setToolCode(toolCmd); - opt.setSupArchList(archList); + if (archList != null) { + opt.setSupArchList(archList); + } + else { + if (opt.isSetSupArchList()) { + opt.unsetSupArchList(); + } + } } public void removeBuildOptionsOpt(int i){ @@ -1244,6 +1936,10 @@ public class FpdFileContents { cursor.toNextSibling(); } cursor.removeXml(); + if (getBuildOptionsOptCount() == 0) { + cursor.toParent(); + cursor.removeXml(); + } } cursor.dispose(); } @@ -1479,10 +2175,15 @@ public class FpdFileContents { cursor.toNextSibling(qSections); } if (cursor.toFirstChild()) { - for (int m = 0; m < k; ++m) { + int m = 0; + for (; m < k; ++m) { cursor.toNextSibling(); } cursor.removeXml(); + if (m == 0) { + cursor.toParent(); + cursor.removeXml(); + } } } cursor.dispose(); @@ -1652,7 +2353,16 @@ public class FpdFileContents { } public void setPlatformDefsSupportedArchs(Vector archs) { - getfpdPlatformDefs().setSupportedArchitectures(archs); + if (archs != null) { + getfpdPlatformDefs().setSupportedArchitectures(archs); + } +// else { +// XmlCursor cursor = getfpdPlatformDefs().newCursor(); +// if (cursor.toChild(xmlNs, "SupportedArchitectures")) { +// cursor.removeXml(); +// } +// cursor.dispose(); +// } } public void getPlatformDefsBuildTargets(Vector targets) { @@ -1697,6 +2407,10 @@ public class FpdFileContents { public void getPlatformDefsSkuInfos(String[][] saa){ if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) { + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; + } return ; } @@ -1761,7 +2475,16 @@ public class FpdFileContents { } public void setPlatformDefsOutputDir(String outputDir) { - getfpdPlatformDefs().setOutputDirectory(outputDir); + if (outputDir != null && outputDir.length() > 0) { + getfpdPlatformDefs().setOutputDirectory(outputDir); + } + else{ + XmlCursor cursor = getfpdPlatformDefs().newCursor(); + if (cursor.toChild(new QName(xmlNs, "OutputDirectory"))) { + cursor.removeXml(); + } + cursor.dispose(); + } } public FlashDocument.Flash getfpdFlash() { @@ -1789,8 +2512,6 @@ public class FpdFileContents { return fdf.getStringValue(); } - - public void genFvImagesNameValue(String name, String value) { FvImagesDocument.FvImages fi = getfpdFlash().getFvImages(); @@ -1869,6 +2590,43 @@ public class FpdFileContents { } } + public void getFvImagesFvImageFvImageNames (Vector vImageNames) { + FvImagesDocument.FvImages fis = getfpdFlash().getFvImages(); + if (fis == null || fis.getFvImageList() == null) { + return; + } + + ListIterator li = fis.getFvImageList().listIterator(); + while (li.hasNext()) { + FvImagesDocument.FvImages.FvImage fi = li.next(); + if (fi.getType().toString().equals("ImageName")) { + vImageNames.addAll(fi.getFvImageNamesList()); + return; + } + } + } + + public void AddFvImageFvImageNames (String[] fvNames) { + FvImagesDocument.FvImages fis = getfpdFlash().getFvImages(); + if (fis == null || fis.getFvImageList() == null) { + genFvImagesFvImage (fvNames, "ImageName", null); + return; + } + + ListIterator li = fis.getFvImageList().listIterator(); + 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]); + } + return; + } + } + genFvImagesFvImage (fvNames, "ImageName", null); + + } + public void genFvImagesFvImage(String[] names, String types, Map options) { FvImagesDocument.FvImages fis = null; @@ -1928,6 +2686,52 @@ public class FpdFileContents { cursor.dispose(); } + /** + * @param oldFvName + * @param newFvName The New FV Name. If null, remove the old FvImageNames entry. + */ + public void updateFvImageNameAll (String oldFvName, String newFvName) { + if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) { + return; + } + ListIterator li = getfpdFlash().getFvImages().getFvImageList().listIterator(); + while (li.hasNext()) { + FvImagesDocument.FvImages.FvImage fi = li.next(); + updateFvImageNamesInFvImage (fi, oldFvName, newFvName); + } + } + + /** + * @param fi + * @param oldFvName The FV Name to be replaced. + * @param newFvName The New FV Name. If null, remove the old FvImageNames entry. + */ + public void updateFvImageNamesInFvImage (FvImagesDocument.FvImages.FvImage fi, String oldFvName, String newFvName) { + QName qFvImageNames = new QName(xmlNs, "FvImageNames"); + XmlCursor cursor = fi.newCursor(); + + if (cursor.toChild(qFvImageNames)) { + do { + if (cursor.getTextValue().equals(oldFvName)){ + if (newFvName != null) { + cursor.setTextValue(newFvName); + } + else { + if (fi.getFvImageNamesList().size() == 1) { + removeElement(fi); + break; + } + else { + cursor.removeXml(); + } + } + } + }while (cursor.toNextSibling(qFvImageNames)); + } + + cursor.dispose(); + } + public void updateFvImagesFvImage(int i, String[] names, String types, Map options){ XmlObject o = getfpdFlash().getFvImages(); @@ -1968,18 +2772,50 @@ public class FpdFileContents { cursor.dispose(); } - public int getFvImagesFvImageCount() { + public int getFvImagesFvImageCount(String type) { if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) { return 0; } - return getfpdFlash().getFvImages().getFvImageList().size(); + List l = getfpdFlash().getFvImages().getFvImageList(); + ListIterator li = l.listIterator(); + int i = 0; + while(li.hasNext()) { + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next(); + if (!fi.getType().toString().equals(type) && !type.equals("ALL")) { + continue; + } + + ++i; + } + + return i; } - /**Only Get Fv image setting - name and type. + public Vector getFvImagesFvImageWithName (String fvName, String type) { + Vector vFvImage = new Vector(); + if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) { + return vFvImage; + } + List l = getfpdFlash().getFvImages().getFvImageList(); + ListIterator li = l.listIterator(); + while(li.hasNext()) { + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next(); + if (!fi.getType().toString().equals(type) && !type.equals("ALL")) { + continue; + } + if (fi.getFvImageNamesList().contains(fvName)) { + vFvImage.add(fi); + } + } + + return vFvImage; + } + /** * @param saa + * @param type "ALL" means all FvImage types: ImageName, Options, Attributes, Components. */ - public void getFvImagesFvImages(String[][] saa) { + public void getFvImagesFvImages(String[][] saa, String type) { if (getfpdFlash().getFvImages() == null) { return; @@ -1992,6 +2828,9 @@ public class FpdFileContents { int i = 0; while(li.hasNext()) { FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next(); + if (!fi.getType().toString().equals(type) && !type.equals("ALL")) { + continue; + } // // get FvImageNames array, space separated // @@ -2010,6 +2849,108 @@ public class FpdFileContents { } } + /**Add name-value pair to FvImage element with type. + * @param fvName FV name to add name-value pair. + * @param type FvImage attribute. + * @param name + * @param value + */ + public void setTypedNamedFvImageNameValue (String fvName, String type, String name, String value) { + if (getfpdFlash().getFvImages() == null) { + return; + } + List l = getfpdFlash().getFvImages().getFvImageList(); + if (l == null) { + return; + } + ListIterator li = l.listIterator(); + while(li.hasNext()) { + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next(); + if (!fi.getType().toString().equals(type) && !type.equals("ALL")) { + continue; + } + if (!fi.getFvImageNamesList().contains(fvName)) { + continue; + } + setFvImagesFvImageNameValue (fi, name, value, null); + } + } + + /**Add to all FvImage elements with type, the name-value pair. + * @param type + * @param name + * @param value + */ + public void setTypedFvImageNameValue (String type, String name, String value) { + if (getfpdFlash().getFvImages() == null) { + return; + } + List l = getfpdFlash().getFvImages().getFvImageList(); + if (l == null) { + return; + } + ListIterator li = l.listIterator(); + while(li.hasNext()) { + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next(); + if (!fi.getType().toString().equals(type) && !type.equals("ALL")) { + continue; + } + setFvImagesFvImageNameValue (fi, name, value, null); + } + } + + /**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 + * @param value + * @param newName + */ + public void setFvImagesFvImageNameValue (FvImagesDocument.FvImages.FvImage fi, String name, String value, String newName) { + if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null) { + return; + } + + XmlCursor cursor = fi.getFvImageOptions().newCursor(); + if (cursor.toFirstChild()) { + do { + FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue)cursor.getObject(); + if (nv.getName().equals(name)) { + nv.setValue(value); + if (newName != null) { + nv.setName(newName); + } + cursor.dispose(); + return; + } + }while (cursor.toNextSibling()); + } + + FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.getFvImageOptions().addNewNameValue(); + nv.setName(name); + nv.setValue(value); + if (newName != null) { + nv.setName(newName); + } + cursor.dispose(); + } + + public void getFvImagesFvImageOptions (String fvName, Map m) { + Vector vFvImage = getFvImagesFvImageWithName (fvName, "Options"); + for (int i = 0; i < vFvImage.size(); ++i) { + FvImagesDocument.FvImages.FvImage fi = vFvImage.get(i); + if (fi == null || fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null) { + continue; + } + + ListIterator li = fi.getFvImageOptions() + .getNameValueList() + .listIterator(); + while (li.hasNext()) { + FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next(); + m.put(nv.getName(), nv.getValue()); + } + } + } /**Get FvImage Options for FvImage i * @param i the ith FvImage */ @@ -2044,7 +2985,7 @@ public class FpdFileContents { if (fpdHdr == null) { fpdHdr = fpdRoot.addNewPlatformHeader(); } - genPlatformDefsSkuInfo("0", "DEFAULT"); + return fpdHdr; } @@ -2090,7 +3031,7 @@ public class FpdFileContents { public String getFpdHdrSpec() { - return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; + return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; // return getFpdHdr().getSpecification(); } @@ -2136,7 +3077,7 @@ public class FpdFileContents { } public void setFpdHdrSpec(String s){ - s = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; + s = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; getFpdHdr().setSpecification(s); } /** @@ -2172,4 +3113,62 @@ public class FpdFileContents { } return s.trim(); } + + private void removeElement(XmlObject o) { + XmlCursor cursor = o.newCursor(); + cursor.removeXml(); + cursor.dispose(); + } +} + +class PcdItemTypeConflictException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String details = null; + + PcdItemTypeConflictException(String pcdName, String info){ + ModuleIdentification mi = WorkspaceProfile.getModuleId(info); + details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackageId().getName(); + } + + public String getMessage() { + return details; + } +} + +class PcdDeclNotFound extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String details = null; + + PcdDeclNotFound(String info) { + details = "PcdDeclNotFound: " + info; + } + + public String getMessage() { + return details; + } +} + +class PcdValueMalFormed extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String details = null; + + PcdValueMalFormed(String info) { + details = "PcdValueMalFormed: " + info; + } + + public String getMessage() { + return details; + } }