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=d942addf50adb966217dd3d720eacee22bc62e58;hp=4783a74a25185aa5eafa337059f49f3b4e669b48;hb=a390c35d8a99be7adcc551ce541b5a6ce3f5fd2a;hpb=055e7ae674d038d79c2eb2b36bef44d37ed5c4c9 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 4783a74a25..d942addf50 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; @@ -95,6 +96,8 @@ public class FpdFileContents { dynPcdMap = new HashMap>(); List l = getfpdFrameworkModules().getModuleSAList(); if (l == null) { + removeElement(getfpdFrameworkModules()); + fpdFrameworkModules = null; return; } ListIterator li = l.listIterator(); @@ -104,7 +107,7 @@ public class FpdFileContents { continue; } String ModuleInfo = msa.getModuleGuid() + " " + msa.getModuleVersion() + - " " + msa.getPackageGuid() + " " + msa.getPackageVersion(); + " " + msa.getPackageGuid() + " " + msa.getPackageVersion() + " " + listToString(msa.getSupArchList()); List lp = msa.getPcdBuildDefinition().getPcdDataList(); ListIterator lpi = lp.listIterator(); while (lpi.hasNext()) { @@ -179,7 +182,9 @@ public class FpdFileContents { } 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(); @@ -194,25 +199,39 @@ public class FpdFileContents { int i = 0; while(li.hasNext()) { ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next(); - saa[i][1] = msa.getModuleGuid(); - saa[i][2] = msa.getModuleVersion(); + saa[i][0] = msa.getModuleGuid(); + saa[i][1] = msa.getModuleVersion(); - saa[i][3] = msa.getPackageGuid(); - saa[i][4] = msa.getPackageVersion(); -// saa[i][4] = listToString(msa.getSupArchList()); + saa[i][2] = msa.getPackageGuid(); + saa[i][3] = msa.getPackageVersion(); + saa[i][4] = listToString(msa.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.getModuleGuid().equalsIgnoreCase(s[0]) && msa.getPackageGuid().equalsIgnoreCase(s[2])) { if (msa.getModuleVersion() != null) { if (!msa.getModuleVersion().equals(s[1])) { continue; @@ -223,13 +242,36 @@ public class FpdFileContents { continue; } } + //ToDo add arch check for s[4] + if (msa.getSupArchList() != null) { + if (!listToString(msa.getSupArchList()).equals(s[4])) { + continue; + } + } return msa; } } return null; } + + private ModuleSADocument.ModuleSA getModuleSA(int i) { + ModuleSADocument.ModuleSA msa = null; + if (fpdRoot.getFrameworkModules() == null) { + return null; + } + XmlCursor cursor = fpdRoot.getFrameworkModules().newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + msa = (ModuleSADocument.ModuleSA)cursor.getObject(); + } + cursor.dispose(); + return msa; + } + public void removeModuleSA(int i) { - XmlObject o = getfpdFrameworkModules(); + XmlObject o = fpdRoot.getFrameworkModules(); if (o == null) { return; } @@ -244,7 +286,7 @@ 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 && pcdBuildDef.getPcdDataList() != null) { ListIterator li = pcdBuildDef.getPcdDataList().listIterator(); @@ -253,6 +295,13 @@ public class FpdFileContents { maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), moduleInfo); } } + + cursor.push(); + cursor.toPrevToken(); + if (cursor.isComment()) { + cursor.removeXml(); + } + cursor.pop(); cursor.removeXml(); if (getFrameworkModulesCount() == 0) { cursor.toParent(); @@ -272,6 +321,10 @@ public class FpdFileContents { for(int i = 0; i < al.size(); ++i){ 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; } @@ -285,22 +338,10 @@ public class FpdFileContents { } // - // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer" + // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch" // public int getPcdDataCount(int i){ - if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) { - return 0; - } - - XmlCursor cursor = getfpdFrameworkModules().newCursor(); - ModuleSADocument.ModuleSA msa = null; - if (cursor.toFirstChild()) { - for (int j = 0; j < i; ++j) { - cursor.toNextSibling(); - } - msa = (ModuleSADocument.ModuleSA)cursor.getObject(); - } - cursor.dispose(); + ModuleSADocument.ModuleSA msa = getModuleSA(i); if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){ return 0; @@ -310,19 +351,7 @@ public class FpdFileContents { } public void getPcdData(int i, String[][] saa) { - if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) { - return; - } - - XmlCursor cursor = getfpdFrameworkModules().newCursor(); - ModuleSADocument.ModuleSA msa = null; - if (cursor.toFirstChild()) { - for (int j = 0; j < i; ++j) { - cursor.toNextSibling(); - } - msa = (ModuleSADocument.ModuleSA)cursor.getObject(); - } - cursor.dispose(); + ModuleSADocument.ModuleSA msa = getModuleSA(i); if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){ return; @@ -411,7 +440,7 @@ public class FpdFileContents { } catch (Exception e){ -// e.printStackTrace(); + e.printStackTrace(); throw e; } @@ -435,25 +464,31 @@ public class FpdFileContents { while(li.hasNext()) { PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next(); ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey); - XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor(); - if (cursor.toFirstChild()) { - 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()) { - pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject(); - if (msaPcd.getCName().equals(pcdData.getCName()) && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) { - maintainDynPcdMap(pcdData.getCName()+" "+pcdData.getTokenSpaceGuidCName(), moduleKey); + if (moduleSA.getPcdBuildDefinition() != null) { + XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor(); + if (cursor.toFirstChild()) { + 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()) { + 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; + } + } } + cursor.dispose(); } - cursor.dispose(); } } @@ -463,7 +498,7 @@ public class FpdFileContents { } } // - // 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); @@ -500,13 +535,23 @@ public class FpdFileContents { 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(); @@ -516,7 +561,26 @@ public class FpdFileContents { libs = msa.addNewLibraries(); } + String mn = libMi.getName(); + String mg = libMi.getGuid(); + String mv = libMi.getVersion(); + String pn = libMi.getPackage().getName(); + String pg = libMi.getPackage().getGuid(); + String pv = libMi.getPackage().getVersion(); LibrariesDocument.Libraries.Instance instance = libs.addNewInstance(); + XmlCursor cursor = instance.newCursor(); + try{ + String comment = "Pkg: " + pn + " Mod: " + mn + + " Path: " + GlobalData.getMsaFile(libMi).getPath(); + cursor.insertComment(comment); + } + catch (Exception e){ + e.printStackTrace(); + } + finally { + cursor.dispose(); + } + instance.setModuleGuid(mg); instance.setModuleVersion(mv); instance.setPackageGuid(pg); @@ -558,10 +622,21 @@ public class FpdFileContents { return; } if(msa.getModuleSaBuildOptions() == null){ - msa.addNewModuleSaBuildOptions().setFfsFileNameGuid(fileGuid); - return; + msa.addNewModuleSaBuildOptions(); + + } + ModuleSaBuildOptionsDocument.ModuleSaBuildOptions msaBuildOpts= msa.getModuleSaBuildOptions(); + if (fileGuid != null) { + msaBuildOpts.setFfsFileNameGuid(fileGuid); } - msa.getModuleSaBuildOptions().setFfsFileNameGuid(fileGuid); + else{ + XmlCursor cursor = msaBuildOpts.newCursor(); + if (cursor.toChild(xmlNs, "FfsFileNameGuid")) { + cursor.removeXml(); + } + cursor.dispose(); + } + } public String getFfsFormatKey(String moduleKey){ @@ -581,12 +656,12 @@ public class FpdFileContents { msa.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey); return; } - msa.getModuleSaBuildOptions().setFvBinding(ffsKey); + msa.getModuleSaBuildOptions().setFfsFormatKey(ffsKey); } 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 ; } @@ -600,12 +675,14 @@ 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(); + saa[i][5] = opt.getStringValue(); ++i; @@ -614,7 +691,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; } @@ -670,12 +747,12 @@ public class FpdFileContents { * @param mi * @param moduleSa if null, generate a new ModuleSA. */ - public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, ModuleSADocument.ModuleSA moduleSa) throws Exception { + public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, String arch, ModuleSADocument.ModuleSA moduleSa) throws Exception { //ToDo add Arch filter try { if (moduleSa == null) { - moduleSa = genModuleSA(mi); + moduleSa = genModuleSA(mi, arch); } ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi); @@ -699,7 +776,7 @@ public class FpdFileContents { // // ToDo Error // - throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName()); + throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module " + mi.getName()); } // // AddItem to ModuleSA PcdBuildDefinitions @@ -711,7 +788,7 @@ public class FpdFileContents { } catch (Exception e){ -// e.printStackTrace(); + throw e; } @@ -747,13 +824,30 @@ public class FpdFileContents { return null; } - private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi) { + private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi, String arch) { PackageIdentification pi = GlobalData.getPackageForModule(mi); ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA(); + XmlCursor cursor = msa.newCursor(); + try{ + String comment = "Mod: " + mi.getName() + " Type: " + mi.getModuleType() + " Path: " + + GlobalData.getMsaFile(mi).getPath(); + 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; } @@ -772,23 +866,24 @@ public class FpdFileContents { pcdConsumer = new ArrayList(); } 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 // + /* Comment out Item type checking temporarily. 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")) { + if (!valuePart[5].equals("DYNAMIC")) { //ToDo error for same pcd, other type than dynamic pcdConsumer.remove(listValue); - throw new PcdItemTypeConflictException(value); + throw new PcdItemTypeConflictException(cName, value); } } } @@ -797,14 +892,14 @@ public class FpdFileContents { while(li.hasNext()) { String value = li.next().toString(); String[] valuePart= value.split(" "); - if (valuePart[4].equals("DYNAMIC")) { + if (valuePart[5].equals("DYNAMIC")) { //ToDo error for same pcd, other type than non-dynamic pcdConsumer.remove(listValue); - throw new PcdItemTypeConflictException(value); + throw new PcdItemTypeConflictException(cName, value); } } } - + */ PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData(); fpdPcd.setCName(cName); fpdPcd.setToken(token); @@ -812,6 +907,41 @@ 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(""); + } + } + 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); // @@ -823,6 +953,7 @@ public class FpdFileContents { } } else { + /* if (defaultVal != null){ fpdPcd.setValue(defaultVal); } @@ -837,6 +968,7 @@ public class FpdFileContents { fpdPcd.setValue(""); } } + if (dataType.equals("UINT8")){ fpdPcd.setMaxDatumSize(1); } @@ -856,6 +988,7 @@ public class FpdFileContents { int maxSize = setMaxSizeForPointer(fpdPcd.getValue()); fpdPcd.setMaxDatumSize(maxSize); } + */ } } @@ -936,18 +1069,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(); @@ -1022,7 +1159,10 @@ public class FpdFileContents { } public void removeDynamicPcdBuildData(String cName, String tsGuid) { - XmlObject o = getfpdDynPcdBuildDefs(); + XmlObject o = fpdRoot.getDynamicPcdBuildDefinitions(); + if (o == null) { + return; + } XmlCursor cursor = o.newCursor(); if (cursor.toFirstChild()) { @@ -1047,7 +1187,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; } @@ -1071,6 +1212,8 @@ public class FpdFileContents { public void getDynamicPcdSkuInfos(int i, String[][] saa){ if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; return; } @@ -1108,6 +1251,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; } @@ -1131,6 +1276,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; } @@ -1153,6 +1300,8 @@ public class FpdFileContents { public void removeDynamicPcdBuildDataSkuInfo(int i) { if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; return; } @@ -1179,9 +1328,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()) { @@ -1208,9 +1357,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()) { @@ -1259,12 +1408,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) { @@ -1350,7 +1507,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){ @@ -1783,7 +1947,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) { @@ -1828,6 +2001,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 ; } @@ -2182,7 +2359,7 @@ public class FpdFileContents { if (fpdHdr == null) { fpdHdr = fpdRoot.addNewPlatformHeader(); } - genPlatformDefsSkuInfo("0", "DEFAULT"); + return fpdHdr; } @@ -2310,6 +2487,12 @@ public class FpdFileContents { } return s.trim(); } + + private void removeElement(XmlObject o) { + XmlCursor cursor = o.newCursor(); + cursor.removeXml(); + cursor.dispose(); + } } class PcdItemTypeConflictException extends Exception { @@ -2320,8 +2503,9 @@ class PcdItemTypeConflictException extends Exception { private static final long serialVersionUID = 1L; private String details = null; - PcdItemTypeConflictException(String info){ - details = info; + PcdItemTypeConflictException(String pcdName, String info){ + ModuleIdentification mi = GlobalData.getModuleId(info); + details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackage().getName(); } public String getMessage() { @@ -2338,7 +2522,7 @@ class PcdDeclNotFound extends Exception { private String details = null; PcdDeclNotFound(String info) { - details = info; + details = "PcdDeclNotFound: " + info; } public String getMessage() { @@ -2355,7 +2539,7 @@ class PcdValueMalFormed extends Exception { private String details = null; PcdValueMalFormed(String info) { - details = info; + details = "PcdValueMalFormed: " + info; } public String getMessage() {