import java.io.IOException;\r
import java.math.BigInteger;\r
import java.util.ArrayList;\r
+import java.util.Collections;\r
import java.util.Comparator;\r
import java.util.HashMap;\r
+import java.util.Iterator;\r
import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
import java.util.UUID;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
\r
import org.apache.xmlbeans.XmlException;\r
import org.apache.xmlbeans.XmlObject;\r
+import org.tianocore.DynamicPcdBuildDefinitionsDocument;\r
import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions;\r
+import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData;\r
+import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo;\r
import org.tianocore.FrameworkModulesDocument;\r
-import org.tianocore.FrameworkPlatformDescriptionDocument;\r
+import org.tianocore.PcdDeclarationsDocument;\r
+import org.tianocore.PlatformSurfaceAreaDocument;\r
+import org.tianocore.PcdBuildDefinitionDocument;\r
+import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;\r
import org.tianocore.ModuleSADocument;\r
+import org.tianocore.ModuleSADocument.ModuleSA;\r
+import org.tianocore.PackageSurfaceAreaDocument;\r
import org.tianocore.PcdBuildDefinitionDocument.PcdBuildDefinition;\r
+import org.tianocore.build.autogen.CommonDefinition;\r
import org.tianocore.build.global.GlobalData;\r
import org.tianocore.build.global.SurfaceAreaQuery;\r
+import org.tianocore.build.id.FpdModuleIdentification;\r
import org.tianocore.build.pcd.action.ActionMessage;\r
import org.tianocore.build.pcd.entity.DynamicTokenValue;\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
import org.tianocore.build.pcd.exception.EntityException;\r
+import org.tianocore.logger.EdkLog;\r
import org.tianocore.ModuleTypeDef;\r
\r
class CStructTypeDeclaration {\r
\r
Output.add("/* GuidTable */");\r
Output.add("{");\r
+\r
if (al.size() == 0) {\r
Output.add("\t" + getUuidCString(new UUID(0, 0)));\r
}\r
}\r
\r
class ModuleInfo {\r
- public ModuleSADocument.ModuleSA module;\r
- public ModuleTypeDef.Enum type;\r
+ private String type;\r
+ private FpdModuleIdentification moduleId;\r
+ private PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef;\r
+ \r
+ \r
\r
- public ModuleInfo (ModuleSADocument.ModuleSA module, ModuleTypeDef.Enum type) {\r
- this.module = module;\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
+ }\r
+ public FpdModuleIdentification getModuleId (){\r
+ return this.moduleId;\r
+ }\r
+ public PcdBuildDefinitionDocument.PcdBuildDefinition getPcdBuildDef(){\r
+ return this.pcdBuildDef;\r
}\r
}\r
\r
private int originalMessageLevel;\r
\r
/// Cache the fpd docment instance for private usage.\r
- private FrameworkPlatformDescriptionDocument fpdDocInstance;\r
-\r
+ private PlatformSurfaceAreaDocument fpdDocInstance;\r
+ \r
+ /// xmlObject name\r
+ private static String xmlObjectName = "PcdBuildDefinition"; \r
+ \r
/**\r
Set WorkspacePath parameter for this action class.\r
\r
@throws EntityException Exception indicate failed to execute this action.\r
\r
**/\r
- private void execute() throws EntityException {\r
+ public void execute() throws EntityException {\r
//\r
// Get memoryDatabaseManager instance from GlobalData.\r
// The memoryDatabaseManager should be initialized for whatever build\r
List<ModuleInfo> allModules = new ArrayList<ModuleInfo>();\r
ModuleInfo current = null;\r
int index = 0;\r
- org.tianocore.Components components = null;\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 = (FrameworkPlatformDescriptionDocument)XmlObject.Factory.parse(new File(fpdFilePath));\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
\r
}\r
\r
- map.put("FrameworkPlatformDescription", fpdDocInstance);\r
- SurfaceAreaQuery.setDoc(map); \r
- modules = SurfaceAreaQuery.getFpdModuleSAs();\r
- for (index = 0; index < modules.length; index ++) {\r
- SurfaceAreaQuery.setDoc(GlobalData.getDoc(modules[index].getModuleName()));\r
- allModules.add(new ModuleInfo(modules[index], \r
- ModuleTypeDef.Enum.forString(SurfaceAreaQuery.getModuleType())));\r
- }\r
+ //map.put("FrameworkPlatformDescription", fpdDocInstance);\r
+ //SurfaceAreaQuery.setDoc(map); \r
+ Map<FpdModuleIdentification,XmlObject>pcdBuildDef = GlobalData.getFpdModuleSaXmlObject(CollectPCDAction.xmlObjectName);\r
+ Set<FpdModuleIdentification> pcdBuildKeySet = pcdBuildDef.keySet();\r
+ Iterator item = pcdBuildKeySet.iterator();\r
+ while (item.hasNext()){\r
+ FpdModuleIdentification id = (FpdModuleIdentification)item.next();\r
+ try {\r
+ allModules.add(new ModuleInfo(id, id.getModule().getModuleType(),pcdBuildDef.get(id))); \r
+ } catch (Exception e){\r
+ System.out.println(e.getMessage());\r
+ //EdkLog.log(EdkLog.EDK_INFO,e.getMessage());\r
+ }\r
+ \r
+ \r
+ }\r
+// //modules = SurfaceAreaQuery.getFpdModuleSAs();\r
+// for (index = 0; index < modules.length; index ++) {\r
+// //SurfaceAreaQuery.setDoc(GlobalData.getDoc(modules[index].getModuleName()));\r
+// allModules.add(new ModuleInfo(modules[index], \r
+// ModuleTypeDef.Enum.forString(SurfaceAreaQuery.getModuleType())));\r
+// }\r
\r
return allModules;\r
}\r
String moduleName = null;\r
String datum = null;\r
int maxDatumSize = 0;\r
-\r
+ String tokenSpaceGuidString = null;\r
+ \r
//\r
// ----------------------------------------------\r
// 1), Get all <ModuleSA> from FPD file.\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).module.getModuleName(), \r
+ primaryKey1 = UsageInstance.getPrimaryKey(modules.get(index).getModuleId().getModule().getName(), \r
+ null,\r
null,\r
null, \r
- null, \r
- modules.get(index).module.getArch().toString(),\r
+ modules.get(index).getModuleId().getArch(),\r
null);\r
- primaryKey2 = UsageInstance.getPrimaryKey(modules.get(index2).module.getModuleName(), \r
+ primaryKey2 = UsageInstance.getPrimaryKey(modules.get(index2).getModuleId().getModule().getName(), \r
null, \r
null, \r
null, \r
- modules.get(index2).module.getArch().toString(), \r
+ modules.get(index2).getModuleId().getArch(), \r
null);\r
if (primaryKey1.equalsIgnoreCase(primaryKey2)) {\r
isDuplicate = true;\r
//\r
// It is legal for a module does not contains ANY pcd build definitions.\r
// \r
- if (modules.get(index).module.getPcdBuildDefinition() == null) {\r
+ if (modules.get(index).getPcdBuildDef() == null) {\r
continue;\r
}\r
\r
- pcdBuildDataArray = modules.get(index).module.getPcdBuildDefinition().getPcdDataList();\r
+ pcdBuildDataArray = modules.get(index).getPcdBuildDef().getPcdDataList();\r
\r
- moduleName = modules.get(index).module.getModuleName();\r
+ moduleName = modules.get(index).getModuleId().getModule().getName();\r
\r
//\r
// ----------------------------------------------------------------------\r
// ----------------------------------------------------------------------\r
// \r
for (pcdIndex = 0; pcdIndex < pcdBuildDataArray.size(); pcdIndex ++) {\r
+ //tokenSpaceGuidString = GlobalData.getGuidInfoFromCname(pcdBuildData.getTokenSpaceGuidCName())[1];\r
+ tokenSpaceGuidString = null;\r
pcdBuildData = pcdBuildDataArray.get(pcdIndex);\r
primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(),\r
- translateSchemaStringToUUID(pcdBuildData.getTokenSpaceGuid()));\r
+ translateSchemaStringToUUID(tokenSpaceGuidString));\r
pcdType = Token.getpcdTypeFromString(pcdBuildData.getItemType().toString());\r
datumType = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString());\r
tokenNumber = Long.decode(pcdBuildData.getToken().toString());\r
- \r
if (pcdBuildData.getValue() != null) {\r
datum = pcdBuildData.getValue().toString();\r
} else {\r
throw new EntityException(exceptionString);\r
}\r
\r
- //\r
- // Check <TokenSpaceGuid> is exist? In future, because all schema verification will tools\r
- // will check that, following checking code could be removed.\r
- // \r
- if (pcdBuildData.getTokenSpaceGuid() == null) {\r
- exceptionString = String.format("[FPD file error] There is no <TokenSpaceGuid> for PCD %s in module %s! This is required!",\r
- pcdBuildData.getCName(),\r
- moduleName);\r
- throw new EntityException(exceptionString);\r
- }\r
-\r
//\r
// -------------------------------------------------------------------------------------------\r
// 2.1.1), Do some necessary checking work for FixedAtBuild, FeatureFlag and PatchableInModule\r
// If the token is not in database, create a new token instance and add\r
// a usage instance into this token in database.\r
// \r
+ //String tokenSpaceString = GlobalData.getGuidInfoFromCname(pcdBuildData.getTokenSpaceGuidCName())[1];\r
+ String tokenSpaceString = null;\r
token = new Token(pcdBuildData.getCName(), \r
- translateSchemaStringToUUID(pcdBuildData.getTokenSpaceGuid()));\r
+ translateSchemaStringToUUID(tokenSpaceString));\r
\r
token.datumType = datumType;\r
token.tokenNumber = tokenNumber;\r
null,\r
null,\r
null,\r
- modules.get(index).type, \r
+ CommonDefinition.getModuleType(modules.get(index).getModuleType()), \r
pcdType,\r
- modules.get(index).module.getArch().toString(), \r
+ modules.get(index).getModuleId().getArch(), \r
null,\r
datum,\r
maxDatumSize);\r
// \r
if (fpdDocInstance == null) {\r
try {\r
- fpdDocInstance = (FrameworkPlatformDescriptionDocument)XmlObject.Factory.parse(new File(fpdFilePath));\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
}\r
-\r
- dynamicPcdBuildDefinitions = fpdDocInstance.getFrameworkPlatformDescription().getDynamicPcdBuildDefinitions();\r
+ \r
+ dynamicPcdBuildDefinitions = fpdDocInstance.getPlatformSurfaceArea().getDynamicPcdBuildDefinitions();\r
if (dynamicPcdBuildDefinitions == null) {\r
exceptionString = String.format("[FPD file error] There are no <PcdDynamicBuildDescriptions> in FPD file but contains Dynamic type "+\r
"PCD entry %s in module %s!",\r
\r
dynamicPcdBuildDataArray = dynamicPcdBuildDefinitions.getPcdBuildDataList();\r
for (index = 0; index < dynamicPcdBuildDataArray.size(); index ++) {\r
- //\r
- // Check <TokenSpaceGuid> is exist? In future, because all schema verification will tools\r
- // will check that, following checking code could be removed.\r
- // \r
- if (dynamicPcdBuildDataArray.get(index).getTokenSpaceGuid() == null) {\r
- exceptionString = String.format("[FPD file error] There is no <TokenSpaceGuid> for PCD %s in <DynamicPcdBuildDefinitions>! This is required!",\r
- dynamicPcdBuildDataArray.get(index).getCName());\r
- throw new EntityException(exceptionString);\r
- }\r
-\r
+ //String tokenSpaceGuidString = GlobalData.getGuidInfoFromCname(dynamicPcdBuildDataArray.get(index).getTokenSpaceGuidCName())[1];\r
+ String tokenSpaceGuidString = null;\r
dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(),\r
- translateSchemaStringToUUID(dynamicPcdBuildDataArray.get(index).getTokenSpaceGuid()));\r
+ translateSchemaStringToUUID(tokenSpaceGuidString));\r
if (dynamicPrimaryKey.equalsIgnoreCase(token.getPrimaryKeyString())) {\r
return dynamicPcdBuildDataArray.get(index);\r
}\r
//\r
// Get variable guid string according to the name of guid which will be mapped into a GUID in SPD file.\r
// \r
- variableGuidString = GlobalData.getGuidInfoGuid(skuInfoList.get(index).getVariableGuid().toString());\r
+ variableGuidString = GlobalData.getGuidInfoFromCname(skuInfoList.get(index).getVariableGuid().toString());\r
if (variableGuidString == null) {\r
throw new EntityException(String.format("[GUID Error] For dynamic PCD %s, the variable guid %s can be found in all SPD file!",\r
token.cName, \r
skuInfoList.get(index).getVariableGuid().toString()));\r
}\r
-\r
- skuInstance.value.setHiiData(skuInfoList.get(index).getVariableName(),\r
+ String variableStr = skuInfoList.get(index).getVariableName();\r
+ Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}");\r
+ Matcher matcher = pattern.matcher(variableStr);\r
+ List<String> varNameList = new ArrayList<String>();\r
+ while (matcher.find()){\r
+ String str = variableStr.substring(matcher.start(),matcher.end());\r
+ varNameList.add(str);\r
+ }\r
+ \r
+ skuInstance.value.setHiiData(varNameList,\r
translateSchemaStringToUUID(variableGuidString[1]),\r
skuInfoList.get(index).getVariableOffset(),\r
skuInfoList.get(index).getHiiDefaultValue().toString());\r
ca.setWorkspacePath("m:/tianocore/edk2");\r
ca.setFPDFilePath("m:/tianocore/edk2/EdkNt32Pkg/Nt32.fpd");\r
ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL);\r
- GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",\r
- "m:/tianocore/edk2");\r
- ca.execute();\r
+// GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",\r
+// "m:/tianocore/edk2");\r
+// ca.execute();\r
}\r
}\r