**/\r
package org.tianocore.build.pcd.entity;\r
\r
-import java.io.BufferedWriter;\r
-import java.io.File;\r
-import java.io.FileWriter;\r
-import java.io.IOException;\r
import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
import java.util.HashMap;\r
-import java.util.Hashtable;\r
import java.util.List;\r
import java.util.Map;\r
import java.util.UUID;\r
\r
-import org.tianocore.build.pcd.action.ActionMessage;\r
+import org.tianocore.build.id.ModuleIdentification;\r
+import org.tianocore.build.pcd.exception.EntityException;\r
\r
/** Database hold all PCD information comes from SPD, MSA, FPD file in memory.\r
**/\r
/// context of building libary.\r
/// \r
public static List<UsageInstance> UsageInstanceContext = null;\r
+\r
///\r
- /// \r
+ /// Current module name, if now is buiding library, this value indicate this library\r
+ /// is for building what module.\r
/// \r
public static String CurrentModuleName = null;\r
- public static String PcdPeimHString = "";\r
- public static String PcdPeimCString = "";\r
- public static String PcdDxeHString = "";\r
- public static String PcdDxeCString = "";\r
+\r
+ ///\r
+ /// String for PCD PEIM and DXE autogen file\r
+ /// \r
+ public static String PcdPeimHString = "";\r
+ public static String PcdPeimCString = "";\r
+ public static String PcdDxeHString = "";\r
+ public static String PcdDxeCString = "";\r
\r
/**\r
Constructure function\r
private ArrayList getDynamicRecordArray() {\r
Token[] tokenArray = getRecordArray();\r
int index = 0;\r
- int count = 0;\r
ArrayList<Token> al = new ArrayList<Token>();\r
\r
for (index = 0; index < tokenArray.length; index++) {\r
The output array is sorted based on descending order of the size of alignment for each feilds.\r
\r
@return the token record array contained all PCD token referenced in PEI phase.\r
+ @throws EntityException\r
**/\r
- public void getTwoPhaseDynamicRecordArray(ArrayList<Token> pei, ArrayList<Token> dxe) {\r
+ public void getTwoPhaseDynamicRecordArray(ArrayList<Token> pei, ArrayList<Token> dxe) \r
+ throws EntityException {\r
int usageInstanceIndex = 0;\r
int index = 0;\r
ArrayList tokenArrayList = getDynamicRecordArray();\r
}\r
}\r
\r
- // If no PEI components reference the PCD entry, we insert it to DXE list\r
+ //\r
+ // If no PEI components reference the PCD entry, \r
+ // we check if it is referenced in DXE driver. \r
//\r
if (!found) {\r
- dxe.add(token);\r
+ if (token.consumers != null) {\r
+ usageInstanceArray = token.consumers.entrySet().toArray();\r
+ for (usageInstanceIndex = 0; usageInstanceIndex < token.consumers.size(); usageInstanceIndex ++) {\r
+ usageInstance =(UsageInstance) (((Map.Entry)usageInstanceArray[usageInstanceIndex]).getValue());\r
+ if (usageInstance.isDxePhaseComponent()) {\r
+ dxe.add(token);\r
+ found = true;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ \r
+ if (!found) {\r
+ if (token.isDynamicPCD && token.consumers.size() == 0) {\r
+ dxe.add(token);\r
+ } else {\r
+ //\r
+ // We only support Dynamice(EX) type for PEI and DXE phase.\r
+ // If it is not referenced in either PEI or DXE, throw exception now.\r
+ //\r
+ throw new EntityException("[PCD tool Internal Error] Dynamic(EX) PCD Entries are referenced in module that is not in PEI phase nor in DXE phase.");\r
+ }\r
+ }\r
}\r
}\r
\r
Get all PCD record for a module according to module's name, module's GUID,\r
package name, package GUID, arch, version information.\r
\r
- @param moduleName the name of module.\r
+ @param moduleId the id of module.\r
+ @param arch the architecture\r
\r
@return all usage instance for this module in memory database.\r
**/\r
- public List<UsageInstance> getUsageInstanceArrayByModuleName(String moduleName,\r
- UUID moduleGuid,\r
- String packageName,\r
- UUID packageGuid,\r
- String arch,\r
- String version) {\r
-\r
- String primaryKey = UsageInstance.getPrimaryKey(moduleName, \r
- moduleGuid,\r
- packageName,\r
- packageGuid,\r
- arch,\r
- version);\r
+ public List<UsageInstance> getUsageInstanceArrayByModuleName(ModuleIdentification moduleId,\r
+ String arch) {\r
+\r
+ String primaryKey = UsageInstance.getPrimaryKey(moduleId, arch);\r
\r
return getUsageInstanceArrayByKeyString(primaryKey);\r
}\r