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=6e7c79f6582976223cc09d38f89c805a23833b0a;hb=a390c35d8a99be7adcc551ce541b5a6ce3f5fd2a;hpb=8f55ea7396747725b18b8090f9d3fc5c22d1c53f 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 6e7c79f658..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 @@ -96,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(); @@ -180,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(); @@ -219,13 +223,15 @@ public class FpdFileContents { 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; @@ -250,7 +256,10 @@ public class FpdFileContents { private ModuleSADocument.ModuleSA getModuleSA(int i) { ModuleSADocument.ModuleSA msa = null; - XmlCursor cursor = getfpdFrameworkModules().newCursor(); + if (fpdRoot.getFrameworkModules() == null) { + return null; + } + XmlCursor cursor = fpdRoot.getFrameworkModules().newCursor(); if (cursor.toFirstChild()) { for (int j = 0; j < i; ++j) { cursor.toNextSibling(); @@ -262,7 +271,7 @@ public class FpdFileContents { } public void removeModuleSA(int i) { - XmlObject o = getfpdFrameworkModules(); + XmlObject o = fpdRoot.getFrameworkModules(); if (o == null) { return; } @@ -286,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(); @@ -424,7 +440,7 @@ public class FpdFileContents { } catch (Exception e){ -// e.printStackTrace(); + e.printStackTrace(); throw e; } @@ -448,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(); } } @@ -513,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(); @@ -529,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); @@ -610,7 +661,7 @@ public class FpdFileContents { 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 ; } @@ -640,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; } @@ -725,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 @@ -737,7 +788,7 @@ public class FpdFileContents { } catch (Exception e){ -// e.printStackTrace(); + throw e; } @@ -776,6 +827,18 @@ public class FpdFileContents { 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()); @@ -810,16 +873,17 @@ public class FpdFileContents { // // 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); } } } @@ -828,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); @@ -843,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); // @@ -854,6 +953,7 @@ public class FpdFileContents { } } else { + /* if (defaultVal != null){ fpdPcd.setValue(defaultVal); } @@ -868,6 +968,7 @@ public class FpdFileContents { fpdPcd.setValue(""); } } + if (dataType.equals("UINT8")){ fpdPcd.setMaxDatumSize(1); } @@ -887,6 +988,7 @@ public class FpdFileContents { int maxSize = setMaxSizeForPointer(fpdPcd.getValue()); fpdPcd.setMaxDatumSize(maxSize); } + */ } } @@ -967,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(); @@ -1053,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()) { @@ -1078,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; } @@ -1102,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; } @@ -1139,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; } @@ -1162,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; } @@ -1184,6 +1300,8 @@ public class FpdFileContents { public void removeDynamicPcdBuildDataSkuInfo(int i) { if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; return; } @@ -1210,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()) { @@ -1239,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()) { @@ -1883,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 ; } @@ -2237,7 +2359,7 @@ public class FpdFileContents { if (fpdHdr == null) { fpdHdr = fpdRoot.addNewPlatformHeader(); } - genPlatformDefsSkuInfo("0", "DEFAULT"); + return fpdHdr; } @@ -2365,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 { @@ -2375,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() { @@ -2393,7 +2522,7 @@ class PcdDeclNotFound extends Exception { private String details = null; PcdDeclNotFound(String info) { - details = info; + details = "PcdDeclNotFound: " + info; } public String getMessage() { @@ -2410,7 +2539,7 @@ class PcdValueMalFormed extends Exception { private String details = null; PcdValueMalFormed(String info) { - details = info; + details = "PcdValueMalFormed: " + info; } public String getMessage() {