diff options
author | bob.c.feng@intel.com <bob.c.feng@intel.com> | 2018-11-07 17:18:34 +0800 |
---|---|---|
committer | BobCF <bob.c.feng@intel.com> | 2018-12-07 09:59:36 +0800 |
commit | 72a1d77694d51914c0dd6aa97dbfa58634b0a4a5 (patch) | |
tree | c101bf18a2739de1e6f2344c22898ec08650a4cb /BaseTools/Source/Python/Workspace/DecBuildData.py | |
parent | 088a5334809d175ea6b4020012afa9f3b6962960 (diff) | |
download | edk2-72a1d77694d51914c0dd6aa97dbfa58634b0a4a5.tar.gz edk2-72a1d77694d51914c0dd6aa97dbfa58634b0a4a5.tar.bz2 edk2-72a1d77694d51914c0dd6aa97dbfa58634b0a4a5.zip |
BaseTools: Enable Pcd Array support.
https://bugzilla.tianocore.org/show_bug.cgi?id=1292
This patch is going to enable Array data type for PCD.
1. Support Pcd ARRAY as Structure PCD type
including basic datatype array and structure array.
For example:
gStructuredPcdPkgTokenSpaceGuid.PcdTest|{0x0}|TEST[10]|0x00010080
gStructuredPcdPkgTokenSpaceGuid.PcdTest2|{0x0}|UINT8[10]|0x00010081
2. Support C CODE style value initialization in DEC/DSC.
For example:
gStructuredPcdPkgTokenSpaceGuid.PcdTest|{CODE({
{0, {0, 0, 0, 0, 0, 0, 0}},
{0, {0, 0, 0, 0, 0, 0, 0}},
{0, {0, 0, 0, 0, 0, 0, 0}},
{0, {0, 0, 0, 0, 0, 0, 0}},
{0, {0, 0, 0, 0, 0, 0, 0}},
{0, {0, 0, 0, 0, 0, 0, 0}},
{0, {0, 0, 0, 0, 0, 0, 0}},
{0, {0, 0, 0, 0, 0, 0, 0}},
{0, {0, 0, 0, 0, 0, 0, 0}},
{0, {0, 0, 0, 0, 0, 0, 0}},
})}
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Workspace/DecBuildData.py')
-rw-r--r-- | BaseTools/Source/Python/Workspace/DecBuildData.py | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 31ee13eca9..cc00409fee 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -361,6 +361,21 @@ class DecBuildData(PackageBuildClassObject): self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX))
return self._Pcds
+ def ParsePcdName(self,TokenCName):
+ TokenCName = TokenCName.strip()
+ if TokenCName.startswith("["):
+ if "." in TokenCName:
+ Demesionattr = TokenCName[:TokenCName.index(".")]
+ Fields = TokenCName[TokenCName.index(".")+1:]
+ else:
+ Demesionattr = TokenCName
+ Fields = ""
+ else:
+ Demesionattr = ""
+ Fields = TokenCName
+
+ return Demesionattr,Fields
+
def ProcessStructurePcd(self, StructurePcdRawDataSet):
s_pcd_set = OrderedDict()
for s_pcd, LineNo in StructurePcdRawDataSet:
@@ -373,6 +388,8 @@ class DecBuildData(PackageBuildClassObject): dep_pkgs = []
struct_pcd = StructurePcd()
for item, LineNo in s_pcd_set[pcdname]:
+ if not item.TokenCName:
+ continue
if "<HeaderFiles>" in item.TokenCName:
struct_pcd.StructuredPcdIncludeFile.append(item.DefaultValue)
elif "<Packages>" in item.TokenCName:
@@ -385,7 +402,8 @@ class DecBuildData(PackageBuildClassObject): struct_pcd.PkgPath = self.MetaFile.File
struct_pcd.SetDecDefaultValue(item.DefaultValue)
else:
- struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue, self.MetaFile.File, LineNo)
+ DemesionAttr, Fields = self.ParsePcdName(item.TokenCName)
+ struct_pcd.AddDefaultValue(Fields, item.DefaultValue, self.MetaFile.File, LineNo,DemesionAttr)
struct_pcd.PackageDecs = dep_pkgs
str_pcd_set.append(struct_pcd)
@@ -446,15 +464,12 @@ class DecBuildData(PackageBuildClassObject): StructurePcds = self.ProcessStructurePcd(StrPcdSet)
for pcd in StructurePcds:
Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd
- StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*$')
for pcd in Pcds.values():
if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:
- if StructPattern.match(pcd.DatumType) is None:
+ if not pcd.IsAggregateDatumType():
EdkLogger.error('build', FORMAT_INVALID, "DatumType only support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct name.", DefinitionPosition[pcd][0], DefinitionPosition[pcd][1])
- for struct_pcd in Pcds.values():
- if isinstance(struct_pcd, StructurePcd) and not struct_pcd.StructuredPcdIncludeFile:
- EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName, DefinitionPosition[struct_pcd][0], DefinitionPosition[struct_pcd][1] ))
-
+ elif not pcd.IsArray() and not pcd.StructuredPcdIncludeFile:
+ EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (pcd.TokenSpaceGuidCName, pcd.TokenCName, pcd.DefinitionPosition[0], pcd.DefinitionPosition[1] ))
return Pcds
@property
|