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=b8c80b48cc2f5264d6b8f354beedc5040bc4dc29;hp=449578006e1d7b43af7429ab1a987d86b842185f;hb=1faac7b69fbddc4b1af451f51465988d8e1988c7;hpb=202c4f38c598bc91f678ba90f4e9f3142d02142b 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 449578006e..b8c80b48cc 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 @@ -23,6 +23,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Set; +import java.util.Vector; import javax.xml.namespace.QName; @@ -32,13 +33,14 @@ import org.apache.xmlbeans.XmlOptions; import org.tianocore.AntTaskDocument; import org.tianocore.BuildOptionsDocument; import org.tianocore.DynamicPcdBuildDefinitionsDocument; +import org.tianocore.EfiSectionType; import org.tianocore.FlashDefinitionFileDocument; -import org.tianocore.FlashDeviceDefinitionsDocument; import org.tianocore.FlashDocument; import org.tianocore.FrameworkModulesDocument; -import org.tianocore.FvRegionNameDocument; +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; @@ -84,7 +86,7 @@ public class FpdFileContents { private DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs = null; - public static HashMap> dynPcdMap = null; + private HashMap> dynPcdMap = null; /** * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings. @@ -94,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(); @@ -103,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()) { @@ -121,6 +125,10 @@ public class FpdFileContents { } } } + + public ArrayList getDynPcdMapValue(String key) { + return dynPcdMap.get(key); + } /** Constructor to create a new spd file **/ @@ -173,31 +181,10 @@ public class FpdFileContents { return fpdFrameworkModules; } - public int getPlatformDefsSkuInfoCount(){ - if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) { - return 0; - } - return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size(); - } - - public void getPlatformDefsSkuInfos(String[][] saa){ - if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) { - return ; - } - - List l = getfpdPlatformDefs().getSkuInfo().getUiSkuNameList(); - ListIterator li = l.listIterator(); - int i = 0; - while(li.hasNext()) { - SkuInfoDocument.SkuInfo.UiSkuName sku = li.next(); - saa[i][0] = sku.getSkuID()+""; - saa[i][1] = sku.getStringValue(); - ++i; - } - } - 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(); @@ -212,34 +199,79 @@ 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.getModuleVersion().equals(s[1]) - && msa.getPackageGuid().equals(s[2]) && msa.getPackageVersion().equals(s[3])) { - + if (msa.getModuleGuid().equalsIgnoreCase(s[0]) && msa.getPackageGuid().equalsIgnoreCase(s[2])) { + if (msa.getModuleVersion() != null) { + if (!msa.getModuleVersion().equals(s[1])) { + continue; + } + } + if (msa.getPackageVersion() != null) { + if (!msa.getPackageVersion().equals(s[3])) { + 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; } @@ -254,112 +286,219 @@ 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()){ + private void maintainDynPcdMap(String pcdKey, String moduleInfo) { + + ArrayList al = dynPcdMap.get(pcdKey); + if (al == null) { return; } - // - // deal with first child, same process in the while loop below for siblings. - // - PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject(); - String pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(); - ArrayList al = dynPcdMap.get(pcdKey); + 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) { dynPcdMap.remove(pcdKey); + String[] s1 = pcdKey.split(" "); + removeDynamicPcdBuildData(s1[0], s1[1]); } - if (pcdData.getItemType().toString().equals("DYNAMIC")) { - if (dynPcdMap.get(pcdKey) == null) { - removeDynamicPcdBuildData(pcdData.getCName(), pcdData.getTokenSpaceGuidCName()); - } + } + // + // 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; } - if (fromLibInstance){ - cursor.removeXml(); + return msa.getPcdBuildDefinition().getPcdDataList().size(); + + } + + public void getPcdData(int i, String[][] saa) { + ModuleSADocument.ModuleSA msa = getModuleSA(i); + + if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == 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; + 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 updatePcdData(String key, String cName, String tsGuid, String itemType, String maxSize, String value){ + ModuleSADocument.ModuleSA msa = getModuleSA(key); + if (msa == null || msa.getPcdBuildDefinition() == null){ + return; + } + + XmlCursor cursor = msa.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); 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[] sa) throws Exception{ + try { + + ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.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); + // + // 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; + } + 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)GlobalData.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()) { + 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(); + } + } + } - 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); @@ -385,18 +524,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(); @@ -406,102 +561,299 @@ 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); instance.setPackageVersion(pv); } - /**add pcd information of module mi to a ModuleSA. - * @param mi - * @param moduleSa if null, generate a new ModuleSA. - */ - public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, ModuleSADocument.ModuleSA moduleSa){ - //ToDo add Arch filter - - try { - ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.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); - // - // Implementing InitializePlatformPcdBuildDefinitions - // - List l = msa.getPcdCoded().getPcdEntryList(); - ListIterator li = l.listIterator(); - while(li.hasNext()) { - PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next(); - PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs); - if (spdPcd == null) { - // - // ToDo Error - // - break; - } - // - // 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); - } - + + public String getFvBinding(String moduleKey){ + ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); + if (msa == null || msa.getModuleSaBuildOptions() == null) { + return null; } - catch (Exception e){ - e.printStackTrace(); + return msa.getModuleSaBuildOptions().getFvBinding(); + } + + public void setFvBinding(String moduleKey, String fvBinding){ + ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); + if (msa == null ) { + return; } - + if(msa.getModuleSaBuildOptions() == null){ + msa.addNewModuleSaBuildOptions().setFvBinding(fvBinding); + return; + } + msa.getModuleSaBuildOptions().setFvBinding(fvBinding); } - 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(); - if (xo == null) { - continue; - } - for (int j = 0; j < xo.length; ++j) { - spdPcd = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)xo[j]; - if (msaPcd.getTokenSpaceGuidCName() == null) { - if (spdPcd.getCName().equals(msaPcd.getCName())) { - return spdPcd; - } - } - else{ - if (spdPcd.getCName().equals(msaPcd.getCName()) && spdPcd.getTokenSpaceGuidCName().equals(msaPcd.getTokenSpaceGuidCName())) { - return spdPcd; - } - } - - } - + public String getFfsFileNameGuid(String moduleKey){ + ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); + if (msa == null || msa.getModuleSaBuildOptions() == null) { + return null; } - return null; + return msa.getModuleSaBuildOptions().getFfsFileNameGuid(); } - private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi) { - PackageIdentification pi = GlobalData.getPackageForModule(mi); - ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA(); - msa.setModuleGuid(mi.getGuid()); - msa.setModuleVersion(mi.getVersion()); - msa.setPackageGuid(pi.getGuid()); - msa.setPackageVersion(pi.getVersion()); - + public void setFfsFileNameGuid(String moduleKey, String fileGuid){ + ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); + if (msa == null ) { + return; + } + if(msa.getModuleSaBuildOptions() == null){ + msa.addNewModuleSaBuildOptions(); + + } + 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){ + ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); + if (msa == null || msa.getModuleSaBuildOptions() == null) { + return null; + } + return msa.getModuleSaBuildOptions().getFfsFormatKey(); + } + + public void setFfsFormatKey(String moduleKey, String ffsKey){ + ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); + if (msa == null ) { + return; + } + if(msa.getModuleSaBuildOptions() == null){ + msa.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey); + return; + } + msa.getModuleSaBuildOptions().setFfsFormatKey(ffsKey); + } + + public void getModuleSAOptions(String moduleKey, String[][] saa) { + ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); + if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null + || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) { + return ; + } + + List lOpt = msa.getModuleSaBuildOptions().getOptions().getOptionList(); + ListIterator li = lOpt.listIterator(); + int i = 0; + while(li.hasNext()) { + OptionDocument.Option opt = (OptionDocument.Option)li.next(); + if (opt.getBuildTargets() != null) { + 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][4] = listToString(opt.getSupArchList()); + + } + + saa[i][5] = opt.getStringValue(); + + ++i; + } + } + + public int getModuleSAOptionsCount(String moduleKey){ + ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); + if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null + || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) { + return 0; + } + return msa.getModuleSaBuildOptions().getOptions().getOptionList().size(); + } + + public void genModuleSAOptionsOpt(String moduleKey, Vector buildTargets, String toolChain, String tagName, String toolCmd, Vector archList, String contents) { + ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); + if (msa.getModuleSaBuildOptions() == null) { + msa.addNewModuleSaBuildOptions(); + } + if (msa.getModuleSaBuildOptions().getOptions() == null){ + msa.getModuleSaBuildOptions().addNewOptions(); + } + OptionDocument.Option opt = msa.getModuleSaBuildOptions().getOptions().addNewOption(); + setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt); + } + + public void removeModuleSAOptionsOpt(String moduleKey, int i) { + ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); + if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) { + return ; + } + OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions(); + XmlCursor cursor = opts.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j){ + cursor.toNextSibling(); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + public void updateModuleSAOptionsOpt(String moduleKey, int i, Vector buildTargets, String toolChain, String tagName, String toolCmd, Vector archList, String contents) { + ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey); + if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) { + return ; + } + OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions(); + XmlCursor cursor = opts.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j){ + cursor.toNextSibling(); + } + OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject(); + setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt); + } + cursor.dispose(); + } + + /**add pcd information of module mi to a ModuleSA. + * @param mi + * @param moduleSa if null, generate a new ModuleSA. + */ + public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, String arch, ModuleSADocument.ModuleSA moduleSa) throws Exception { + //ToDo add Arch filter + + try { + if (moduleSa == null) { + moduleSa = genModuleSA(mi, arch); + } + + ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi); + if (msa.getPcdCoded() == null) { + return; + } + + Map m = new HashMap(); + m.put("ModuleSurfaceArea", msa); + SurfaceAreaQuery.setDoc(m); + PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null); + // + // Implementing InitializePlatformPcdBuildDefinitions + // + List l = msa.getPcdCoded().getPcdEntryList(); + ListIterator li = l.listIterator(); + while(li.hasNext()) { + PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next(); + 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); + } + + } + catch (Exception e){ + + 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(); + if (xo == null) { + continue; + } + for (int j = 0; j < xo.length; ++j) { + spdPcd = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)xo[j]; + if (msaPcd.getTokenSpaceGuidCName() == null) { + if (spdPcd.getCName().equals(msaPcd.getCName())) { + return spdPcd; + } + } + else{ + if (spdPcd.getCName().equals(msaPcd.getCName()) && spdPcd.getTokenSpaceGuidCName().equals(msaPcd.getTokenSpaceGuidCName())) { + return spdPcd; + } + } + + } + + } + return null; + } + + 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; } - 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(); } @@ -514,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); - return; + throw new PcdItemTypeConflictException(cName, value); } } } @@ -539,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); - return; + throw new PcdItemTypeConflictException(cName, value); } } } - + */ PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData(); fpdPcd.setCName(cName); fpdPcd.setToken(token); @@ -601,7 +954,7 @@ public class FpdFileContents { } } - private int setMaxSizeForPointer(String datum) { + public int setMaxSizeForPointer(String datum) throws PcdValueMalFormed{ if (datum == null) { return 0; } @@ -621,6 +974,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); @@ -631,7 +985,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(); @@ -652,7 +1006,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", - + throw new PcdValueMalFormed (datum); } } return strValueArray.length; @@ -664,7 +1018,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); } } @@ -677,18 +1031,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(); @@ -706,7 +1064,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); @@ -761,19 +1120,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)) { + cursor.removeXml(); + if (getDynamicPcdBuildDataCount() == 0) { + cursor.toParent(); + cursor.removeXml(); + } + cursor.dispose(); + return; + } } - - cursor.removeXml(); + while (cursor.toNextSibling()); } cursor.dispose(); } @@ -781,7 +1149,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; } @@ -805,6 +1174,8 @@ public class FpdFileContents { public void getDynamicPcdSkuInfos(int i, String[][] saa){ if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; return; } @@ -842,6 +1213,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; } @@ -865,6 +1238,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; } @@ -887,6 +1262,8 @@ public class FpdFileContents { public void removeDynamicPcdBuildDataSkuInfo(int i) { if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; return; } @@ -913,9 +1290,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()) { @@ -942,9 +1319,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()) { @@ -974,135 +1351,643 @@ 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(); + } + return fpdBuildOpts; + } + + public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) { + UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks(); + if (udats == null) { + udats = getfpdBuildOpts().addNewUserDefinedAntTasks(); + } + + AntTaskDocument.AntTask at = udats.addNewAntTask(); + setBuildOptionsUserDefAntTask(id, fileName, execOrder, at); + } + + 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) { + XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks(); + if (o == null) { + return; + } + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.removeXml(); + if (getBuildOptionsUserDefAntTaskCount() == 0) { + cursor.toParent(); + cursor.removeXml(); + } + } + cursor.dispose(); + } + + public void updateBuildOptionsUserDefAntTask(int i, String id, String fileName, String execOrder){ + XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks(); + if (o == null) { + return; + } + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)cursor.getObject(); + setBuildOptionsUserDefAntTask(id, fileName, execOrder, at); + } + cursor.dispose(); + } + + public int getBuildOptionsUserDefAntTaskCount() { + UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks(); + if (udats == null || udats.getAntTaskList() == null) { + return 0; + } + + return udats.getAntTaskList().size(); + } + + public void getBuildOptionsUserDefAntTasks(String[][] saa) { + UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks(); + if (udats == null || udats.getAntTaskList() == null) { + return ; + } + + List l = udats.getAntTaskList(); + ListIterator li = l.listIterator(); + int i = 0; + while (li.hasNext()) { + AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)li.next(); + saa[i][0] = at.getId() + ""; + saa[i][1] = saa[i][2] = ""; + if (at.getFilename() != null){ + saa[i][1] = at.getFilename(); + } + if (at.getAntCmdOptions() != null) { + saa[i][2] = at.getAntCmdOptions(); + } + ++i; + } + } + public void genBuildOptionsOpt(Vector buildTargets, String toolChain, String tagName, String toolCmd, Vector archList, String contents) { + OptionsDocument.Options opts = getfpdBuildOpts().getOptions(); + if (opts == null) { + opts = getfpdBuildOpts().addNewOptions(); + } + OptionDocument.Option opt = opts.addNewOption(); + setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt); + } + + private void setBuildOptionsOpt(Vector buildTargets, String toolChain, String tagName, String toolCmd, Vector archList, String contents, OptionDocument.Option opt){ + opt.setStringValue(contents); + + opt.setBuildTargets(buildTargets); + opt.setToolChainFamily(toolChain); + opt.setTagName(tagName); + opt.setToolCode(toolCmd); + + if (archList != null) { + opt.setSupArchList(archList); + } + else { + if (opt.isSetSupArchList()) { + opt.unsetSupArchList(); + } + } + } + + public void removeBuildOptionsOpt(int i){ + + XmlObject o = getfpdBuildOpts().getOptions(); + if (o == null) { + return; + } + + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.removeXml(); + if (getBuildOptionsOptCount() == 0) { + cursor.toParent(); + cursor.removeXml(); + } + } + cursor.dispose(); + } + + public void updateBuildOptionsOpt(int i, Vector buildTargets, String toolChain, String tagName, String toolCmd, Vector archList, String contents) { + XmlObject o = getfpdBuildOpts().getOptions(); + if (o == null) { + return; + } + + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject(); + setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt); + } + cursor.dispose(); + } + + public int getBuildOptionsOptCount(){ + if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) { + return 0; + } + return getfpdBuildOpts().getOptions().getOptionList().size(); + } + + public void getBuildOptionsOpts(String[][] saa) { + if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) { + return ; + } + + List lOpt = getfpdBuildOpts().getOptions().getOptionList(); + ListIterator li = lOpt.listIterator(); + int i = 0; + while(li.hasNext()) { + OptionDocument.Option opt = (OptionDocument.Option)li.next(); + if (opt.getBuildTargets() != null) { + saa[i][0] = listToString(opt.getBuildTargets()); + } + saa[i][1] = opt.getToolChainFamily(); + if (opt.getSupArchList() != null){ + saa[i][2] = listToString(opt.getSupArchList()); + + } + saa[i][3] = opt.getToolCode(); + saa[i][4] = opt.getTagName(); + saa[i][5] = opt.getStringValue(); + + ++i; + } + } + + public void genBuildOptionsFfs(String ffsKey, String type) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs(); + ffs.setFfsKey(ffsKey); + if (type != null) { + ffs.addNewSections().setEncapsulationType(type); + } + } + + public void updateBuildOptionsFfsSectionsType(int i, String type) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs(); + if (type != null) { + ffs.addNewSections().setEncapsulationType(type); + } + } + + public void genBuildOptionsFfsAttribute(int i, String name, String value) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = ffs.addNewAttribute(); + attrib.setName(name); + attrib.setValue(value); + } + + /**update jth attribute of ith ffs. + * @param i + * @param j + */ + public void updateBuildOptionsFfsAttribute(int i, int j, String name, String value){ + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + XmlCursor cursor = ffs.newCursor(); + QName qAttrib = new QName(xmlNs, "Attribute"); + if (cursor.toChild(qAttrib)) { + for (int k = 0; k < j; ++k) { + cursor.toNextSibling(qAttrib); + } + BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = (BuildOptionsDocument.BuildOptions.Ffs.Attribute)cursor.getObject(); + attrib.setName(name); + attrib.setValue(value); + } + cursor.dispose(); + } + + public void removeBuildOptionsFfsAttribute(int i, int j){ + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + XmlCursor cursor = ffs.newCursor(); + QName qAttrib = new QName(xmlNs, "Attribute"); + if (cursor.toChild(qAttrib)) { + for (int k = 0; k < j; ++k) { + cursor.toNextSibling(qAttrib); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + public void genBuildOptionsFfsSectionsSection(int i, String sectionType) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + if (ffs == null) { + return; + } + BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections(); + + if (sections == null){ + sections = ffs.addNewSections(); + } + sections.addNewSection().setSectionType(EfiSectionType.Enum.forString(sectionType)); + } + + public void removeBuildOptionsFfsSectionsSection(int i, int j) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections(); + if (sections == null) { + return; + } + XmlCursor cursor = sections.newCursor(); + QName qSection = new QName(xmlNs, "Section"); + if (cursor.toChild(qSection)) { + for (int k = 0; k < j; ++k) { + cursor.toNextSibling(qSection); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + public void updateBuildOptionsFfsSectionsSection(int i, int j, String type){ + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections(); + if (sections == null) { + return; + } + XmlCursor cursor = sections.newCursor(); + QName qSection = new QName(xmlNs, "Section"); + if (cursor.toChild(qSection)) { + for (int k = 0; k < j; ++k) { + cursor.toNextSibling(qSection); + } + BuildOptionsDocument.BuildOptions.Ffs.Sections.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Section)cursor.getObject(); + section.setSectionType(EfiSectionType.Enum.forString(type)); + } + cursor.dispose(); + } + + public void genBuildOptionsFfsSectionsSections(int i, String encapType) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + if (ffs == null) { + return; + } + BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections(); + + if (sections == null){ + sections = ffs.addNewSections(); + } + sections.addNewSections().setEncapsulationType(encapType); + } + + public void removeBuildOptionsFfsSectionsSections(int i, int j) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections(); + if (sections == null) { + return; + } + XmlCursor cursor = sections.newCursor(); + QName qSections = new QName(xmlNs, "Sections"); + if (cursor.toChild(qSections)) { + for (int k = 0; k < j; ++k) { + cursor.toNextSibling(qSections); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + public void updateBuildOptionsFfsSectionsSections(int i, int j, String type) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections(); + if (sections == null) { + return; + } + XmlCursor cursor = sections.newCursor(); + QName qSections = new QName(xmlNs, "Sections"); + if (cursor.toChild(qSections)) { + for (int k = 0; k < j; ++k) { + cursor.toNextSibling(qSections); + } + BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject(); + sections2.setEncapsulationType(type); + } + cursor.dispose(); + } + + public void genBuildOptionsFfsSectionsSectionsSection(int i, int j, String type) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + if (ffs == null) { + return; + } + BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections(); + XmlCursor cursor = sections.newCursor(); + QName qSections = new QName(xmlNs, "Sections"); + if (cursor.toChild(qSections)){ + for (int k = 0; k < j; ++k) { + cursor.toNextSibling(qSections); + } + BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject(); + sections2.addNewSection().setSectionType(EfiSectionType.Enum.forString(type)); + } + cursor.dispose(); + } + + public void removeBuildOptionsFfsSectionsSectionsSection(int i, int j, int k) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections(); + if (sections == null) { + return; + } + XmlCursor cursor = sections.newCursor(); + QName qSections = new QName(xmlNs, "Sections"); + if (cursor.toChild(qSections)) { + for (int l = 0; l < j; ++l) { + cursor.toNextSibling(qSections); + } + if (cursor.toFirstChild()) { + int m = 0; + for (; m < k; ++m) { + cursor.toNextSibling(); + } + cursor.removeXml(); + if (m == 0) { + cursor.toParent(); + cursor.removeXml(); + } + } + } + cursor.dispose(); + } + + public void updateBuildOptionsFfsSectionsSectionsSection(int i, int j, int k, String type) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections(); + if (sections == null) { + return; + } + XmlCursor cursor = sections.newCursor(); + QName qSections = new QName(xmlNs, "Sections"); + if (cursor.toChild(qSections)) { + for (int l = 0; l < j; ++l) { + cursor.toNextSibling(qSections); + } + if (cursor.toFirstChild()) { + for (int m = 0; m < k; ++m) { + cursor.toNextSibling(); + } + BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section)cursor.getObject(); + section.setSectionType(EfiSectionType.Enum.forString(type)); + } + } + cursor.dispose(); + } + + public void getBuildOptionsFfsSectionsSectionsSection(int i, int j, ArrayList al) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + if (ffs == null) { + return; + } + BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections(); + XmlCursor cursor = sections.newCursor(); + QName qSections = new QName(xmlNs, "Sections"); + if (cursor.toChild(qSections)){ + for (int k = 0; k < j; ++k) { + cursor.toNextSibling(qSections); + } + BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject(); + if (sections2.getSectionList() == null){ + cursor.dispose(); + return; + } + ListIterator li = sections2.getSectionList().listIterator(); + while(li.hasNext()) { + BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = li.next(); + if (section.isSetSectionType()) { + al.add(section.getSectionType().toString()); + } + + } + } + cursor.dispose(); + + } + + public int getBuildOptionsFfsCount(){ + if (getfpdBuildOpts().getFfsList() == null) { + return 0; + } + return getfpdBuildOpts().getFfsList().size(); + } + + public void getBuildOptionsFfsKey(String[][] saa) { + if (getfpdBuildOpts().getFfsList() == null) { + return; + } + ListIterator li = getfpdBuildOpts().getFfsList().listIterator(); + int i = 0; + while(li.hasNext()){ + BuildOptionsDocument.BuildOptions.Ffs ffs = li.next(); + saa[i][0] = ffs.getFfsKey(); + ++i; + } + } + + public void updateBuildOptionsFfsKey(int i, String key) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + ffs.setFfsKey(key); + } + + /**Get ith FFS key and contents. + * @param saa + */ + public void getBuildOptionsFfs(int i, String[] sa, LinkedHashMap ffsAttribMap, ArrayList firstLevelSections, ArrayList firstLevelSection) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + + if (ffs != null) { + + sa[0] = ffs.getFfsKey(); + if (ffs.getSections() != null) { + if(ffs.getSections().getEncapsulationType() != null){ + sa[1] = ffs.getSections().getEncapsulationType(); + } + if (ffs.getSections().getSectionList() != null){ + ListIterator li = ffs.getSections().getSectionList().listIterator(); + while (li.hasNext()) { + firstLevelSection.add(li.next().getSectionType().toString()); + } + } + if (ffs.getSections().getSectionsList() != null) { + ListIterator li = ffs.getSections().getSectionsList().listIterator(); + while(li.hasNext()) { + firstLevelSections.add(li.next().getEncapsulationType()); + } + } + } + if (ffs.getAttributeList() != null) { + ListIterator li = ffs.getAttributeList().listIterator(); + while(li.hasNext()) { + BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = li.next(); + ffsAttribMap.put(attrib.getName(), attrib.getValue()); + } + + } + } + + + } + + private BuildOptionsDocument.BuildOptions.Ffs getFfs(int i) { + XmlObject o = getfpdBuildOpts(); + BuildOptionsDocument.BuildOptions.Ffs ffs = null; + XmlCursor cursor = o.newCursor(); + QName qFfs = new QName(xmlNs, "Ffs"); + if (cursor.toChild(qFfs)) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(qFfs); + } + ffs = (BuildOptionsDocument.BuildOptions.Ffs)cursor.getObject(); + } + cursor.dispose(); + return ffs; } - public BuildOptionsDocument.BuildOptions getfpdBuildOpts() { - if (fpdBuildOpts == null) { - fpdBuildOpts = fpdRoot.addNewBuildOptions(); + public void removeBuildOptionsFfs(int i) { + BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i); + if (ffs == null){ + return; } - return fpdBuildOpts; + + XmlCursor cursor = ffs.newCursor(); + cursor.removeXml(); + cursor.dispose(); } - public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) { - UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks(); - if (udats == null) { - udats = getfpdBuildOpts().addNewUserDefinedAntTasks(); + + + public PlatformDefinitionsDocument.PlatformDefinitions getfpdPlatformDefs(){ + if (fpdPlatformDefs == null){ + fpdPlatformDefs = fpdRoot.addNewPlatformDefinitions(); } - - AntTaskDocument.AntTask at = udats.addNewAntTask(); - setBuildOptionsUserDefAntTask(id, fileName, execOrder, at); + return fpdPlatformDefs; } - private void setBuildOptionsUserDefAntTask(String id, String fileName, String execOrder, AntTaskDocument.AntTask at) { - at.setId(new Integer(id)); - if (fileName != null){ - at.setFilename(fileName); + public void getPlatformDefsSupportedArchs(Vector archs){ + if (getfpdPlatformDefs().getSupportedArchitectures() == null) { + return; } - if (execOrder != null) { - at.setAntCmdOptions(execOrder); + ListIterator li = getfpdPlatformDefs().getSupportedArchitectures().listIterator(); + while(li.hasNext()) { + archs.add(li.next()); } } - public void removeBuildOptionsUserDefAntTask(int i) { - XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks(); - if (o == null) { + public void setPlatformDefsSupportedArchs(Vector 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) { + if (getfpdPlatformDefs().getBuildTargets() == null) { return; } - XmlCursor cursor = o.newCursor(); - if (cursor.toFirstChild()) { - for (int j = 0; j < i; ++j) { - cursor.toNextSibling(); - } - cursor.removeXml(); + ListIterator li = getfpdPlatformDefs().getBuildTargets().listIterator(); + while(li.hasNext()) { + targets.add(li.next()); } - cursor.dispose(); } - public void updateBuildOptionsUserDefAntTask(int i, String id, String fileName, String execOrder){ - XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks(); - if (o == null) { - return; + public void setPlatformDefsBuildTargets(Vector targets) { + getfpdPlatformDefs().setBuildTargets(targets); + } + + public void genPlatformDefsSkuInfo(String id, String name) { + SkuInfoDocument.SkuInfo skuInfo = null; + if (getfpdPlatformDefs().getSkuInfo() == null) { + skuInfo = getfpdPlatformDefs().addNewSkuInfo(); } - XmlCursor cursor = o.newCursor(); - if (cursor.toFirstChild()) { - for (int j = 0; j < i; ++j) { - cursor.toNextSibling(); - } - AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)cursor.getObject(); - setBuildOptionsUserDefAntTask(id, fileName, execOrder, at); + skuInfo = getfpdPlatformDefs().getSkuInfo(); + if (skuInfo.getUiSkuNameList() == null || skuInfo.getUiSkuNameList().size() == 0) { + SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName(); + skuName.setSkuID(new BigInteger("0")); + skuName.setStringValue("DEFAULT"); } - cursor.dispose(); + if (id.equals("0")) { + return; + } + SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName(); + skuName.setSkuID(new BigInteger(id)); + skuName.setStringValue(name); } - public int getBuildOptionsUserDefAntTaskCount() { - UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks(); - if (udats == null || udats.getAntTaskList() == null) { + public int getPlatformDefsSkuInfoCount(){ + if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) { return 0; } - - return udats.getAntTaskList().size(); + return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size(); } - public void getBuildOptionsUserDefAntTasks(String[][] saa) { - UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks(); - if (udats == null || udats.getAntTaskList() == null) { + public void getPlatformDefsSkuInfos(String[][] saa){ + if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) { + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) { + removeElement(getfpdDynPcdBuildDefs()); + fpdDynPcdBuildDefs = null; + } return ; } - List l = udats.getAntTaskList(); - ListIterator li = l.listIterator(); + List l = getfpdPlatformDefs().getSkuInfo().getUiSkuNameList(); + ListIterator li = l.listIterator(); int i = 0; - while (li.hasNext()) { - AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)li.next(); - saa[i][0] = at.getId() + ""; - saa[i][1] = saa[i][2] = ""; - if (at.getFilename() != null){ - saa[i][1] = at.getFilename(); - } - if (at.getAntCmdOptions() != null) { - saa[i][2] = at.getAntCmdOptions(); - } + while(li.hasNext()) { + SkuInfoDocument.SkuInfo.UiSkuName sku = li.next(); + saa[i][0] = sku.getSkuID()+""; + saa[i][1] = sku.getStringValue(); ++i; } } - public void genBuildOptionsOpt(String buildTargets, String toolChain, String tagName, String toolCmd, String archList, String contents) { - OptionsDocument.Options opts = getfpdBuildOpts().getOptions(); - if (opts == null) { - opts = getfpdBuildOpts().addNewOptions(); - } - OptionDocument.Option opt = opts.addNewOption(); - setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt); - } - - private void setBuildOptionsOpt(String buildTargets, String toolChain, String tagName, String toolCmd, String archList, String contents, OptionDocument.Option opt){ - opt.setStringValue(contents); -// opt.setBuildTargets(buildTargets); - opt.setToolChainFamily(toolChain); - opt.setTagName(tagName); - opt.setToolCode(toolCmd); - String[] s = archList.split(" "); - ArrayList al = new ArrayList(); - for (int i = 0; i < s.length; ++i) { - al.add(s[i]); - } - opt.setSupArchList(al); - } - - public void removeBuildOptionsOpt(int i){ - XmlObject o = getfpdBuildOpts().getOptions(); - if (o == null) { - return; + public void removePlatformDefsSkuInfo(int i) { + SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo(); + if (skuInfo == null || i == 0) { + return ; } - XmlCursor cursor = o.newCursor(); + XmlCursor cursor = skuInfo.newCursor(); if (cursor.toFirstChild()) { for (int j = 0; j < i; ++j) { cursor.toNextSibling(); @@ -1112,64 +1997,50 @@ public class FpdFileContents { cursor.dispose(); } - public void updateBuildOptionsOpt(int i, String buildTargets, String toolChain, String tagName, String toolCmd, String archList, String contents) { - XmlObject o = getfpdBuildOpts().getOptions(); - if (o == null) { - return; + public void updatePlatformDefsSkuInfo(int i, String id, String name) { + SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo(); + if (skuInfo == null || i == 0) { + return ; } - XmlCursor cursor = o.newCursor(); + XmlCursor cursor = skuInfo.newCursor(); if (cursor.toFirstChild()) { for (int j = 0; j < i; ++j) { cursor.toNextSibling(); } - OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject(); - setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt); + SkuInfoDocument.SkuInfo.UiSkuName sku = (SkuInfoDocument.SkuInfo.UiSkuName)cursor.getObject(); + sku.setSkuID(new BigInteger(id)); + sku.setStringValue(name); } cursor.dispose(); } - public int getBuildOptionsOptCount(){ - if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) { - return 0; + public String getPlatformDefsInterDir(){ + if (getfpdPlatformDefs().getIntermediateDirectories() == null) { + return null; } - return getfpdBuildOpts().getOptions().getOptionList().size(); + return getfpdPlatformDefs().getIntermediateDirectories().toString(); } - public void getBuildOptionsOpts(String[][] saa) { - if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) { - return ; - } - - List lOpt = getfpdBuildOpts().getOptions().getOptionList(); - ListIterator li = lOpt.listIterator(); - int i = 0; - while(li.hasNext()) { - OptionDocument.Option opt = (OptionDocument.Option)li.next(); -// saa[i][0] = opt.getBuildTargets(); - saa[i][1] = opt.getToolChainFamily(); - if (opt.getSupArchList() != null){ - Object[] archs = opt.getSupArchList().toArray(); - saa[i][2] = " "; - for (int j = 0; j < archs.length; ++j){ - saa[i][2] += archs[j]; - saa[i][2] += " "; - } - saa[i][2] = saa[i][2].trim(); - } - saa[i][3] = opt.getToolCode(); - saa[i][4] = opt.getTagName(); - saa[i][5] = opt.getStringValue(); - - ++i; - } + public void setPlatformDefsInterDir(String interDir){ + getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType.Enum.forString(interDir)); } - public PlatformDefinitionsDocument.PlatformDefinitions getfpdPlatformDefs(){ - if (fpdPlatformDefs == null){ - fpdPlatformDefs = fpdRoot.addNewPlatformDefinitions(); + public String getPlatformDefsOutputDir() { + return getfpdPlatformDefs().getOutputDirectory(); + } + + public void setPlatformDefsOutputDir(String 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(); } - return fpdPlatformDefs; } public FlashDocument.Flash getfpdFlash() { @@ -1197,8 +2068,6 @@ public class FpdFileContents { return fdf.getStringValue(); } - - public void genFvImagesNameValue(String name, String value) { FvImagesDocument.FvImages fi = getfpdFlash().getFvImages(); @@ -1306,8 +2175,10 @@ public class FpdFileContents { Set key = options.keySet(); Iterator i = key.iterator(); while (i.hasNext()) { + FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fio.addNewNameValue(); String k = (String)i.next(); + nv.setName(k); nv.setValue((String)options.get(k)); @@ -1315,6 +2186,7 @@ public class FpdFileContents { } + public void removeFvImagesFvImage(int i) { XmlObject o = getfpdFlash().getFvImages(); @@ -1381,7 +2253,10 @@ public class FpdFileContents { return getfpdFlash().getFvImages().getFvImageList().size(); } - public void getFvImagesFvImages(String[][] saa, ArrayList> options) { + /**Only Get Fv image setting - name and type. + * @param saa + */ + public void getFvImagesFvImages(String[][] saa) { if (getfpdFlash().getFvImages() == null) { return; @@ -1408,27 +2283,33 @@ public class FpdFileContents { saa[i][1] = fi.getType()+""; - // - // get FvImageOptions into Map[i] - // - FvImagesDocument.FvImages.FvImage.FvImageOptions fo = fi.getFvImageOptions(); - if (fo == null) { - ++i; - continue; + ++i; + } + } + + /**Get FvImage Options for FvImage i + * @param i the ith FvImage + */ + public void getFvImagesFvImageOptions(int i, Map m) { + XmlObject o = getfpdFlash().getFvImages(); + if (o == null) { + return; + } + XmlCursor cursor = o.newCursor(); + QName qFvImage = new QName(xmlNs, "FvImage"); + if (cursor.toChild(qFvImage)) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(qFvImage); } - List lnv = fo.getNameValueList(); - if (lnv == null || lnv.isEmpty()) { - ++i; - continue; + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject(); + if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null){ + return; } - ListIterator lnvi = lnv.listIterator(); - while (lnvi.hasNext()) { - FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue)lnvi.next(); - Map m = options.get(i); + ListIterator li = fi.getFvImageOptions().getNameValueList().listIterator(); + while(li.hasNext()){ + FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next(); m.put(nv.getName(), nv.getValue()); } - - ++i; } } @@ -1440,30 +2321,10 @@ public class FpdFileContents { if (fpdHdr == null) { fpdHdr = fpdRoot.addNewPlatformHeader(); } - genPlatformDefsSkuInfo("0", "DEFAULT"); + return fpdHdr; } - public void genPlatformDefsSkuInfo(String id, String name) { - SkuInfoDocument.SkuInfo skuInfo = null; - if (getfpdPlatformDefs().getSkuInfo() == null) { - skuInfo = getfpdPlatformDefs().addNewSkuInfo(); - } - skuInfo = getfpdPlatformDefs().getSkuInfo(); - if (skuInfo.getUiSkuNameList() == null || skuInfo.getUiSkuNameList().size() == 0) { - SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName(); - skuName.setSkuID(new BigInteger("0")); - skuName.setStringValue("DEFAULT"); - } - if (id.equals("0")) { - return; - } - SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName(); - skuName.setSkuID(new BigInteger(id)); - skuName.setStringValue(name); - - - } public String getFpdHdrPlatformName() { return getFpdHdr().getPlatformName(); } @@ -1506,7 +2367,7 @@ public class FpdFileContents { public String getFpdHdrSpec() { - return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; + return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; // return getFpdHdr().getSpecification(); } @@ -1552,7 +2413,7 @@ public class FpdFileContents { } public void setFpdHdrSpec(String s){ - s = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; + s = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; getFpdHdr().setSpecification(s); } /** @@ -1576,7 +2437,7 @@ public class FpdFileContents { } - private String listToString(List l) { + private String listToString(List l) { if (l == null) { return null; } @@ -1588,4 +2449,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 = GlobalData.getModuleId(info); + details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackage().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; + } }