]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Check pcd DefaultValue and SkuId EBNF.
authorZhaozh1x <zhiqiangx.zhao@intel.com>
Mon, 27 Aug 2018 01:29:37 +0000 (09:29 +0800)
committerLiming Gao <liming.gao@intel.com>
Mon, 3 Sep 2018 02:14:44 +0000 (10:14 +0800)
1. When assign dynamic hii pcd value in dsc file,
missed the DefaultValue, build should be fail.
2. Check the EBNF of SkuId.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/Common/Misc.py
BaseTools/Source/Python/Workspace/DscBuildData.py

index 5a63c83a2a0c3dcfb580f248a36fe18aaa7955f3..2cf9574326d5834488ac797b6a4a1be21cae1089 100644 (file)
@@ -1508,6 +1508,7 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
                 Size = -1\r
         return [VpdOffset, str(Size), Value], IsValid, 2\r
     elif PcdType in (MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_EX_HII):\r
+        IsValid = (3 <= len(FieldList) <= 5)\r
         HiiString = FieldList[0]\r
         Guid = Offset = Value = Attribute = ''\r
         if len(FieldList) > 1:\r
@@ -1516,9 +1517,10 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
             Offset = FieldList[2]\r
         if len(FieldList) > 3:\r
             Value = FieldList[3]\r
+            if not Value:\r
+                IsValid = False\r
         if len(FieldList) > 4:\r
             Attribute = FieldList[4]\r
-        IsValid = (3 <= len(FieldList) <= 5)\r
         return [HiiString, Guid, Offset, Value, Attribute], IsValid, 3\r
     return [], False, 0\r
 \r
index 7d6536c4b6df7b2b91bdc40b608f5c62e2405ff5..9055b257bd6e8cf3c14ca3cc0a2110077a15c333 100644 (file)
@@ -92,7 +92,7 @@ LIBS = -lCommon
 '''\r
 \r
 variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')\r
-\r
+SkuIdPattern = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')\r
 ## regular expressions for finding decimal and hex numbers\r
 Pattern = re.compile('^[1-9]\d*|0$')\r
 HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')\r
@@ -631,8 +631,8 @@ class DscBuildData(PlatformBuildClassObject):
                 if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]):\r
                     EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID number is invalid. It only support Integer and HexNumber",\r
                                     File=self.MetaFile, Line=Record[-1])\r
-                if not IsValidWord(Record[1]):\r
-                    EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID name is invalid. The correct format is '(a-zA-Z0-9_)(a-zA-Z0-9_-.)*'",\r
+                if not SkuIdPattern.match(Record[1]) or (Record[2] and not SkuIdPattern.match(Record[2])):\r
+                    EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID name is invalid. The correct format is '(a-zA-Z_)(a-zA-Z0-9_)*'",\r
                                     File=self.MetaFile, Line=Record[-1])\r
                 self._SkuIds[Record[1].upper()] = (str(DscBuildData.ToInt(Record[0])), Record[1].upper(), Record[2].upper())\r
             if TAB_DEFAULT not in self._SkuIds:\r