+ public boolean adjustPcd (int seqModuleSa) throws Exception {\r
+ boolean dataModified = false;\r
+ ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa);\r
+ int pcdCount = getPcdDataCount(seqModuleSa);\r
+ String[][] saaModuleSaPcd = new String[pcdCount][7];\r
+ getPcdData(seqModuleSa, saaModuleSaPcd);\r
+ String mg = moduleSa.getModuleGuid();\r
+ String mv = moduleSa.getModuleVersion();\r
+ String pg = moduleSa.getPackageGuid();\r
+ String pv = moduleSa.getPackageVersion();\r
+ String arch = listToString(moduleSa.getSupArchList());\r
+ //\r
+ // delete pcd in ModuleSA but not in MSA files any longer.\r
+ //\r
+ String moduleKey = mg + " " + mv + " " + pg + " " + pv + " " + arch;\r
+ int libCount = getLibraryInstancesCount(moduleKey);\r
+ String[][] saaLib = new String[libCount][5];\r
+ getLibraryInstances(moduleKey, saaLib);\r
+ ModuleIdentification mi = GlobalData.getModuleId(moduleKey);\r
+ Vector<ModuleIdentification> vMi = new Vector<ModuleIdentification>();\r
+ vMi.add(mi);\r
+ try {\r
+ nextPcd:for (int i = 0; i < saaModuleSaPcd.length; ++i) {\r
+ if (GlobalData.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], mi)){\r
+ continue;\r
+ }\r
+ for (int j = 0; j < saaLib.length; ++j) {\r
+ String libKey = saaLib[j][1] + " " + saaLib[j][2] + " " + saaLib[j][3] + " " + saaLib[j][4];\r
+ ModuleIdentification libMi = GlobalData.getModuleId(libKey);\r
+ vMi.add(libMi);\r
+ if (GlobalData.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], libMi)) {\r
+ continue nextPcd;\r
+ }\r
+ }\r
+ removePcdData(seqModuleSa, saaModuleSaPcd[i][0], saaModuleSaPcd[i][1]);\r
+ dataModified = true;\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ \r
+ }\r
+ //\r
+ // add new Pcd from MSA file to ModuleSA.\r
+ //\r
+ try {\r
+ \r
+ for (int i = 0; i < vMi.size(); ++i) {\r
+ ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) GlobalData\r
+ .getModuleXmlObject(vMi\r
+ .get(i));\r
+ if (msa.getPcdCoded() == null || msa.getPcdCoded().getPcdEntryList() == null) {\r
+ continue;\r
+ }\r
+ ListIterator li = msa.getPcdCoded().getPcdEntryList().listIterator();\r
+ msaPcdIter:while (li.hasNext()) {\r
+ PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry) li.next();\r
+ ArrayList<String> al = getDynPcdMapValue(msaPcd.getCName() + " " + msaPcd.getTokenSpaceGuidCName());\r
+ if (al != null) {\r
+ for (int j = 0; j < al.size(); ++j) {\r
+ if (al.get(j).contains(moduleKey)) {\r
+ continue msaPcdIter;\r
+ }\r
+ }\r
+ }\r
+ \r
+ Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r
+ m.put("ModuleSurfaceArea", msa);\r
+ SurfaceAreaQuery.setDoc(m);\r
+ PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null);\r
+ PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r
+ if (spdPcd == null) {\r
+ //\r
+ // ToDo Error \r
+ //\r
+ throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module "\r
+ + mi.getName());\r
+ }\r
+ //\r
+ // AddItem to ModuleSA PcdBuildDefinitions\r
+ //\r
+ String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue()\r
+ : msaPcd.getDefaultValue();\r
+\r
+ genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(),\r
+ msaPcd.getPcdItemType().toString(), spdPcd.getDatumType() + "", defaultVal, moduleSa);\r
+ dataModified = true;\r
+ }\r
+\r
+ }\r
+ }\r
+ catch (Exception e){\r
+ throw e;\r
+ }\r
+ \r
+ return dataModified;\r
+ }\r
+ \r