GuidGuidToAutogenC(fileBuffer);\r
\r
//\r
- // Call pcd autogen. PCDAutoGenAction tool only need module name and\r
- // isPcdEmulatedDriver as parameter. Library inherits PCD and module's\r
- // PCD information has been collected in FPDParser task by\r
- // CollectPCDAction.\r
- // Note : when PCD image tool ready,\r
- // isPCDEmulatedDriver parameter will be removed.\r
- //\r
- try {\r
-// this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(),\r
-// moduleId.getGuid(), moduleId.getPackage().getName(), moduleId.getPackage().getGuid(),this.arch,moduleId.getVersion(),false, null);\r
- this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(),null,null,null, this.arch,null,false, null);\r
- this.myPcdAutogen.execute();\r
- } catch (Exception e) {\r
- throw new BuildException("PCD Autogen failed:" + e.getMessage());\r
- }\r
+ // Call pcd autogen. \r
+ //\r
+ this.myPcdAutogen = new PCDAutoGenAction(moduleId, this.arch, false, null);\r
+ try {\r
+ this.myPcdAutogen.execute();\r
+ } catch (Exception exp) {\r
+ throw new BuildException (exp.getMessage());\r
+ }\r
\r
if (this.myPcdAutogen != null) {\r
- fileBuffer.append("\r\n");\r
- fileBuffer.append(this.myPcdAutogen.OutputC());\r
+ fileBuffer.append("\r\n");\r
+ fileBuffer.append(this.myPcdAutogen.OutputC());\r
}\r
\r
if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
fileBuffer.append("\r\n");\r
\r
//\r
- // Call pcd autogen. PCDAutoGenAction tool only need module name and\r
- // isPcdEmulatedDriver as parameter. Library inherit PCD and module's\r
- // PCD information has been collected in FPDParser task by\r
- // CollectPCDAction.\r
- // Note : when PCD image tool ready,\r
- // isPCDEmulatedDriver parameter will be removed.\r
+ // Call pcd autogen. \r
//\r
+ this.myPcdAutogen = new PCDAutoGenAction(this.moduleId,\r
+ this.arch,\r
+ true, \r
+ SurfaceAreaQuery.getModulePcdEntryNameArray());\r
try {\r
-// this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(),\r
-// this.moduleId.getGuid(),moduleId.getPackage().getName(),moduleId.getPackage().getGuid(), this.arch, moduleId.getVersion(),true, SurfaceAreaQuery.getModulePcdEntryNameArray());\r
- this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(),\r
- null,\r
- null,\r
- null,\r
- this.arch,\r
- null,\r
- true, \r
- SurfaceAreaQuery.getModulePcdEntryNameArray());\r
- \r
- this.myPcdAutogen.execute();\r
+ this.myPcdAutogen.execute();\r
} catch (Exception e) {\r
- throw new BuildException(e.getMessage());\r
+ throw new BuildException(e.getMessage());\r
}\r
\r
if (this.myPcdAutogen != null) {\r
- fileBuffer.append("\r\n");\r
- fileBuffer.append(this.myPcdAutogen.OutputC());\r
+ fileBuffer.append("\r\n");\r
+ fileBuffer.append(this.myPcdAutogen.OutputC());\r
}\r
\r
if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
//\r
// For PCD\r
//\r
- public synchronized static Map<FpdModuleIdentification, XmlObject> getFpdModuleSaXmlObject(\r
- String xmlObjectName) {\r
+ public synchronized static Map<FpdModuleIdentification, XmlObject> \r
+ getFpdModuleSaXmlObject(String xmlObjectName) {\r
Set<FpdModuleIdentification> fpdModuleSASet = fpdModuleSA.keySet();\r
Iterator item = fpdModuleSASet.iterator();\r
\r
try{\r
if (SANode.get(xmlObjectName)!= null){\r
SAPcdBuildDef.put(moduleId,\r
- (XmlObject) SANode\r
- .get(xmlObjectName));\r
+ (XmlObject) SANode.get(xmlObjectName));\r
\r
}\r
- \r
- \r
} catch (Exception e){\r
EdkLog.log(EdkLog.EDK_INFO, e.getMessage());\r
}\r
- }\r
+ }\r
return SAPcdBuildDef;\r
}\r
+\r
+ public synchronized static Map<FpdModuleIdentification,XmlObject> getFpdPcdBuildDefinitions() {\r
+ Map<FpdModuleIdentification,XmlObject> pcdBuildDef = getFpdModuleSaXmlObject ("PcdBuildDefinition");\r
+\r
+ return pcdBuildDef;\r
+ }\r
}\r
\r
if (t.isDynamicEx()) {\r
exMapTable.add((int)t.tokenNumber, \r
t.dynamicExTokenNumber, \r
- guidTable.add(t.tokenSpaceName, t.getPrimaryKeyString()), \r
+ guidTable.add(translateSchemaStringToUUID(t.tokenSpaceName), t.getPrimaryKeyString()), \r
t.getPrimaryKeyString()\r
);\r
}\r
}\r
\r
private String getDataTypeDeclarationForVariableDefault (Token token, String cName, int skuId) \r
- throws EntityException {\r
+ throws EntityException {\r
\r
String typeStr;\r
\r
return retStr;\r
}\r
\r
+ /**\r
+ Translate the schema string to UUID instance.\r
+ \r
+ In schema, the string of UUID is defined as following two types string:\r
+ 1) GuidArrayType: pattern = 0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},(\r
+ )*0x[a-fA-F0-9]{1,4}(,( )*\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\})?\r
+ \r
+ 2) GuidNamingConvention: pattern =\r
+ [a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\r
+ \r
+ This function will convert string and create uuid instance.\r
+ \r
+ @param uuidString UUID string in XML file\r
+ \r
+ @return UUID UUID instance\r
+ **/\r
+ private UUID translateSchemaStringToUUID(String uuidString) \r
+ throws EntityException {\r
+ String temp;\r
+ String[] splitStringArray;\r
+ int index;\r
+ int chIndex;\r
+ int chLen;\r
+\r
+ if (uuidString == null) {\r
+ return null;\r
+ }\r
+\r
+ if (uuidString.length() == 0) {\r
+ return null;\r
+ }\r
+\r
+ if (uuidString.equals("0") ||\r
+ uuidString.equalsIgnoreCase("0x0")) {\r
+ return new UUID(0, 0);\r
+ }\r
+\r
+ uuidString = uuidString.replaceAll("\\{", "");\r
+ uuidString = uuidString.replaceAll("\\}", "");\r
+\r
+ //\r
+ // If the UUID schema string is GuidArrayType type then need translate \r
+ // to GuidNamingConvention type at first.\r
+ // \r
+ if ((uuidString.charAt(0) == '0') && ((uuidString.charAt(1) == 'x') || (uuidString.charAt(1) == 'X'))) {\r
+ splitStringArray = uuidString.split("," );\r
+ if (splitStringArray.length != 11) {\r
+ throw new EntityException ("[FPD file error] Wrong format for UUID string: " + uuidString);\r
+ }\r
+\r
+ //\r
+ // Remove blank space from these string and remove header string "0x"\r
+ // \r
+ for (index = 0; index < 11; index ++) {\r
+ splitStringArray[index] = splitStringArray[index].trim();\r
+ splitStringArray[index] = splitStringArray[index].substring(2, splitStringArray[index].length());\r
+ }\r
+\r
+ //\r
+ // Add heading '0' to normalize the string length\r
+ // \r
+ for (index = 3; index < 11; index ++) {\r
+ chLen = splitStringArray[index].length();\r
+ for (chIndex = 0; chIndex < 2 - chLen; chIndex ++) {\r
+ splitStringArray[index] = "0" + splitStringArray[index];\r
+ }\r
+ }\r
+\r
+ //\r
+ // construct the final GuidNamingConvention string\r
+ // \r
+ temp = String.format("%s-%s-%s-%s%s-%s%s%s%s%s%s",\r
+ splitStringArray[0],\r
+ splitStringArray[1],\r
+ splitStringArray[2],\r
+ splitStringArray[3],\r
+ splitStringArray[4],\r
+ splitStringArray[5],\r
+ splitStringArray[6],\r
+ splitStringArray[7],\r
+ splitStringArray[8],\r
+ splitStringArray[9],\r
+ splitStringArray[10]);\r
+ uuidString = temp;\r
+ }\r
+\r
+ return UUID.fromString(uuidString);\r
+ }\r
}\r
\r
+/** Module Info class is the data structure to hold information got from GlobalData.\r
+*/\r
class ModuleInfo {\r
- private String type;\r
- private FpdModuleIdentification moduleId;\r
+ ///\r
+ /// Module's ID for a <ModuleSA>\r
+ /// \r
+ private FpdModuleIdentification moduleId;\r
+ ///\r
+ /// <PcdBuildDefinition> xmlobject in FPD file for a <ModuleSA>\r
+ /// \r
private PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef;\r
- \r
- \r
\r
- public ModuleInfo (FpdModuleIdentification moduleId, String type, XmlObject pcdDef) {\r
- this.moduleId = moduleId;\r
- this.type = type;\r
- this.pcdBuildDef = ((PcdBuildDefinitionDocument)pcdDef).getPcdBuildDefinition();\r
- }\r
- public String getModuleType (){\r
- return this.type;\r
+ public ModuleInfo (FpdModuleIdentification moduleId, XmlObject pcdDef) {\r
+ this.moduleId = moduleId;\r
+ this.pcdBuildDef = ((PcdBuildDefinitionDocument)pcdDef).getPcdBuildDefinition();\r
}\r
+\r
public FpdModuleIdentification getModuleId (){\r
- return this.moduleId;\r
+ return moduleId;\r
}\r
+\r
public PcdBuildDefinitionDocument.PcdBuildDefinition getPcdBuildDef(){\r
- return this.pcdBuildDef;\r
+ return pcdBuildDef;\r
}\r
}\r
\r
from buildAction or UIAction.\r
**/\r
public class CollectPCDAction {\r
+ ///\r
/// memoryDatabase hold all PCD information collected from SPD, MSA, FPD.\r
+ /// \r
private MemoryDatabaseManager dbManager;\r
-\r
+ ///\r
/// Workspacepath hold the workspace information.\r
+ /// \r
private String workspacePath;\r
-\r
+ ///\r
/// FPD file is the root file. \r
+ /// \r
private String fpdFilePath;\r
-\r
+ ///\r
/// Message level for CollectPCDAction.\r
+ /// \r
private int originalMessageLevel;\r
-\r
+ ///\r
/// Cache the fpd docment instance for private usage.\r
+ /// \r
private PlatformSurfaceAreaDocument fpdDocInstance;\r
- \r
+ ///\r
/// xmlObject name\r
+ /// \r
private static String xmlObjectName = "PcdBuildDefinition"; \r
\r
/**\r
createTokenInDBFromFPD();\r
\r
//\r
- // Call Private function genPcdDatabaseSourceCode (void); ComponentTypeBsDriver\r
- // 1) Generate for PEI, DXE PCD DATABASE's definition and initialization.\r
+ // Generate for PEI, DXE PCD DATABASE's definition and initialization.\r
//\r
genPcdDatabaseSourceCode ();\r
\r
**/\r
private void genPcdDatabaseSourceCode()\r
throws EntityException {\r
- String PcdCommonHeaderString = PcdDatabase.getPcdDatabaseCommonDefinitions ();\r
+ String PcdCommonHeaderString = PcdDatabase.getPcdDatabaseCommonDefinitions();\r
\r
ArrayList<Token> alPei = new ArrayList<Token> ();\r
ArrayList<Token> alDxe = new ArrayList<Token> ();\r
dbManager.getTwoPhaseDynamicRecordArray(alPei, alDxe);\r
PcdDatabase pcdPeiDatabase = new PcdDatabase (alPei, "PEI", 0);\r
pcdPeiDatabase.genCode();\r
- MemoryDatabaseManager.PcdPeimHString = PcdCommonHeaderString + pcdPeiDatabase.getHString()\r
- + PcdDatabase.getPcdPeiDatabaseDefinitions();\r
+ MemoryDatabaseManager.PcdPeimHString = PcdCommonHeaderString + pcdPeiDatabase.getHString() + \r
+ PcdDatabase.getPcdPeiDatabaseDefinitions();\r
MemoryDatabaseManager.PcdPeimCString = pcdPeiDatabase.getCString();\r
\r
- PcdDatabase pcdDxeDatabase = new PcdDatabase (alDxe, \r
- "DXE",\r
- alPei.size()\r
- );\r
+ PcdDatabase pcdDxeDatabase = new PcdDatabase(alDxe, "DXE", alPei.size());\r
pcdDxeDatabase.genCode();\r
- MemoryDatabaseManager.PcdDxeHString = MemoryDatabaseManager.PcdPeimHString + pcdDxeDatabase.getHString()\r
- + PcdDatabase.getPcdDxeDatabaseDefinitions();\r
+ MemoryDatabaseManager.PcdDxeHString = MemoryDatabaseManager.PcdPeimHString + pcdDxeDatabase.getHString() + \r
+ PcdDatabase.getPcdDxeDatabaseDefinitions();\r
MemoryDatabaseManager.PcdDxeCString = pcdDxeDatabase.getCString();\r
}\r
\r
*/\r
private List<ModuleInfo> getComponentsFromFPD() \r
throws EntityException {\r
- List<ModuleInfo> allModules = new ArrayList<ModuleInfo>();\r
- ModuleInfo current = null;\r
- int index = 0;\r
- FrameworkModulesDocument.FrameworkModules fModules = null;\r
- ModuleSADocument.ModuleSA[] modules = null;\r
- HashMap<String, XmlObject> map = new HashMap<String, XmlObject>();\r
-\r
- if (fpdDocInstance == null) {\r
- try {\r
- fpdDocInstance = (PlatformSurfaceAreaDocument)XmlObject.Factory.parse(new File(fpdFilePath));\r
- } catch(IOException ioE) {\r
- throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage());\r
- } catch(XmlException xmlE) {\r
- throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage());\r
- }\r
+ List<ModuleInfo> allModules = new ArrayList<ModuleInfo>();\r
+ FrameworkModulesDocument.FrameworkModules fModules = null;\r
+ ModuleSADocument.ModuleSA[] modules = null;\r
+ Map<FpdModuleIdentification, XmlObject> pcdBuildDefinitions = null;\r
\r
+ pcdBuildDefinitions = GlobalData.getFpdPcdBuildDefinitions();\r
+ if (pcdBuildDefinitions == null) {\r
+ return null;\r
}\r
\r
- Map<FpdModuleIdentification,XmlObject>pcdBuildDef = GlobalData.getFpdModuleSaXmlObject(CollectPCDAction.xmlObjectName);\r
- Set<FpdModuleIdentification> pcdBuildKeySet = pcdBuildDef.keySet();\r
- Iterator item = pcdBuildKeySet.iterator();\r
+ //\r
+ // Loop map to retrieve all PCD build definition and Module id \r
+ // \r
+ Iterator item = pcdBuildDefinitions.keySet().iterator();\r
while (item.hasNext()){\r
- FpdModuleIdentification id = (FpdModuleIdentification)item.next();\r
- allModules.add(new ModuleInfo(id, id.getModule().getModuleType(),pcdBuildDef.get(id))); \r
+ FpdModuleIdentification id = (FpdModuleIdentification) item.next();\r
+ allModules.add(new ModuleInfo(id, pcdBuildDefinitions.get(id))); \r
}\r
\r
return allModules;\r
// -------------------------------------------------------------------\r
// \r
for (index = 0; index < modules.size(); index ++) {\r
- isDuplicate = false;\r
- for (index2 = 0; index2 < index; index2 ++) {\r
- //\r
- // BUGBUG: For transition schema, we can *not* get module's version from \r
- // <ModuleSAs>, It is work around code.\r
- // \r
- primaryKey1 = UsageInstance.getPrimaryKey(modules.get(index).getModuleId().getModule().getName(), \r
- null,\r
- null,\r
- null, \r
- modules.get(index).getModuleId().getArch(),\r
- null);\r
- primaryKey2 = UsageInstance.getPrimaryKey(modules.get(index2).getModuleId().getModule().getName(), \r
- null, \r
- null, \r
- null, \r
- modules.get(index2).getModuleId().getArch(), \r
- null);\r
- if (primaryKey1.equalsIgnoreCase(primaryKey2)) {\r
- isDuplicate = true;\r
- break;\r
- }\r
- }\r
-\r
- if (isDuplicate) {\r
- continue;\r
- }\r
-\r
//\r
// It is legal for a module does not contains ANY pcd build definitions.\r
// \r
throw new EntityException ("Fail to get Token space guid for token" + pcdBuildData.getCName());\r
} \r
\r
- primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(),\r
- translateSchemaStringToUUID(tokenSpaceStrRet[1]));\r
+ primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(), tokenSpaceStrRet[1]);\r
pcdType = Token.getpcdTypeFromString(pcdBuildData.getItemType().toString());\r
datumType = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString());\r
tokenNumber = Long.decode(pcdBuildData.getToken().toString());\r
throw new EntityException("Fail to get token space guid for token " + token.cName);\r
}\r
\r
- token = new Token(pcdBuildData.getCName(), \r
- translateSchemaStringToUUID(tokenSpaceStrRet[1]));\r
+ token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]);\r
\r
token.datumType = datumType;\r
token.tokenNumber = tokenNumber;\r
// ------------------------------------------------\r
// \r
usageInstance = new UsageInstance(token, \r
- moduleName, \r
- null,\r
- null,\r
- null,\r
- CommonDefinition.getModuleType(modules.get(index).getModuleType()), \r
+ modules.get(index).getModuleId().getModule(), \r
pcdType,\r
modules.get(index).getModuleId().getArch(), \r
- null,\r
datum,\r
maxDatumSize);\r
token.addUsageInstance(usageInstance);\r
String variableGuidString[];\r
\r
//\r
- // If FPD document is not be opened, open and initialize it.\r
+ // Open fpd document to get <DynamicPcdBuildDefinition> Section.\r
+ // BUGBUG: the function should be move GlobalData in furture.\r
// \r
if (fpdDocInstance == null) {\r
try {\r
} \r
\r
primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(),\r
- translateSchemaStringToUUID(tokenSpaceStrRet[1]));\r
+ tokenSpaceStrRet[1]);\r
\r
if (dbManager.isTokenInDatabase(primaryKey)) {\r
continue;\r
//\r
// Create new token for unreference dynamic PCD token\r
// \r
- token = new Token(pcdBuildData.getCName(), translateSchemaStringToUUID(tokenSpaceStrRet[1]));\r
+ token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]);\r
token.datumSize = pcdBuildData.getMaxDatumSize();\r
\r
\r
\r
//\r
// If FPD document is not be opened, open and initialize it.\r
+ // BUGBUG: The code should be moved into GlobalData in future.\r
// \r
if (fpdDocInstance == null) {\r
try {\r
}\r
\r
dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(),\r
- translateSchemaStringToUUID(tokenSpaceStrRet[1]));\r
+ tokenSpaceStrRet[1]);\r
if (dynamicPrimaryKey.equalsIgnoreCase(token.getPrimaryKeyString())) {\r
return dynamicPcdBuildDataArray.get(index);\r
}\r
import org.apache.xmlbeans.XmlObject;\r
import org.tianocore.build.global.GlobalData;\r
import org.tianocore.build.global.SurfaceAreaQuery;\r
+import org.tianocore.build.id.ModuleIdentification;\r
import org.tianocore.build.pcd.entity.MemoryDatabaseManager;\r
import org.tianocore.build.pcd.entity.Token;\r
import org.tianocore.build.pcd.entity.UsageInstance;\r
///\r
private MemoryDatabaseManager dbManager;\r
///\r
- /// The name of module which is analysised currently.\r
- ///\r
- private String moduleName;\r
- ///\r
- /// The Guid of module which is analyzed currently.\r
- /// \r
- private UUID moduleGuid;\r
- ///\r
- /// The name of package whose module is analysized currently.\r
+ /// The identification for a module.\r
/// \r
- private String packageName;\r
- ///\r
- /// The Guid of package whose module is analyszed curretnly.\r
- /// \r
- private UUID packageGuid;\r
+ private ModuleIdentification moduleId;\r
///\r
/// The arch of current module\r
/// \r
private String arch;\r
///\r
- /// The version of current module\r
- /// \r
- private String version;\r
- ///\r
/// Whether current autogen is for building library used by current module.\r
/// \r
private boolean isBuildUsedLibrary;\r
///\r
/// The name array of <PcdCoded> in a module.\r
/// \r
- private String[] pcdNameArray;\r
+ private String[] pcdNameArrayInMsa;\r
/**\r
- Set parameter ModuleName\r
+ Set parameter moduleId\r
\r
@param moduleName the module name parameter.\r
**/\r
- public void setModuleName(String moduleName) {\r
- this.moduleName = moduleName;\r
- }\r
-\r
- /**\r
- set the moduleGuid parameter.\r
- \r
- @param moduleGuid\r
- **/\r
- public void setModuleGuid(UUID moduleGuid) {\r
- this.moduleGuid = moduleGuid;\r
- }\r
-\r
- /**\r
- set packageName parameter.\r
- \r
- @param packageName\r
- **/\r
- public void setPackageName(String packageName) {\r
- this.packageName = packageName;\r
- }\r
-\r
- /**\r
- set packageGuid parameter.\r
- \r
- @param packageGuid\r
- **/\r
- public void setPackageGuid(UUID packageGuid) {\r
- this.packageGuid = packageGuid;\r
+ public void setModuleId(ModuleIdentification moduleId) {\r
+ this.moduleId = moduleId;\r
}\r
\r
/**\r
this.arch = arch;\r
}\r
\r
- /**\r
- set version parameter\r
- \r
- @param version\r
- */\r
- public void setVersion(String version) {\r
- this.version = version;\r
- }\r
-\r
/**\r
set isBuildUsedLibrary parameter.\r
\r
@param isBuildUsedLibrary\r
- */\r
+ **/\r
public void setIsBuildUsedLibrary(boolean isBuildUsedLibrary) {\r
this.isBuildUsedLibrary = isBuildUsedLibrary;\r
}\r
+\r
/**\r
- set pcdNameArray parameter.\r
+ set pcdNameArrayInMsa parameter.\r
\r
- @param pcdNameArray\r
+ @param pcdNameArrayInMsa\r
*/\r
- public void setPcdNameArray(String[] pcdNameArray) {\r
- this.pcdNameArray = pcdNameArray;\r
+ public void setPcdNameArrayInMsa(String[] pcdNameArrayInMsa) {\r
+ this.pcdNameArrayInMsa = pcdNameArrayInMsa;\r
}\r
\r
/**\r
return cAutoGenString;\r
}\r
\r
-// /**\r
-// Construct function\r
-// \r
-// This function mainly initialize some member variable.\r
-// \r
-// @param moduleName Parameter of this action class.\r
-// @param isEmulatedPCDDriver Parameter of this action class.\r
-// **/\r
-// public PCDAutoGenAction(String moduleName, \r
-// UUID moduleGuid, \r
-// String packageName,\r
-// UUID packageGuid,\r
-// String arch,\r
-// String version,\r
-// boolean isBuildUsedLibrary,\r
-// String[] pcdNameArray) {\r
-// dbManager = null;\r
-// hAutoGenString = "";\r
-// cAutoGenString = "";\r
-//\r
-// setModuleName(moduleName);\r
-// setModuleGuid(moduleGuid);\r
-// setPackageName(packageName);\r
-// setPackageGuid(packageGuid);\r
-// setPcdNameArray(pcdNameArray);\r
-// setArch(arch);\r
-// setVersion(version);\r
-// setIsBuildUsedLibrary(isBuildUsedLibrary);\r
-// }\r
-\r
- \r
+ \r
/**\r
- Construct function\r
+ Construct function\r
\r
- This function mainly initialize some member variable.\r
+ This function mainly initialize some member variable.\r
\r
- @param moduleName Parameter of this action class.\r
- @param isEmulatedPCDDriver Parameter of this action class.\r
- **/\r
- public PCDAutoGenAction(String moduleName, \r
- String moduleGuidString, \r
- String packageName,\r
- String packageGuidString,\r
- String arch,\r
- String version,\r
- boolean isBuildUsedLibrary,\r
- String[] pcdNameArray) \r
- throws BuildActionException {\r
- dbManager = null;\r
- hAutoGenString = "";\r
- cAutoGenString = "";\r
- try {\r
- setModuleName(moduleName);\r
- setModuleGuid(translateSchemaStringToUUID(moduleGuidString));\r
- setPackageName(packageName);\r
- setPackageGuid(translateSchemaStringToUUID(packageGuidString));\r
- setPcdNameArray(pcdNameArray);\r
- setArch(arch);\r
- setVersion(version);\r
- setIsBuildUsedLibrary(isBuildUsedLibrary);\r
- } catch (EntityException e){\r
- throw new BuildActionException(e.getMessage());\r
- }\r
- }\r
-\r
- /**\r
- Translate the schema string to UUID instance.\r
- \r
- In schema, the string of UUID is defined as following two types string:\r
- 1) GuidArrayType: pattern = 0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},(\r
- )*0x[a-fA-F0-9]{1,4}(,( )*\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\})?\r
- \r
- 2) GuidNamingConvention: pattern =\r
- [a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\r
- \r
- This function will convert string and create uuid instance.\r
- \r
- @param uuidString UUID string in XML file\r
- \r
- @return UUID UUID instance\r
-**/\r
-private UUID translateSchemaStringToUUID(String uuidString) \r
- throws EntityException {\r
- String temp;\r
- String[] splitStringArray;\r
- int index;\r
- int chIndex;\r
- int chLen;\r
-\r
- if (uuidString == null) {\r
- return null;\r
- }\r
-\r
- if (uuidString.length() == 0) {\r
- return null;\r
- }\r
-\r
- if (uuidString.equals("0") ||\r
- uuidString.equalsIgnoreCase("0x0")) {\r
- return new UUID(0, 0);\r
- }\r
-\r
- uuidString = uuidString.replaceAll("\\{", "");\r
- uuidString = uuidString.replaceAll("\\}", "");\r
-\r
- //\r
- // If the UUID schema string is GuidArrayType type then need translate \r
- // to GuidNamingConvention type at first.\r
- // \r
- if ((uuidString.charAt(0) == '0') && ((uuidString.charAt(1) == 'x') || (uuidString.charAt(1) == 'X'))) {\r
- splitStringArray = uuidString.split("," );\r
- if (splitStringArray.length != 11) {\r
- throw new EntityException ("[FPD file error] Wrong format for UUID string: " + uuidString);\r
- }\r
-\r
- //\r
- // Remove blank space from these string and remove header string "0x"\r
- // \r
- for (index = 0; index < 11; index ++) {\r
- splitStringArray[index] = splitStringArray[index].trim();\r
- splitStringArray[index] = splitStringArray[index].substring(2, splitStringArray[index].length());\r
- }\r
-\r
- //\r
- // Add heading '0' to normalize the string length\r
- // \r
- for (index = 3; index < 11; index ++) {\r
- chLen = splitStringArray[index].length();\r
- for (chIndex = 0; chIndex < 2 - chLen; chIndex ++) {\r
- splitStringArray[index] = "0" + splitStringArray[index];\r
- }\r
- }\r
-\r
- //\r
- // construct the final GuidNamingConvention string\r
- // \r
- temp = String.format("%s-%s-%s-%s%s-%s%s%s%s%s%s",\r
- splitStringArray[0],\r
- splitStringArray[1],\r
- splitStringArray[2],\r
- splitStringArray[3],\r
- splitStringArray[4],\r
- splitStringArray[5],\r
- splitStringArray[6],\r
- splitStringArray[7],\r
- splitStringArray[8],\r
- splitStringArray[9],\r
- splitStringArray[10]);\r
- uuidString = temp;\r
- }\r
-\r
- return UUID.fromString(uuidString);\r
- }\r
- \r
+ @param moduleId the identification for module\r
+ @param arch the architecture for module\r
+ @param isBuildUsedLibary Is the current module library.\r
+ @param pcdNameArrayInMsa the pcd name array got from MSA file.\r
+ **/\r
+ public PCDAutoGenAction(ModuleIdentification moduleId, \r
+ String arch,\r
+ boolean isBuildUsedLibrary,\r
+ String[] pcdNameArrayInMsa) {\r
+ dbManager = null;\r
+ hAutoGenString = "";\r
+ cAutoGenString = "";\r
+\r
+ setModuleId(moduleId);\r
+ setArch(arch);\r
+ setIsBuildUsedLibrary(isBuildUsedLibrary);\r
+ setPcdNameArrayInMsa(pcdNameArrayInMsa);\r
+ }\r
+\r
/**\r
check the parameter for action class.\r
\r
ActionMessage.debug(this,\r
"PCD memory database contains " + dbManager.getDBSize() + " PCD tokens");\r
\r
-\r
-\r
generateAutogenForModule();\r
}\r
\r
String[] guidStringArray = null;\r
String guidStringCName = null;\r
String guidString = null;\r
+ String moduleName = moduleId.getName();\r
UsageInstance usageInstance = null;\r
boolean found = false;\r
\r
usageInstanceArray = null;\r
if (!isBuildUsedLibrary) {\r
- usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleName,\r
- moduleGuid,\r
- packageName,\r
- packageGuid,\r
- arch,\r
- version);\r
+ usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleId, arch);\r
dbManager.UsageInstanceContext = usageInstanceArray;\r
dbManager.CurrentModuleName = moduleName; \r
- } else if ((pcdNameArray != null) && (pcdNameArray.length > 0)) {\r
+ } else if ((pcdNameArrayInMsa != null) && (pcdNameArrayInMsa.length > 0)) {\r
usageContext = dbManager.UsageInstanceContext;\r
//\r
// For building library package, although all module are library, but PCD entries of \r
// these library should be used to autogen.\r
// \r
if (usageContext == null) {\r
- usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleName,\r
- moduleGuid,\r
- packageName,\r
- packageGuid,\r
- arch,\r
- version);\r
+ usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleId, arch);\r
} else {\r
usageInstanceArray = new ArrayList<UsageInstance>();\r
\r
// Try to find all PCD defined in library's PCD in all <PcdEntry> in module's \r
// <ModuleSA> in FPD file.\r
// \r
- for (index = 0; index < pcdNameArray.length; index++) {\r
+ for (index = 0; index < pcdNameArrayInMsa.length; index++) {\r
found = false;\r
for (index2 = 0; index2 < usageContext.size(); index2 ++) {\r
- if (pcdNameArray[index].equalsIgnoreCase(usageContext.get(index2).parentToken.cName)) {\r
+ if (pcdNameArrayInMsa[index].equalsIgnoreCase(usageContext.get(index2).parentToken.cName)) {\r
usageInstanceArray.add(usageContext.get(index2));\r
found = true;\r
break;\r
"it in the %s's <ModuleSA> in FPD file!",\r
dbManager.CurrentModuleName,\r
moduleName,\r
- pcdNameArray[index],\r
+ pcdNameArrayInMsa[index],\r
dbManager.CurrentModuleName\r
));\r
}\r
// Generate all PCD entry for a module.\r
// \r
for(index = 0; index < usageInstanceArray.size(); index ++) {\r
- ActionMessage.debug(this,\r
- "Module " + moduleName + "'s PCD [" + Integer.toHexString(index) + \r
- "]: " + usageInstanceArray.get(index).parentToken.cName);\r
- try {\r
- usageInstance = usageInstanceArray.get(index);\r
+ usageInstance = usageInstanceArray.get(index);\r
+ //\r
+ // Before generate any PCD information into autogen.h/autogen.c for a module,\r
+ // generate TokenSpaceGuid array variable firstly. For every dynamicEx type\r
+ // PCD in this module the token, they are all reference to TokenSpaceGuid \r
+ // array.\r
+ // \r
+ if (usageInstanceArray.get(index).modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
+ guidStringArray = usageInstance.parentToken.tokenSpaceName.split("-");\r
+ guidStringCName = "_gPcd_TokenSpaceGuid_" + \r
+ usageInstance.parentToken.tokenSpaceName.replaceAll("-", "_");\r
+ guidString = String.format("{ 0x%s, 0x%s, 0x%s, {0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s}}",\r
+ guidStringArray[0],\r
+ guidStringArray[1],\r
+ guidStringArray[2],\r
+ (guidStringArray[3].substring(0, 2)),\r
+ (guidStringArray[3].substring(2, 4)),\r
+ (guidStringArray[4].substring(0, 2)),\r
+ (guidStringArray[4].substring(2, 4)),\r
+ (guidStringArray[4].substring(4, 6)),\r
+ (guidStringArray[4].substring(6, 8)),\r
+ (guidStringArray[4].substring(8, 10)),\r
+ (guidStringArray[4].substring(10, 12)));\r
+ \r
+ Pattern pattern = Pattern.compile("(" + guidStringCName + ")+?");\r
+ Matcher matcher = pattern.matcher(cAutoGenString + " ");\r
//\r
- // Before generate any PCD information into autogen.h/autogen.c for a module,\r
- // generate TokenSpaceGuid array variable firstly. For every dynamicEx type\r
- // PCD in this module the token, they are all reference to TokenSpaceGuid \r
- // array.\r
+ // Find whether this guid array variable has been generated into autogen.c\r
+ // For different DyanmicEx pcd token who use same token space guid, the token space\r
+ // guid array should be only generated once.\r
// \r
- if (usageInstanceArray.get(index).modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
- guidStringArray = usageInstance.parentToken.tokenSpaceName.toString().split("-");\r
- guidStringCName = "_gPcd_TokenSpaceGuid_" + \r
- usageInstance.parentToken.tokenSpaceName.toString().replaceAll("-", "_");\r
- guidString = String.format("{ 0x%s, 0x%s, 0x%s, {0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s}}",\r
- guidStringArray[0],\r
- guidStringArray[1],\r
- guidStringArray[2],\r
- (guidStringArray[3].substring(0, 2)),\r
- (guidStringArray[3].substring(2, 4)),\r
- (guidStringArray[4].substring(0, 2)),\r
- (guidStringArray[4].substring(2, 4)),\r
- (guidStringArray[4].substring(4, 6)),\r
- (guidStringArray[4].substring(6, 8)),\r
- (guidStringArray[4].substring(8, 10)),\r
- (guidStringArray[4].substring(10, 12)));\r
- \r
- Pattern pattern = Pattern.compile("(" + guidStringCName + ")+?");\r
- Matcher matcher = pattern.matcher(cAutoGenString + " ");\r
- //\r
- // Find whether this guid array variable has been generated into autogen.c\r
- // For different DyanmicEx pcd token who use same token space guid, the token space\r
- // guid array should be only generated once.\r
- // \r
- if (!matcher.find()) {\r
- hAutoGenString += String.format("extern EFI_GUID %s;\r\n",\r
- guidStringCName);\r
- if (!isBuildUsedLibrary) {\r
- cAutoGenString += String.format("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID %s = %s;\r\n",\r
- guidStringCName,\r
- guidString);\r
- } \r
- }\r
+ if (!matcher.find()) {\r
+ hAutoGenString += String.format("extern EFI_GUID %s;\r\n",\r
+ guidStringCName);\r
+ if (!isBuildUsedLibrary) {\r
+ cAutoGenString += String.format("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID %s = %s;\r\n",\r
+ guidStringCName,\r
+ guidString);\r
+ } \r
}\r
-\r
- usageInstance.generateAutoGen(isBuildUsedLibrary);\r
- //\r
- // For every PCD entry for this module(usage instance), autogen string would\r
- // be appand.\r
- // \r
- hAutoGenString += usageInstance.getHAutogenStr() + "\r\n";\r
- cAutoGenString += usageInstance.getCAutogenStr();\r
-\r
- } catch(EntityException exp) {\r
- throw new BuildActionException("[PCD Autogen Error]: " + exp.getMessage());\r
}\r
+\r
+ usageInstance.generateAutoGen(isBuildUsedLibrary);\r
+ //\r
+ // For every PCD entry for this module(usage instance), autogen string would\r
+ // be appand.\r
+ // \r
+ hAutoGenString += usageInstance.getHAutogenStr() + "\r\n";\r
+ cAutoGenString += usageInstance.getCAutogenStr();\r
}\r
\r
//\r
hAutoGenString += dbManager.PcdDxeHString;\r
cAutoGenString += dbManager.PcdDxeCString;\r
}\r
-\r
- ActionMessage.debug(this,\r
- "Module " + moduleName + "'s PCD header file:\r\n" + hAutoGenString + "\r\n"\r
- );\r
- ActionMessage.debug(this,\r
- "Module " + moduleName + "'s PCD C file:\r\n" + cAutoGenString + "\r\n"\r
- );\r
}\r
\r
/**\r
} catch(Exception e) {\r
e.printStackTrace();\r
}\r
-\r
- //\r
- // Then execute the PCDAuotoGenAction to get generated Autogen.h and Autogen.c\r
- //\r
-// PCDAutoGenAction autogenAction = new PCDAutoGenAction("MonoStatusCode",\r
-// null,\r
-// null,\r
-// null,\r
-// "IA32",\r
-// null,\r
-// false,\r
-// nameArray);\r
-// autogenAction.execute();\r
-//\r
-// System.out.println(autogenAction.OutputH());\r
-// System.out.println("WQWQWQWQWQ");\r
-// System.out.println(autogenAction.OutputC());\r
}\r
}\r
return str;\r
}\r
\r
- /**\r
- Get UINT16 array which use string to express a number.\r
- \r
- @return String\r
- */\r
- public String getStringArrayOfVariableName() {\r
- String strArray;\r
- int index;\r
-\r
- strArray = "{";\r
- for (index = 0; index < variableName.size(); index ++) {\r
- strArray += variableName.get(index).toString();\r
- if (index != (variableName.size() - 1)) {\r
- strArray += ",";\r
- }\r
- }\r
- strArray += "}";\r
- return strArray;\r
- }\r
-\r
/**\r
Set Vpd case data.\r
\r
import java.util.Map;\r
import java.util.UUID;\r
\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
/// 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
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
+ @throws EntityException\r
**/\r
public void getTwoPhaseDynamicRecordArray(ArrayList<Token> pei, ArrayList<Token> dxe) \r
throws EntityException {\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("Dynamic(EX) PCD Entries are referenced in module that is not in PEI phase nor in DXE phase.");\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
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
import java.util.Map;\r
import java.util.UUID;\r
\r
+import org.tianocore.build.id.ModuleIdentification;\r
import org.tianocore.build.pcd.exception.EntityException;\r
\r
/** This class is to descript a PCD token object. The information of a token mainly \r
/// assignedtokenSpaceName as follows.\r
/// tokenSpaceName is defined in MSA, SPD, FPD, can be regarded as primary key with cName.\r
///\r
- public UUID tokenSpaceName;\r
+ public String tokenSpaceName;\r
\r
///\r
/// tokenNumber is allocated by platform. tokenNumber indicate an index for this token in\r
/// platform token space. For Dynamic, dynamicEx type, this number will be re-adjust by\r
/// PCD run-time database autogen tools.\r
///\r
- public long tokenNumber;\r
+ public long tokenNumber;\r
\r
///\r
/// This token number is retrieved from FPD file for DynamicEx type. \r
/// \r
- public long dynamicExTokenNumber;\r
+ public long dynamicExTokenNumber;\r
\r
///\r
/// All supported PCD type, this value can be retrieved from SPD\r
///\r
public Map<String, UsageInstance> consumers;\r
\r
- public Token(String cName, UUID tokenSpaceName) {\r
+ /**\r
+ Constructure function for Token class\r
+ \r
+ @param cName The name of token\r
+ @param tokenSpaceName The name of token space, it is a guid string\r
+ **/\r
+ public Token(String cName, String tokenSpaceName) {\r
UUID nullUUID = new UUID(0, 0);\r
\r
this.cName = cName;\r
- this.tokenSpaceName = (tokenSpaceName == null) ? nullUUID : tokenSpaceName;\r
+ this.tokenSpaceName = tokenSpaceName;\r
this.tokenNumber = 0;\r
this.datumType = DATUM_TYPE.UNKNOWN;\r
this.datumSize = -1;\r
@param pcdType new PCD type found in FPD file for this token.\r
**/\r
public void updateSupportPcdType(PCD_TYPE pcdType) {\r
- int index = 0;\r
- boolean found = false;\r
- for (index = 0; index < this.supportedPcdType.size(); index ++) {\r
- if (this.supportedPcdType.get(index) == pcdType) {\r
- found = true;\r
- break;\r
+ for (int index = 0; index < this.supportedPcdType.size(); index ++) {\r
+ if (supportedPcdType.get(index) == pcdType) {\r
+ return;\r
}\r
}\r
- if (!found) {\r
- this.supportedPcdType.add(pcdType);\r
- }\r
+\r
+ //\r
+ // If not found, add the pcd type to member variable supportedPcdType\r
+ // \r
+ supportedPcdType.add(pcdType);\r
}\r
\r
/**\r
Judge whether pcdType is belong to dynamic type. Dynamic type includes\r
DYNAMIC and DYNAMIC_EX.\r
\r
- @param pcdType\r
+ @param pcdType the judged pcd type\r
\r
@return boolean\r
*/\r
}\r
\r
public boolean isDynamicEx() {\r
- \r
for (int i = 0; i < supportedPcdType.size(); i++) {\r
if (supportedPcdType.get(i) == PCD_TYPE.DYNAMIC_EX) {\r
return true;\r
Use "TokencName + "-" + SpaceTokenName" as primary key when adding token into database\r
\r
@param cName Token name.\r
- @param tokenSpaceName The token space guid defined in MSA or SPD\r
- @param platformtokenSpaceName The token space guid for current platform token space,\r
+ @param tokenSpaceName The token space guid string defined in MSA or SPD\r
\r
- @return primary key for this token in token database.\r
+ @retval primary key for this token in token database.\r
**/\r
- public static String getPrimaryKeyString(String cName, UUID tokenSpaceName) {\r
- UUID nullUUID = new UUID(0, 0);\r
-\r
+ public static String getPrimaryKeyString(String cName, String tokenSpaceName) {\r
if (tokenSpaceName == null) {\r
- return cName + "_" + nullUUID.toString().replace('-', '_');\r
+ return cName + "_nullTokenSpaceGuid";\r
} else {\r
return cName + "_" + tokenSpaceName.toString().replace('-', '_');\r
}\r
/**\r
If skudata list contains more than one data, then Sku mechanism is enable.\r
\r
- @return boolean\r
+ @retval boolean if the number of sku data exceed to 1\r
*/\r
public boolean isSkuEnable() {\r
if (this.skuData.size() > 1) {\r
}\r
return false;\r
}\r
- \r
+\r
+ /**\r
+ If Hii type for value of token\r
+ \r
+ @return boolean\r
+ **/\r
public boolean isHiiEnable() {\r
if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.HII_TYPE) {\r
return true;\r
return false;\r
}\r
\r
+ /**\r
+ If Vpd type for value of token\r
+ \r
+ @return boolean\r
+ **/\r
public boolean isVpdEnable() {\r
if (getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {\r
return true;\r
@retval TRUE - Success to add usage instance.\r
@retval FALSE - Fail to add usage instance\r
**/\r
- public boolean addUsageInstance(UsageInstance usageInstance) \r
- throws EntityException {\r
+ public boolean addUsageInstance(UsageInstance usageInstance) throws EntityException {\r
String exceptionStr;\r
\r
- if (isUsageInstanceExist(usageInstance.moduleName,\r
- usageInstance.moduleGUID,\r
- usageInstance.packageName,\r
- usageInstance.packageGUID,\r
- usageInstance.arch,\r
- usageInstance.version)) {\r
- exceptionStr = String.format("PCD %s for module %s has already exist in database, Please check all PCD build entries "+\r
- "in modules %s in <ModuleSA> to make sure no duplicated definitions!",\r
+ if (isUsageInstanceExist(usageInstance.moduleId, usageInstance.arch)) {\r
+ exceptionStr = String.format("[PCD Collection Tool Exception] PCD %s for module %s has already exist in database, Please check all PCD build entries "+\r
+ "in modules %s in <ModuleSA> to make sure no duplicated definitions in FPD file!",\r
usageInstance.parentToken.cName,\r
- usageInstance.moduleName,\r
- usageInstance.moduleName);\r
+ usageInstance.moduleId.getName(),\r
+ usageInstance.moduleId.getName());\r
throw new EntityException(exceptionStr);\r
}\r
\r
+ //\r
+ // Put usage instance into usage instance database of this PCD token.\r
+ // \r
consumers.put(usageInstance.getPrimaryKey(), usageInstance);\r
+\r
return true;\r
}\r
\r
/**\r
Judge whether exist an usage instance for this token\r
\r
- @param moduleName the name of module\r
- @param moduleGuid the GUID name of modules\r
- @param packageName the name of package contains this module\r
- @param packageGuid the GUID name of package contains this module\r
+ @param moduleId The module identification for usage instance\r
@param arch the architecture string\r
- @param version the version string\r
\r
@return boolean whether exist an usage instance for this token.\r
*/\r
- public boolean isUsageInstanceExist(String moduleName,\r
- UUID moduleGuid,\r
- String packageName,\r
- UUID packageGuid,\r
- String arch,\r
- String version) {\r
- String keyStr = UsageInstance.getPrimaryKey(moduleName, \r
- moduleGuid, \r
- packageName, \r
- packageGuid, \r
- arch, \r
- version);\r
+ public boolean isUsageInstanceExist(ModuleIdentification moduleId,\r
+ String arch) {\r
+ String keyStr = UsageInstance.getPrimaryKey(moduleId, arch);\r
+\r
return (consumers.get(keyStr) != null);\r
}\r
\r
}\r
\r
/**\r
- UUID defined in Schems is object, this function is to tranlate this object \r
- to UUID data.\r
- \r
- @param uuidObj The object comes from schema.\r
- \r
- @return The traslated UUID instance.\r
+ Get the sku data who id is 0.\r
+ \r
+ @retval DynamicTokenValue the value of this dyanmic token.\r
**/\r
- public static UUID getGUIDFromSchemaObject(Object uuidObj) {\r
- UUID uuid;\r
- if (uuidObj.toString().equalsIgnoreCase("0")) {\r
- uuid = new UUID(0,0);\r
- } else {\r
- uuid = UUID.fromString(uuidObj.toString());\r
- }\r
-\r
- return uuid;\r
- }\r
-\r
public DynamicTokenValue getDefaultSku() {\r
DynamicTokenValue dynamicData;\r
int index;\r
+\r
for (index = 0; index < this.skuData.size(); index ++) {\r
if (skuData.get(index).id == 0) {\r
return skuData.get(index).value;\r
\r
return null;\r
}\r
- \r
+\r
+ /**\r
+ Get the number of Sku data for this token\r
+ \r
+ @retval int the number of sku data\r
+ **/\r
public int getSkuIdCount () {\r
return this.skuData.size();\r
}\r
\r
+ /**\r
+ Get the size of PCD value, this PCD is POINTER type.\r
+ \r
+ @param str the string of the value\r
+ @param al \r
+ **/\r
private void getCurrentSizeFromDefaultValue (String str, ArrayList<Integer> al) {\r
if (isValidNullValue(str)) {\r
al.add(new Integer(0));\r
}\r
}\r
}\r
- //\r
- // This method can be used to get the MAX and current size\r
- // for pointer type dynamic(ex) PCD entry\r
- //\r
+\r
+ /**\r
+ This method can be used to get the MAX and current size\r
+ for pointer type dynamic(ex) PCD entry\r
+ **/ \r
public ArrayList<Integer> getPointerTypeSize () {\r
ArrayList<Integer> al = new ArrayList<Integer>();\r
\r
return false;\r
}\r
\r
+ /**\r
+ Judge the value is NULL value. NULL value means the value is uninitialized value\r
+ \r
+ @param judgedValue\r
+ \r
+ @return boolean\r
+ */\r
public boolean isValidNullValue(String judgedValue) {\r
String subStr;\r
BigInteger bigIntValue;\r
}\r
return false;\r
}\r
- \r
+\r
+ /**\r
+ Is the string value in Unicode\r
+ \r
+ @return boolean\r
+ **/\r
public boolean isHiiDefaultValueUnicodeStringType() {\r
DynamicTokenValue dynamicData = getDefaultSku();\r
\r
return dynamicData.hiiDefaultValue.startsWith("L\"")\r
&& dynamicData.hiiDefaultValue.endsWith("\"");\r
}\r
- \r
+\r
+ /**\r
+ Is the string value in ANSCI\r
+ \r
+ @return boolean\r
+ **/\r
public boolean isHiiDefaultValueASCIIStringType() {\r
DynamicTokenValue dynamicData = getDefaultSku();\r
\r
\r
\r
import java.util.UUID;\r
+\r
import org.tianocore.ModuleTypeDef;\r
import org.tianocore.build.autogen.CommonDefinition;\r
+import org.tianocore.build.id.ModuleIdentification;\r
import org.tianocore.build.pcd.exception.EntityException;\r
\r
/**\r
///\r
/// This parent that this usage instance belongs to.\r
///\r
- public Token parentToken;\r
+ public Token parentToken;\r
\r
///\r
- /// The name of the module who contains this PCD.\r
- ///\r
- public String moduleName;\r
-\r
- ///\r
- /// The GUID of the module who contains this PCD. \r
+ /// ModuleIdentification for Usage Instance\r
/// \r
- public UUID moduleGUID;\r
-\r
- ///\r
- /// The name of the package whose module contains this PCD.\r
- ///\r
- public String packageName;\r
+ public ModuleIdentification moduleId;\r
\r
///\r
- /// The GUID of the package whose module contains this PCD.\r
+ /// Arch also is a key for a UsageInstance\r
/// \r
- public UUID packageGUID;\r
+ public String arch;\r
\r
///\r
/// The PCD type defined for module \r
/// \r
- public Token.PCD_TYPE modulePcdType;\r
-\r
- ///\r
- /// The arch string of module contains this PCD\r
- ///\r
- public String arch;\r
-\r
- ///\r
- /// The version of module contains this PCD\r
- /// \r
- public String version;\r
-\r
- ///\r
- /// The module type for this usage instance.\r
- ///\r
- public int moduleType;\r
+ public Token.PCD_TYPE modulePcdType;\r
\r
///\r
/// The value of the PCD in this usage instance. \r
/// \r
- public String datum;\r
+ public String datum;\r
\r
///\r
/// The maxDatumSize could be different for same PCD in different module\r
/// But this case is allow for FeatureFlag, FixedAtBuild, PatchableInModule\r
/// type.\r
/// \r
- public int maxDatumSize;\r
+ public int maxDatumSize;\r
\r
///\r
/// Autogen string for header file.\r
///\r
- public String hAutogenStr;\r
+ public String hAutogenStr;\r
\r
///\r
/// Auotgen string for C code file.\r
/// \r
- public String cAutogenStr;\r
+ public String cAutogenStr;\r
\r
/**\r
- Constructure function\r
+ Constructure function for UsageInstance\r
\r
- @param parentToken Member variable.\r
- @param moduleName Member variable.\r
- @param moduleGUID Member variable.\r
- @param packageName Member variable.\r
- @param packageGUID Member variable.\r
- @param moduleType Member variable.\r
- @param modulePcdType Member variable.\r
- @param arch Member variable.\r
- @param version Member variable.\r
- @param value Member variable.\r
- @param maxDatumSize Member variable.\r
- */\r
- public UsageInstance (Token parentToken,\r
- String moduleName,\r
- UUID moduleGUID,\r
- String packageName,\r
- UUID packageGUID,\r
- int moduleType,\r
- Token.PCD_TYPE modulePcdType,\r
- String arch,\r
- String version,\r
- String value,\r
- int maxDatumSize) {\r
+ @param parentToken The token instance for this usgaInstance\r
+ @param id The identification for usage instance\r
+ @param modulePcdType The PCD type for this usage instance\r
+ @param value The value of this PCD in this usage instance\r
+ @param maxDatumSize The max datum size of this PCD in this usage\r
+ instance.\r
+ **/\r
+ public UsageInstance(Token parentToken,\r
+ ModuleIdentification moduleId,\r
+ Token.PCD_TYPE modulePcdType,\r
+ String arch,\r
+ String value,\r
+ int maxDatumSize) {\r
this.parentToken = parentToken;\r
- this.moduleName = moduleName;\r
- this.moduleGUID = moduleGUID;\r
- this.packageName = packageName;\r
- this.packageGUID = packageGUID;\r
- this.moduleType = moduleType;\r
+ this.moduleId = moduleId;\r
this.modulePcdType = modulePcdType;\r
this.arch = arch;\r
- this.version = version;\r
this.datum = value;\r
this.maxDatumSize = maxDatumSize;\r
}\r
/**\r
Get the primary key for usage instance array for every token.\r
\r
- @param moduleName the name of module\r
- @param moduleGUID the GUID name of module\r
- @param packageName the name of package who contains this module\r
- @param packageGUID the GUID name of package\r
- @param arch the archtecture string\r
- @param version the version of this module\r
+ @param moduleId The module Identification for generating primary key\r
+ @param arch Arch string\r
\r
- @return String primary key\r
- */\r
- public static String getPrimaryKey(String moduleName, \r
- UUID moduleGUID, \r
- String packageName, \r
- UUID packageGUID,\r
- String arch,\r
- String version) {\r
+ @retval String The primary key for this usage instance\r
+ **/\r
+ public static String getPrimaryKey(ModuleIdentification moduleId,\r
+ String arch) {\r
+ String moduleName = moduleId.getName();\r
+ String moduleGuid = moduleId.getGuid();\r
+ String packageName = moduleId.getPackage().getName();\r
+ String packageGuid = moduleId.getPackage().getGuid();\r
+ String version = moduleId.getVersion();\r
+\r
//\r
// Because currently transition schema not require write moduleGuid, package Name, Packge GUID in\r
// <ModuleSA> section, So currently no expect all paramter must be valid.\r
- return(moduleName + "_" +\r
- ((moduleGUID != null) ? moduleGUID.toString() : "NullModuleGuid") + "_" +\r
- ((packageName != null) ? packageName : "NullPackageName") + "_" +\r
- ((packageGUID != null) ? packageGUID.toString() : "NullPackageGuid") + "_" +\r
- ((arch != null) ? arch : "NullArch") + "_" +\r
- ((version != null) ? version : "NullVersion"));\r
+ // BUGBUG: Because currently we can not get version from MSA, So ignore verison.\r
+ // \r
+ return(moduleName + "_" +\r
+ ((moduleGuid != null) ? moduleGuid.toLowerCase() : "NullModuleGuid") + "_" +\r
+ ((packageName != null) ? packageName : "NullPackageName") + "_" +\r
+ ((packageGuid != null) ? packageGuid.toLowerCase() : "NullPackageGuid") + "_" +\r
+ ((arch != null) ? arch : "NullArch") + "_" +\r
+ "NullVersion");\r
}\r
\r
/**\r
@return String primary key string\r
**/\r
public String getPrimaryKey() {\r
- return UsageInstance.getPrimaryKey(moduleName, moduleGUID, packageName, packageGUID, arch, version);\r
+ return UsageInstance.getPrimaryKey(moduleId, arch);\r
}\r
\r
/**\r
Judget whether current module is PEI driver\r
\r
- @return boolean\r
- */\r
+ @return boolean whether current module is PEI driver\r
+ **/\r
public boolean isPeiPhaseComponent() {\r
+ int moduleType = CommonDefinition.getModuleType(moduleId.getModuleType());\r
+\r
if ((moduleType == CommonDefinition.ModuleTypePeiCore) ||\r
(moduleType == CommonDefinition.ModuleTypePeim)) {\r
return true;\r
}\r
return false;\r
}\r
- \r
- public boolean isDxePhaseComponent() {\r
- //\r
- // BugBug: May need confirmation on which type of module can\r
- // make use of Dynamic(EX) PCD entry.\r
- //\r
- if ((moduleType == CommonDefinition.ModuleTypeDxeDriver) ||\r
- (moduleType == CommonDefinition.ModuleTypeDxeRuntimeDriver) ||\r
- (moduleType == CommonDefinition.ModuleTypeDxeSalDriver) ||\r
- (moduleType == CommonDefinition.ModuleTypeDxeSmmDriver) ||\r
- (moduleType == CommonDefinition.ModuleTypeUefiDriver) ||\r
- (moduleType == CommonDefinition.ModuleTypeUefiApplication)\r
- ) {\r
- return true;\r
- }\r
- return false;\r
- }\r
\r
/**\r
- Generate autogen string for header file and C code file.\r
+ Judge whether current module is DXE driver.\r
\r
- @throws EntityException Fail to generate.\r
+ @return boolean whether current module is DXE driver\r
+ **/\r
+ public boolean isDxePhaseComponent() {\r
+ int moduleType = CommonDefinition.getModuleType(moduleId.getModuleType());\r
+\r
+ if ((moduleType == CommonDefinition.ModuleTypeDxeDriver) ||\r
+ (moduleType == CommonDefinition.ModuleTypeDxeRuntimeDriver) ||\r
+ (moduleType == CommonDefinition.ModuleTypeDxeSalDriver) ||\r
+ (moduleType == CommonDefinition.ModuleTypeDxeSmmDriver) ||\r
+ (moduleType == CommonDefinition.ModuleTypeUefiDriver) ||\r
+ (moduleType == CommonDefinition.ModuleTypeUefiApplication)\r
+ ) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ Generate autogen string for header file and C code file.\r
\r
@param isBuildUsedLibrary whether the autogen is for library.\r
- */\r
- public void generateAutoGen(boolean isBuildUsedLibrary) \r
- throws EntityException {\r
+ **/\r
+ public void generateAutoGen(boolean isBuildUsedLibrary) {\r
String guidStringCName = null;\r
boolean isByteArray = false;\r
String printDatum = null;\r
cAutogenStr = "";\r
\r
if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r
+ //\r
+ // For DYNAMIC_EX type PCD, use original token number in SPD or FPD to generate autogen\r
+ // \r
tokenNumberString = Long.toString(parentToken.dynamicExTokenNumber, 16);\r
} else {\r
+ //\r
+ // For Others type PCD, use autogenerated token number to generate autogen\r
+ // \r
tokenNumberString = Long.toString(parentToken.tokenNumber, 16);\r
}\r
\r
- hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%s\r\n", \r
- parentToken.cName, tokenNumberString);\r
- \r
+ hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%s\r\n", parentToken.cName, tokenNumberString);\r
+\r
+ //\r
+ // Judge the value of this PCD is byte array type\r
+ // \r
if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {\r
if (datum.trim().charAt(0) == '{') {\r
isByteArray = true;\r
}\r
}\r
\r
+ //\r
+ // "ULL" should be added to value's tail for UINT64 value\r
+ // \r
if (parentToken.datumType == Token.DATUM_TYPE.UINT64) {\r
printDatum = this.datum + "ULL";\r
} else {\r