# AutoGen for each PCD listed in a [PcdEx] section of a Module/Lib INF file.\r
# Auto generate a macro for each TokenName that takes a Guid pointer as a parameter. \r
# Use the Guid pointer to see if it matches any of the token space GUIDs.\r
- TokenCNameList = []\r
+ TokenCNameList = set()\r
for TokenCName in ExTokenCNameList:\r
if TokenCName in TokenCNameList:\r
continue\r
% (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, RealTokenCName))\r
if Index == Count:\r
AutoGenH.Append('0 \\\n )\n')\r
- TokenCNameList.append(TokenCName)\r
+ TokenCNameList.add(TokenCName)\r
\r
- TokenCNameList = []\r
+ TokenCNameList = set()\r
for TokenCName in ExTokenCNameList:\r
if TokenCName in TokenCNameList:\r
continue\r
# COMPAREGUID() will only be used if the Guid passed in is local to the module.\r
AutoGenH.Append('#define _PCD_TOKEN_EX_%s(GuidPtr) __PCD_%s_ADDR_CMP(GuidPtr) ? __PCD_%s_ADDR_CMP(GuidPtr) : __PCD_%s_VAL_CMP(GuidPtr) \n'\r
% (RealTokenCName, RealTokenCName, RealTokenCName, RealTokenCName))\r
- TokenCNameList.append(TokenCName)\r
+ TokenCNameList.add(TokenCName)\r
\r
def GetPcdSize(Pcd):\r
if Pcd.DatumType not in _NumericDataTypesList:\r
SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_S_' + TokenCName\r
GetModeSizeName = '_PCD_GET_MODE_SIZE' + '_' + TokenCName\r
\r
- PcdExCNameList = []\r
if Pcd.Type in gDynamicExPcd:\r
if Info.IsLibrary:\r
PcdList = Info.LibraryPcdList\r
else:\r
PcdList = Info.ModulePcdList\r
+ PcdExCNameTest = 0\r
for PcdModule in PcdList:\r
- if PcdModule.Type in gDynamicExPcd:\r
- PcdExCNameList.append(PcdModule.TokenCName)\r
+ if PcdModule.Type in gDynamicExPcd and Pcd.TokenCName == PcdModule.TokenCName:\r
+ PcdExCNameTest += 1\r
+ # get out early once we found > 1...\r
+ if PcdExCNameTest > 1:\r
+ break\r
# Be compatible with the current code which using PcdToken and PcdGet/Set for DynamicEx Pcd.\r
# If only PcdToken and PcdGet/Set used in all Pcds with different CName, it should succeed to build.\r
# If PcdToken and PcdGet/Set used in the Pcds with different Guids but same CName, it should failed to build.\r
- if PcdExCNameList.count(Pcd.TokenCName) > 1:\r
+ if PcdExCNameTest > 1:\r
AutoGenH.Append('// Disabled the macros, as PcdToken and PcdGet/Set are not allowed in the case that more than one DynamicEx Pcds are different Guids but same CName.\n')\r
AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName))\r
AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))\r
AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))\r
AutoGenH.Append('#define %s(Value) LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))\r
elif Pcd.Type in gDynamicPcd:\r
- PcdList = []\r
- PcdCNameList = []\r
- PcdList.extend(Info.LibraryPcdList)\r
- PcdList.extend(Info.ModulePcdList)\r
- for PcdModule in PcdList:\r
- if PcdModule.Type in gDynamicPcd:\r
- PcdCNameList.append(PcdModule.TokenCName)\r
- if PcdCNameList.count(Pcd.TokenCName) > 1:\r
+ PcdCNameTest = 0\r
+ for PcdModule in Info.LibraryPcdList + Info.ModulePcdList:\r
+ if PcdModule.Type in gDynamicPcd and Pcd.TokenCName == PcdModule.TokenCName:\r
+ PcdCNameTest += 1\r
+ # get out early once we found > 1...\r
+ if PcdCNameTest > 1:\r
+ break\r
+ if PcdCNameTest > 1:\r
EdkLogger.error("build", AUTOGEN_ERROR, "More than one Dynamic Pcds [%s] are different Guids but same CName. They need to be changed to DynamicEx type to avoid the confliction.\n" % (TokenCName), ExtraData="[%s]" % str(Info.MetaFile.Path))\r
else:\r
AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName))\r
Type = '(VOID *)'\r
Array = '[]'\r
PcdItemType = Pcd.Type\r
- PcdExCNameList = []\r
if PcdItemType in gDynamicExPcd:\r
PcdExTokenName = '_PCD_TOKEN_' + TokenSpaceGuidCName + '_' + TokenCName\r
AutoGenH.Append('\n#define %s %dU\n' % (PcdExTokenName, TokenNumber))\r
PcdList = Info.LibraryPcdList\r
else:\r
PcdList = Info.ModulePcdList\r
+ PcdExCNameTest = 0\r
for PcdModule in PcdList:\r
- if PcdModule.Type in gDynamicExPcd:\r
- PcdExCNameList.append(PcdModule.TokenCName)\r
+ if PcdModule.Type in gDynamicExPcd and Pcd.TokenCName == PcdModule.TokenCName:\r
+ PcdExCNameTest += 1\r
+ # get out early once we found > 1...\r
+ if PcdExCNameTest > 1:\r
+ break\r
# Be compatible with the current code which using PcdGet/Set for DynamicEx Pcd.\r
# If only PcdGet/Set used in all Pcds with different CName, it should succeed to build.\r
# If PcdGet/Set used in the Pcds with different Guids but same CName, it should failed to build.\r
- if PcdExCNameList.count(Pcd.TokenCName) > 1:\r
+ if PcdExCNameTest > 1:\r
AutoGenH.Append('// Disabled the macros, as PcdToken and PcdGet/Set are not allowed in the case that more than one DynamicEx Pcds are different Guids but same CName.\n')\r
AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName))\r
AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))\r
AutoGenH.Append("\n// Definition of SkuId Array\n")\r
AutoGenH.Append("extern UINT64 _gPcd_SkuId_Array[];\n")\r
# Add extern declarations to AutoGen.h if one or more Token Space GUIDs were found\r
- if TokenSpaceList <> []: \r
+ if TokenSpaceList:\r
AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in this module\n\n")\r
if Info.ModuleType in ["USER_DEFINED", "BASE"]:\r
GuidType = "GUID"\r