public class FpdFileContents {\r
\r
static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0";\r
- static final String regNewLineAndSpaces = "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*";\r
+ static final String regExpNewLineAndSpaces = "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*";\r
\r
private PlatformSurfaceAreaDocument fpdd = null;\r
\r
break;\r
}\r
String s = cursor.getTextValue();\r
- if (s.matches(regNewLineAndSpaces)) {\r
+ if (s.matches(regExpNewLineAndSpaces)) {\r
continue;\r
}\r
}\r
vMi.add(libMi);\r
}\r
\r
- try {\r
nextPcd:for (int i = 0; i < saaModuleSaPcd.length; ++i) {\r
\r
for (int j = 0; j < vMi.size(); ++j) {\r
removePcdData(seqModuleSa, saaModuleSaPcd[i][0], saaModuleSaPcd[i][1]);\r
dataModified = true;\r
}\r
- }\r
- catch (Exception e) {\r
- throw e;\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
+ for (int i = 0; i < vMi.size(); ++i) {\r
ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile\r
.getModuleXmlObject(vMi\r
.get(i));\r
}\r
\r
}\r
- }\r
- catch (Exception e){\r
- throw e;\r
- }\r
\r
return dataModified;\r
}\r
return false;\r
}\r
\r
+ private boolean multiSourcePcd (String cName, String tsGuidCName, String moduleKey) {\r
+ int libCount = getLibraryInstancesCount(moduleKey);\r
+ String[][] saaLib = new String[libCount][5];\r
+ getLibraryInstances(moduleKey, saaLib);\r
+ ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);\r
+ Vector<ModuleIdentification> vMi = new Vector<ModuleIdentification>();\r
+ //\r
+ // create vector for module & library instance MIs.\r
+ //\r
+ vMi.add(mi);\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 = WorkspaceProfile.getModuleId(libKey);\r
+ vMi.add(libMi);\r
+ }\r
+ \r
+ int pcdSourceCount = 0;\r
+ for (int i = 0; i < vMi.size(); ++i) {\r
+ if (WorkspaceProfile.pcdInMsa(cName, tsGuidCName, vMi.get(i))) {\r
+ pcdSourceCount++;\r
+ }\r
+ }\r
+ \r
+ if (pcdSourceCount < 2) {\r
+ return false;\r
+ }\r
+ else {\r
+ return true;\r
+ }\r
+ \r
+ }\r
+ \r
/**Remove PCDBuildDefinition entries from ModuleSA\r
* @param moduleKey identifier of ModuleSA.\r
* @param consumer where these entries come from.\r
*/\r
public void removePcdData(String moduleKey, ModuleIdentification consumer) {\r
- try {\r
+ \r
ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(consumer);\r
if (msa.getPcdCoded() == null) {\r
return;\r
do {\r
PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor\r
.getObject();\r
- if (msaPcd.getCName().equals(pcdData.getCName())\r
- && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r
+ String cName = msaPcd.getCName();\r
+ String tsGuidCName = msaPcd.getTokenSpaceGuidCName();\r
+ if (cName.equals(pcdData.getCName())\r
+ && tsGuidCName.equals(pcdData.getTokenSpaceGuidCName()) && !multiSourcePcd(cName, tsGuidCName, moduleKey)) {\r
\r
maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(),\r
moduleKey);\r
cursor.dispose();\r
}\r
}\r
- \r
- }\r
- catch (Exception e){\r
- e.printStackTrace();\r
- \r
- }\r
+ \r
}\r
//\r
// key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"\r
break;\r
}\r
String s = cursor.getTextValue();\r
- if (s.matches(regNewLineAndSpaces)) {\r
+ if (s.matches(regExpNewLineAndSpaces)) {\r
continue;\r
}\r
}\r
pcdConsumer = new ArrayList<String>();\r
}\r
//\r
+ // Check whether this PCD has already added to ModuleSA, if so, just return.\r
+ //\r
+ String moduleInfo = moduleSa.getModuleGuid().toLowerCase() + " " + moduleSa.getModuleVersion() \r
+ + " " + moduleSa.getPackageGuid().toLowerCase() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList());\r
+ for (int i = 0; i < pcdConsumer.size(); ++i) {\r
+ String pcdInfo = pcdConsumer.get(i);\r
+ if (moduleInfo.equals(pcdInfo.substring(0, pcdInfo.lastIndexOf(" ")))){\r
+ return;\r
+ }\r
+ }\r
+ //\r
// Using existing Pcd type, if this pcd already exists in other ModuleSA\r
//\r
if (pcdConsumer.size() > 0) {\r
\r
itemType = itemType (pcdConsumer.get(0));\r
}\r
- String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() \r
- + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList())\r
- + " " + itemType;\r
+ String listValue = moduleInfo + " " + itemType;\r
pcdConsumer.add(listValue);\r
dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);\r
\r