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=e60426446fbe826b66cf251432da64e9b5db78e4;hp=f730fa2a6ee22cee410c272c63b5138f80e91df3;hb=61919f8cfa2cdd6a965928933844a91d7aa69626;hpb=5af6b67fdb381cd8e5193d9c66bba9108ea088ee 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 f730fa2a6e..e60426446f 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 @@ -57,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. @@ -88,6 +89,8 @@ public class FpdFileContents { private HashMap> dynPcdMap = null; + private HashMap defaultPcdValue = new HashMap(); + /** * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings. */ @@ -102,13 +105,13 @@ public class FpdFileContents { } 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() + " " + listToString(msa.getSupArchList()); - 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(); @@ -181,6 +184,32 @@ 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 || getfpdFrameworkModules().getModuleSAList().size() == 0){ removeElement(getfpdFrameworkModules()); @@ -198,13 +227,13 @@ public class FpdFileContents { ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator(); int i = 0; while(li.hasNext()) { - ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next(); - saa[i][0] = msa.getModuleGuid(); - saa[i][1] = msa.getModuleVersion(); + ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next(); + saa[i][0] = moduleSa.getModuleGuid(); + saa[i][1] = moduleSa.getModuleVersion(); - saa[i][2] = msa.getPackageGuid(); - saa[i][3] = 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; } } @@ -230,32 +259,32 @@ public class FpdFileContents { } 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; } } - if (msa.getPackageVersion() != null) { - if (!msa.getPackageVersion().equals(s[3])) { + if (moduleSa.getPackageVersion() != null) { + if (!moduleSa.getPackageVersion().equals(s[3])) { continue; } } //ToDo add arch check for s[4] - if (msa.getSupArchList() != null) { - if (!listToString(msa.getSupArchList()).equals(s[4])) { + if (moduleSa.getSupArchList() != null) { + if (!listToString(moduleSa.getSupArchList()).equals(s[4])) { continue; } } - return msa; + return moduleSa; } } return null; } private ModuleSADocument.ModuleSA getModuleSA(int i) { - ModuleSADocument.ModuleSA msa = null; + ModuleSADocument.ModuleSA moduleSa = null; if (fpdRoot.getFrameworkModules() == null) { return null; } @@ -264,10 +293,10 @@ public class FpdFileContents { for (int j = 0; j < i; ++j) { cursor.toNextSibling(); } - msa = (ModuleSADocument.ModuleSA)cursor.getObject(); + moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject(); } cursor.dispose(); - return msa; + return moduleSa; } public void removeModuleSA(int i) { @@ -311,6 +340,103 @@ public class FpdFileContents { cursor.dispose(); } + 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) { + + } + // + // add new Pcd from MSA file to ModuleSA. + // + 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); @@ -331,6 +457,7 @@ public class FpdFileContents { } if (al.size() == 0) { + defaultPcdValue.remove(pcdKey); dynPcdMap.remove(pcdKey); String[] s1 = pcdKey.split(" "); removeDynamicPcdBuildData(s1[0], s1[1]); @@ -340,7 +467,7 @@ public class FpdFileContents { // // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch" // - public int getPcdDataCount(int i){ + public int getPcdDataCount (int i){ ModuleSADocument.ModuleSA msa = getModuleSA(i); if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){ @@ -350,7 +477,7 @@ public class FpdFileContents { } - public void getPcdData(int i, String[][] saa) { + public void getPcdData (int i, String[][] saa) { ModuleSADocument.ModuleSA msa = getModuleSA(i); if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){ @@ -370,13 +497,46 @@ public class FpdFileContents { } } - public void updatePcdData(String key, String cName, String tsGuid, String itemType, String maxSize, String value){ - ModuleSADocument.ModuleSA msa = getModuleSA(key); - if (msa == null || msa.getPcdBuildDefinition() == null){ + 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()); + + } + 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; } - XmlCursor cursor = msa.getPcdBuildDefinition().newCursor(); + XmlCursor cursor = moduleSa.getPcdBuildDefinition().newCursor(); if (cursor.toFirstChild()){ do { PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject(); @@ -386,6 +546,7 @@ public class FpdFileContents { pcdData.setMaxDatumSize(new Integer(maxSize)); } pcdData.setValue(value); + defaultPcdValue.put(cName + " " + tsGuid, value); break; } } @@ -400,10 +561,10 @@ public class FpdFileContents { * @param sa Results: HelpText, Original item type. * @return */ - public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String[] sa) throws Exception{ + public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String tsGuid, String[] sa) throws Exception{ try { - ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi); + ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi); if (msa.getPcdCoded() == null) { return false; } @@ -411,7 +572,7 @@ public class FpdFileContents { Map m = new HashMap(); m.put("ModuleSurfaceArea", msa); SurfaceAreaQuery.setDoc(m); - PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null); + PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi); // // First look through MSA pcd entries. // @@ -422,6 +583,9 @@ public class FpdFileContents { if (!msaPcd.getCName().equals(cName)) { continue; } + if (!msaPcd.getTokenSpaceGuidCName().equals(tsGuid)) { + continue; + } PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs); if (spdPcd == null) { // @@ -453,7 +617,7 @@ public class FpdFileContents { */ public void removePcdData(String moduleKey, ModuleIdentification consumer) { try { - ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(consumer); + ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(consumer); if (msa.getPcdCoded() == null) { return; } @@ -564,14 +728,14 @@ public class FpdFileContents { 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(); + 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: " + GlobalData.getMsaFile(libMi).getPath(); + + " Path: " + libMi.getPath().substring(System.getenv("WORKSPACE").length() + 1); cursor.insertComment(comment); } catch (Exception e){ @@ -601,11 +765,18 @@ public class FpdFileContents { if (msa == null ) { return; } - if(msa.getModuleSaBuildOptions() == null){ - msa.addNewModuleSaBuildOptions().setFvBinding(fvBinding); - return; + if (fvBinding == null || fvBinding.length() == 0) { + if(msa.getModuleSaBuildOptions() != null){ + msa.getModuleSaBuildOptions().unsetFvBinding(); + } + } + else { + if(msa.getModuleSaBuildOptions() == null){ + msa.addNewModuleSaBuildOptions().setFvBinding(fvBinding); + return; + } + msa.getModuleSaBuildOptions().setFvBinding(fvBinding); } - msa.getModuleSaBuildOptions().setFvBinding(fvBinding); } public String getFfsFileNameGuid(String moduleKey){ @@ -659,6 +830,19 @@ public class FpdFileContents { 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 == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null @@ -755,7 +939,7 @@ public class FpdFileContents { moduleSa = genModuleSA(mi, arch); } - ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi); + ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi); if (msa.getPcdCoded() == null) { return; } @@ -763,7 +947,7 @@ public class FpdFileContents { Map m = new HashMap(); m.put("ModuleSurfaceArea", msa); SurfaceAreaQuery.setDoc(m); - PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null); + PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi); // // Implementing InitializePlatformPcdBuildDefinitions // @@ -776,7 +960,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 @@ -788,7 +972,7 @@ public class FpdFileContents { } catch (Exception e){ - e.printStackTrace(); + throw e; } @@ -796,12 +980,10 @@ public class FpdFileContents { 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; } @@ -825,12 +1007,12 @@ public class FpdFileContents { } private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi, String arch) { - PackageIdentification pi = GlobalData.getPackageForModule(mi); + PackageIdentification pi = WorkspaceProfile.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(); + String comment = "Mod: " + mi.getName() + " Type: " + SurfaceAreaQuery.getModuleType(mi) + " Path: " + + mi.getPath().substring(System.getenv("WORKSPACE").length() + 1); cursor.insertComment(comment); } catch(Exception e){ @@ -865,39 +1047,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() + " " + 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); - throw new PcdItemTypeConflictException(value); - } - } - } - 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); - throw new PcdItemTypeConflictException(value); - } - } - } PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData(); fpdPcd.setCName(cName); @@ -906,6 +1067,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); // @@ -916,41 +1122,7 @@ 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); - } - } + } public int setMaxSizeForPointer(String datum) throws PcdValueMalFormed{ @@ -1004,7 +1176,7 @@ 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); } } @@ -1030,7 +1202,7 @@ public class FpdFileContents { private ArrayList LookupPlatformPcdData(String pcdKey) { - return dynPcdMap.get("pcdKey"); + return dynPcdMap.get(pcdKey); } public int getDynamicPcdBuildDataCount() { @@ -1131,11 +1303,11 @@ public class FpdFileContents { DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); if (pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid)) { - cursor.removeXml(); - if (getDynamicPcdBuildDataCount() == 0) { + + if (getDynamicPcdBuildDataCount() == 1) { cursor.toParent(); - cursor.removeXml(); } + cursor.removeXml(); cursor.dispose(); return; } @@ -1357,6 +1529,118 @@ public class FpdFileContents { return fpdBuildOpts; } + public void genBuildOptionsUserExtensions(String fvName, String outputFileName, String[][] includeModules) { + UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions(); + userExts.setUserID("IMAGES"); + userExts.setIdentifier(new BigInteger("1")); + XmlCursor cursor = userExts.newCursor(); + cursor.toEndToken(); + + cursor.beginElement("FvName"); + cursor.insertChars(fvName); + cursor.toNextToken(); + + cursor.beginElement("InfFileName"); + cursor.insertChars(fvName + ".inf"); + cursor.toNextToken(); + + cursor.beginElement("IncludeModules"); + for (int i = 0; i < includeModules.length; ++i) { + cursor.beginElement("Module"); + cursor.insertAttributeWithValue("ModuleGuid", includeModules[i][0]); + cursor.insertAttributeWithValue("BaseName", includeModules[i][1]); + cursor.toEndToken(); + cursor.toNextToken(); + } + cursor.dispose(); + } + + public int getUserExtsIncModCount (String fvName) { + if (getfpdBuildOpts().getUserExtensionsList() == null) { + return -1; + } + 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.toNextSibling(new QName("", "IncludeModules")); + 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; + } + 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.toNextSibling(new QName("", "IncludeModules")); + if (cursor.toFirstChild()) { + int i = 0; + do { + saa[i][0] = cursor.getAttributeText(new QName("ModuleGuid")); + saa[i][1] = cursor.getAttributeText(new QName("BaseName")); + ++i; + }while (cursor.toNextSibling()); + } + cursor.dispose(); + return; + } + 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) { @@ -2320,7 +2604,7 @@ public class FpdFileContents { if (fpdHdr == null) { fpdHdr = fpdRoot.addNewPlatformHeader(); } - genPlatformDefsSkuInfo("0", "DEFAULT"); + return fpdHdr; } @@ -2464,8 +2748,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 = WorkspaceProfile.getModuleId(info); + details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackageId().getName(); } public String getMessage() { @@ -2482,7 +2767,7 @@ class PcdDeclNotFound extends Exception { private String details = null; PcdDeclNotFound(String info) { - details = info; + details = "PcdDeclNotFound: " + info; } public String getMessage() { @@ -2499,7 +2784,7 @@ class PcdValueMalFormed extends Exception { private String details = null; PcdValueMalFormed(String info) { - details = info; + details = "PcdValueMalFormed: " + info; } public String getMessage() {