public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools: Check pcd DefaultValue and SkuId EBNF.
@ 2018-08-27  1:29 BobCF
  2018-08-30  6:48 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: BobCF @ 2018-08-27  1:29 UTC (permalink / raw)
  To: edk2-devel; +Cc: Zhaozh1x, Liming Gao, Yonghong Zhu, Bob Feng

From: Zhaozh1x <zhiqiangx.zhao@intel.com>

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>
---
 BaseTools/Source/Python/Common/Misc.py            | 4 +++-
 BaseTools/Source/Python/Workspace/DscBuildData.py | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 74a5f0bca5..8debb0fdf8 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1525,6 +1525,7 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
                 Size = -1
         return [VpdOffset, str(Size), Value], IsValid, 2
     elif PcdType in (MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_EX_HII):
+        IsValid = (3 <= len(FieldList) <= 5)
         HiiString = FieldList[0]
         Guid = Offset = Value = Attribute = ''
         if len(FieldList) > 1:
@@ -1533,9 +1534,10 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
             Offset = FieldList[2]
         if len(FieldList) > 3:
             Value = FieldList[3]
+            if not Value:
+                IsValid = False
         if len(FieldList) > 4:
             Attribute = FieldList[4]
-        IsValid = (3 <= len(FieldList) <= 5)
         return [HiiString, Guid, Offset, Value, Attribute], IsValid, 3
     return [], False, 0
 
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index e8b36a3868..dd30067491 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -92,7 +92,7 @@ LIBS = -lCommon
 '''
 
 variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
-
+SkuIdPattern = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')
 ## regular expressions for finding decimal and hex numbers
 Pattern = re.compile('^[1-9]\d*|0$')
 HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')
@@ -646,8 +646,8 @@ class DscBuildData(PlatformBuildClassObject):
                 if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]):
                     EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID number is invalid. It only support Integer and HexNumber",
                                     File=self.MetaFile, Line=Record[-1])
-                if not IsValidWord(Record[1]):
-                    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_-.)*'",
+                if not SkuIdPattern.match(Record[1]) or (Record[2] and not SkuIdPattern.match(Record[2])):
+                    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_)*'",
                                     File=self.MetaFile, Line=Record[-1])
                 self._SkuIds[Record[1].upper()] = (str(DscBuildData.ToInt(Record[0])), Record[1].upper(), Record[2].upper())
             if TAB_DEFAULT not in self._SkuIds:
-- 
2.14.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] BaseTools: Check pcd DefaultValue and SkuId EBNF.
  2018-08-27  1:29 [PATCH] BaseTools: Check pcd DefaultValue and SkuId EBNF BobCF
@ 2018-08-30  6:48 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2018-08-30  6:48 UTC (permalink / raw)
  To: Feng, Bob C, edk2-devel@lists.01.org; +Cc: Zhao, ZhiqiangX, Zhu, Yonghong

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Feng, Bob C
>Sent: Monday, August 27, 2018 9:30 AM
>To: edk2-devel@lists.01.org
>Cc: Zhao, ZhiqiangX <zhiqiangx.zhao@intel.com>; Gao, Liming
><liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>; Feng,
>Bob C <bob.c.feng@intel.com>
>Subject: [PATCH] BaseTools: Check pcd DefaultValue and SkuId EBNF.
>
>From: Zhaozh1x <zhiqiangx.zhao@intel.com>
>
>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>
>---
> BaseTools/Source/Python/Common/Misc.py            | 4 +++-
> BaseTools/Source/Python/Workspace/DscBuildData.py | 6 +++---
> 2 files changed, 6 insertions(+), 4 deletions(-)
>
>diff --git a/BaseTools/Source/Python/Common/Misc.py
>b/BaseTools/Source/Python/Common/Misc.py
>index 74a5f0bca5..8debb0fdf8 100644
>--- a/BaseTools/Source/Python/Common/Misc.py
>+++ b/BaseTools/Source/Python/Common/Misc.py
>@@ -1525,6 +1525,7 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
>                 Size = -1
>         return [VpdOffset, str(Size), Value], IsValid, 2
>     elif PcdType in (MODEL_PCD_DYNAMIC_HII,
>MODEL_PCD_DYNAMIC_EX_HII):
>+        IsValid = (3 <= len(FieldList) <= 5)
>         HiiString = FieldList[0]
>         Guid = Offset = Value = Attribute = ''
>         if len(FieldList) > 1:
>@@ -1533,9 +1534,10 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
>             Offset = FieldList[2]
>         if len(FieldList) > 3:
>             Value = FieldList[3]
>+            if not Value:
>+                IsValid = False
>         if len(FieldList) > 4:
>             Attribute = FieldList[4]
>-        IsValid = (3 <= len(FieldList) <= 5)
>         return [HiiString, Guid, Offset, Value, Attribute], IsValid, 3
>     return [], False, 0
>
>diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
>b/BaseTools/Source/Python/Workspace/DscBuildData.py
>index e8b36a3868..dd30067491 100644
>--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
>@@ -92,7 +92,7 @@ LIBS = -lCommon
> '''
>
> variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
>-
>+SkuIdPattern = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*$')
> ## regular expressions for finding decimal and hex numbers
> Pattern = re.compile('^[1-9]\d*|0$')
> HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')
>@@ -646,8 +646,8 @@ class DscBuildData(PlatformBuildClassObject):
>                 if not Pattern.match(Record[0]) and not
>HexPattern.match(Record[0]):
>                     EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku
>ID number is invalid. It only support Integer and HexNumber",
>                                     File=self.MetaFile, Line=Record[-1])
>-                if not IsValidWord(Record[1]):
>-                    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_-.)*'",
>+                if not SkuIdPattern.match(Record[1]) or (Record[2] and not
>SkuIdPattern.match(Record[2])):
>+                    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_)*'",
>                                     File=self.MetaFile, Line=Record[-1])
>                 self._SkuIds[Record[1].upper()] = (str(DscBuildData.ToInt(Record[0])),
>Record[1].upper(), Record[2].upper())
>             if TAB_DEFAULT not in self._SkuIds:
>--
>2.14.1.windows.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-30  6:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-27  1:29 [PATCH] BaseTools: Check pcd DefaultValue and SkuId EBNF BobCF
2018-08-30  6:48 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox