public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch V2] BaseTools: enable FixedAtBuild (VOID*) PCD use in the [DEPEX] section
@ 2018-07-05  7:27 Yonghong Zhu
  2018-07-06  1:55 ` Gao, Liming
  0 siblings, 1 reply; 4+ messages in thread
From: Yonghong Zhu @ 2018-07-05  7:27 UTC (permalink / raw)
  To: edk2-devel; +Cc: Yunhua Feng, Liming Gao

From: Yunhua Feng <yunhuax.feng@intel.com>

V2: limit the PCD used in the [Depex] section should be used in the module

The PCD item used in INF [Depex] section must be defined as FixedAtBuild
type and VOID* datum type, and the size of the PCD must be 16 bytes.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=443
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py        | 31 ++++++++++++++++++++---
 BaseTools/Source/Python/AutoGen/GenDepex.py       |  6 +++++
 BaseTools/Source/Python/Workspace/InfBuildData.py | 15 +++++++----
 BaseTools/Source/Python/build/BuildReport.py      |  6 +++++
 4 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 6d76afd..7d4539e 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2745,10 +2745,14 @@ class ModuleAutoGen(AutoGen):
         ## Store the FixedAtBuild Pcds
         #  
         self._FixedAtBuildPcds         = []
         self.ConstPcd                  = {}
 
+        ##Store the VOID* type FixedAtBuild Pcds
+        #
+        self._FixedPcdVoidTypeDict = {}
+
     def __repr__(self):
         return "%s [%s]" % (self.MetaFile, self.Arch)
 
     # Get FixedAtBuild Pcds of this Module
     def _GetFixedAtBuildPcds(self):
@@ -2758,11 +2762,20 @@ class ModuleAutoGen(AutoGen):
             if Pcd.Type != TAB_PCDS_FIXED_AT_BUILD:
                 continue
             if Pcd not in self._FixedAtBuildPcds:
                 self._FixedAtBuildPcds.append(Pcd)
                 
-        return self._FixedAtBuildPcds        
+        return self._FixedAtBuildPcds
+
+    def _GetFixedAtBuildVoidTypePcds(self):
+        if self._FixedPcdVoidTypeDict:
+            return self._FixedPcdVoidTypeDict
+        for Pcd in self.ModulePcdList:
+            if Pcd.Type == TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType == TAB_VOID:
+                if '{}.{}'.format(Pcd.TokenSpaceGuidCName, Pcd.TokenCName) not in self._FixedPcdVoidTypeDict:
+                    self._FixedPcdVoidTypeDict['{}.{}'.format(Pcd.TokenSpaceGuidCName, Pcd.TokenCName)] = Pcd.DefaultValue
+        return self._FixedPcdVoidTypeDict
 
     def _GetUniqueBaseName(self):
         BaseName = self.Name
         for Module in self.PlatformInfo.ModuleAutoGenList:
             if Module.MetaFile == self.MetaFile:
@@ -3029,11 +3042,11 @@ class ModuleAutoGen(AutoGen):
             self._DepexDict = {}
             if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:
                 return self._DepexDict
 
             self._DepexDict[self.ModuleType] = []
-
+            self._GetFixedAtBuildVoidTypePcds()
             for ModuleType in self._DepexDict:
                 DepexList = self._DepexDict[ModuleType]
                 #
                 # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion
                 #
@@ -3041,11 +3054,22 @@ class ModuleAutoGen(AutoGen):
                     Inherited = False
                     for D in M.Depex[self.Arch, ModuleType]:
                         if DepexList != []:
                             DepexList.append('AND')
                         DepexList.append('(')
-                        DepexList.extend(D)
+                        #replace D with value if D is FixedAtBuild PCD
+                        NewList = []
+                        for item in D:
+                            if '.' not in item:
+                                NewList.append(item)
+                            else:
+                                if item not in self._FixedPcdVoidTypeDict:
+                                    EdkLogger.error("build", FORMAT_INVALID, "{} used in [Depex] section should be used as FixedAtBuild type and VOID* datum type in the module.".format(item))
+                                else:
+                                    Value = self._FixedPcdVoidTypeDict[item]
+                                    NewList.append(Value)
+                        DepexList.extend(NewList)
                         if DepexList[-1] == 'END':  # no need of a END at this time
                             DepexList.pop()
                         DepexList.append(')')
                         Inherited = True
                     if Inherited:
@@ -4409,10 +4433,11 @@ class ModuleAutoGen(AutoGen):
     BuildOptionIncPathList  = property(_GetBuildOptionIncPathList)
     BuildCommand            = property(_GetBuildCommand)
     
     FixedAtBuildPcds         = property(_GetFixedAtBuildPcds)
     UniqueBaseName          = property(_GetUniqueBaseName)
+    FixedVoidTypePcds       = property(_GetFixedAtBuildVoidTypePcds)
 
 # This acts like the main() function for the script, unless it is 'import'ed into another script.
 if __name__ == '__main__':
     pass
 
diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source/Python/AutoGen/GenDepex.py
index d3b1eae..c12b613 100644
--- a/BaseTools/Source/Python/AutoGen/GenDepex.py
+++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
@@ -20,10 +20,12 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
 from io import BytesIO
 from struct import pack
 from Common.BuildToolError import *
 from Common.Misc import SaveFileOnChange
 from Common.Misc import GuidStructureStringToGuidString
+from Common.Misc import GuidStructureByteArrayToGuidString
+from Common.Misc import GuidStringToGuidStructureString
 from Common import EdkLogger as EdkLogger
 from Common.BuildVersion import gBUILD_VERSION
 from Common.DataType import *
 
 ## Regular expression for matching "DEPENDENCY_START ... DEPENDENCY_END"
@@ -331,10 +333,14 @@ class DependencyExpression:
     #   @retval array   The byte array representing the GUID value
     #
     def GetGuidValue(self, Guid):
         GuidValueString = Guid.replace("{", "").replace("}", "").replace(" ", "")
         GuidValueList = GuidValueString.split(",")
+        if len(GuidValueList) != 11 and len(GuidValueList) == 16:
+            GuidValueString = GuidStringToGuidStructureString(GuidStructureByteArrayToGuidString(Guid))
+            GuidValueString = GuidValueString.replace("{", "").replace("}", "").replace(" ", "")
+            GuidValueList = GuidValueString.split(",")
         if len(GuidValueList) != 11:
             EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid GUID value string or opcode: %s" % Guid)
         return pack("1I2H8B", *(int(value, 16) for value in GuidValueList))
 
     ## Save the binary form of dependency expression in file
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 165e03f..efb3de1 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -909,16 +909,21 @@ class InfBuildData(ModuleBuildClassObject):
                         if Module is None:
                             EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "Module is not found in active platform",
                                             ExtraData=Token, File=self.MetaFile, Line=Record[-1])
                         DepexList.append(Module.Guid)
                     else:
-                        # get the GUID value now
-                        Value = ProtocolValue(Token, self.Packages, self.MetaFile.Path)
-                        if Value is None:
-                            Value = PpiValue(Token, self.Packages, self.MetaFile.Path)
+                        # it use the Fixed PCD format
+                        if '.' in Token:
+                            Value = Token
+                        else:
+                            # get the GUID value now
+                            Value = ProtocolValue(Token, self.Packages, self.MetaFile.Path)
                             if Value is None:
-                                Value = GuidValue(Token, self.Packages, self.MetaFile.Path)
+                                Value = PpiValue(Token, self.Packages, self.MetaFile.Path)
+                                if Value is None:
+                                    Value = GuidValue(Token, self.Packages, self.MetaFile.Path)
+
                         if Value is None:
                             PackageList = "\n\t".join(str(P) for P in self.Packages)
                             EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
                                             "Value of [%s] is not found in" % Token,
                                             ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index 897167c..0dbbba0 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -278,10 +278,16 @@ class DepexParser(object):
                     GuidValue = GuidStructureStringToGuidString(Package.Ppis[Ppi])
                     self._GuidDb[GuidValue.upper()] = Ppi
                 for Guid in Package.Guids:
                     GuidValue = GuidStructureStringToGuidString(Package.Guids[Guid])
                     self._GuidDb[GuidValue.upper()] = Guid
+            for Ma in Pa.ModuleAutoGenList:
+                for Pcd in Ma.FixedVoidTypePcds:
+                    PcdValue = Ma.FixedVoidTypePcds[Pcd]
+                    if len(PcdValue.split(',')) == 16:
+                        GuidValue = GuidStructureByteArrayToGuidString(PcdValue)
+                        self._GuidDb[GuidValue.upper()] = Pcd
     
     ##
     # Parse the binary dependency expression files.
     # 
     # This function parses the binary dependency expression file and translate it
-- 
2.6.1.windows.1



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

* Re: [Patch V2] BaseTools: enable FixedAtBuild (VOID*) PCD use in the [DEPEX] section
  2018-07-05  7:27 [Patch V2] BaseTools: enable FixedAtBuild (VOID*) PCD use in the [DEPEX] section Yonghong Zhu
@ 2018-07-06  1:55 ` Gao, Liming
  2018-07-06  1:58   ` Zhu, Yonghong
  0 siblings, 1 reply; 4+ messages in thread
From: Gao, Liming @ 2018-07-06  1:55 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org

Yonghong:
  On error handling, could you check VOID* PCD length to make sure its size is 16 when it is used in [Depex] section?

Thanks
Liming
>-----Original Message-----
>From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>Yonghong Zhu
>Sent: Thursday, July 05, 2018 3:28 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>Subject: [edk2] [Patch V2] BaseTools: enable FixedAtBuild (VOID*) PCD use in
>the [DEPEX] section
>
>From: Yunhua Feng <yunhuax.feng@intel.com>
>
>V2: limit the PCD used in the [Depex] section should be used in the module
>
>The PCD item used in INF [Depex] section must be defined as FixedAtBuild
>type and VOID* datum type, and the size of the PCD must be 16 bytes.
>
>Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=443
>Cc: Liming Gao <liming.gao@intel.com>
>Cc: Yonghong Zhu <yonghong.zhu@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
>---
> BaseTools/Source/Python/AutoGen/AutoGen.py        | 31
>++++++++++++++++++++---
> BaseTools/Source/Python/AutoGen/GenDepex.py       |  6 +++++
> BaseTools/Source/Python/Workspace/InfBuildData.py | 15 +++++++----
> BaseTools/Source/Python/build/BuildReport.py      |  6 +++++
> 4 files changed, 50 insertions(+), 8 deletions(-)
>
>diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
>b/BaseTools/Source/Python/AutoGen/AutoGen.py
>index 6d76afd..7d4539e 100644
>--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
>+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
>@@ -2745,10 +2745,14 @@ class ModuleAutoGen(AutoGen):
>         ## Store the FixedAtBuild Pcds
>         #
>         self._FixedAtBuildPcds         = []
>         self.ConstPcd                  = {}
>
>+        ##Store the VOID* type FixedAtBuild Pcds
>+        #
>+        self._FixedPcdVoidTypeDict = {}
>+
>     def __repr__(self):
>         return "%s [%s]" % (self.MetaFile, self.Arch)
>
>     # Get FixedAtBuild Pcds of this Module
>     def _GetFixedAtBuildPcds(self):
>@@ -2758,11 +2762,20 @@ class ModuleAutoGen(AutoGen):
>             if Pcd.Type != TAB_PCDS_FIXED_AT_BUILD:
>                 continue
>             if Pcd not in self._FixedAtBuildPcds:
>                 self._FixedAtBuildPcds.append(Pcd)
>
>-        return self._FixedAtBuildPcds
>+        return self._FixedAtBuildPcds
>+
>+    def _GetFixedAtBuildVoidTypePcds(self):
>+        if self._FixedPcdVoidTypeDict:
>+            return self._FixedPcdVoidTypeDict
>+        for Pcd in self.ModulePcdList:
>+            if Pcd.Type == TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType ==
>TAB_VOID:
>+                if '{}.{}'.format(Pcd.TokenSpaceGuidCName, Pcd.TokenCName) not
>in self._FixedPcdVoidTypeDict:
>+
>self._FixedPcdVoidTypeDict['{}.{}'.format(Pcd.TokenSpaceGuidCName,
>Pcd.TokenCName)] = Pcd.DefaultValue
>+        return self._FixedPcdVoidTypeDict
>
>     def _GetUniqueBaseName(self):
>         BaseName = self.Name
>         for Module in self.PlatformInfo.ModuleAutoGenList:
>             if Module.MetaFile == self.MetaFile:
>@@ -3029,11 +3042,11 @@ class ModuleAutoGen(AutoGen):
>             self._DepexDict = {}
>             if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE
>in self.FileTypes:
>                 return self._DepexDict
>
>             self._DepexDict[self.ModuleType] = []
>-
>+            self._GetFixedAtBuildVoidTypePcds()
>             for ModuleType in self._DepexDict:
>                 DepexList = self._DepexDict[ModuleType]
>                 #
>                 # Append depex from dependent libraries, if not "BEFORE", "AFTER"
>expresion
>                 #
>@@ -3041,11 +3054,22 @@ class ModuleAutoGen(AutoGen):
>                     Inherited = False
>                     for D in M.Depex[self.Arch, ModuleType]:
>                         if DepexList != []:
>                             DepexList.append('AND')
>                         DepexList.append('(')
>-                        DepexList.extend(D)
>+                        #replace D with value if D is FixedAtBuild PCD
>+                        NewList = []
>+                        for item in D:
>+                            if '.' not in item:
>+                                NewList.append(item)
>+                            else:
>+                                if item not in self._FixedPcdVoidTypeDict:
>+                                    EdkLogger.error("build", FORMAT_INVALID, "{} used in
>[Depex] section should be used as FixedAtBuild type and VOID* datum type
>in the module.".format(item))
>+                                else:
>+                                    Value = self._FixedPcdVoidTypeDict[item]
>+                                    NewList.append(Value)
>+                        DepexList.extend(NewList)
>                         if DepexList[-1] == 'END':  # no need of a END at this time
>                             DepexList.pop()
>                         DepexList.append(')')
>                         Inherited = True
>                     if Inherited:
>@@ -4409,10 +4433,11 @@ class ModuleAutoGen(AutoGen):
>     BuildOptionIncPathList  = property(_GetBuildOptionIncPathList)
>     BuildCommand            = property(_GetBuildCommand)
>
>     FixedAtBuildPcds         = property(_GetFixedAtBuildPcds)
>     UniqueBaseName          = property(_GetUniqueBaseName)
>+    FixedVoidTypePcds       = property(_GetFixedAtBuildVoidTypePcds)
>
> # This acts like the main() function for the script, unless it is 'import'ed into
>another script.
> if __name__ == '__main__':
>     pass
>
>diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py
>b/BaseTools/Source/Python/AutoGen/GenDepex.py
>index d3b1eae..c12b613 100644
>--- a/BaseTools/Source/Python/AutoGen/GenDepex.py
>+++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
>@@ -20,10 +20,12 @@ from Common.LongFilePathSupport import
>OpenLongFilePath as open
> from io import BytesIO
> from struct import pack
> from Common.BuildToolError import *
> from Common.Misc import SaveFileOnChange
> from Common.Misc import GuidStructureStringToGuidString
>+from Common.Misc import GuidStructureByteArrayToGuidString
>+from Common.Misc import GuidStringToGuidStructureString
> from Common import EdkLogger as EdkLogger
> from Common.BuildVersion import gBUILD_VERSION
> from Common.DataType import *
>
> ## Regular expression for matching "DEPENDENCY_START ...
>DEPENDENCY_END"
>@@ -331,10 +333,14 @@ class DependencyExpression:
>     #   @retval array   The byte array representing the GUID value
>     #
>     def GetGuidValue(self, Guid):
>         GuidValueString = Guid.replace("{", "").replace("}", "").replace(" ", "")
>         GuidValueList = GuidValueString.split(",")
>+        if len(GuidValueList) != 11 and len(GuidValueList) == 16:
>+            GuidValueString =
>GuidStringToGuidStructureString(GuidStructureByteArrayToGuidString(Guid))
>+            GuidValueString = GuidValueString.replace("{", "").replace("}",
>"").replace(" ", "")
>+            GuidValueList = GuidValueString.split(",")
>         if len(GuidValueList) != 11:
>             EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid GUID value
>string or opcode: %s" % Guid)
>         return pack("1I2H8B", *(int(value, 16) for value in GuidValueList))
>
>     ## Save the binary form of dependency expression in file
>diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py
>b/BaseTools/Source/Python/Workspace/InfBuildData.py
>index 165e03f..efb3de1 100644
>--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
>@@ -909,16 +909,21 @@ class InfBuildData(ModuleBuildClassObject):
>                         if Module is None:
>                             EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "Module
>is not found in active platform",
>                                             ExtraData=Token, File=self.MetaFile, Line=Record[-1])
>                         DepexList.append(Module.Guid)
>                     else:
>-                        # get the GUID value now
>-                        Value = ProtocolValue(Token, self.Packages, self.MetaFile.Path)
>-                        if Value is None:
>-                            Value = PpiValue(Token, self.Packages, self.MetaFile.Path)
>+                        # it use the Fixed PCD format
>+                        if '.' in Token:
>+                            Value = Token
>+                        else:
>+                            # get the GUID value now
>+                            Value = ProtocolValue(Token, self.Packages,
>self.MetaFile.Path)
>                             if Value is None:
>-                                Value = GuidValue(Token, self.Packages, self.MetaFile.Path)
>+                                Value = PpiValue(Token, self.Packages, self.MetaFile.Path)
>+                                if Value is None:
>+                                    Value = GuidValue(Token, self.Packages,
>self.MetaFile.Path)
>+
>                         if Value is None:
>                             PackageList = "\n\t".join(str(P) for P in self.Packages)
>                             EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
>                                             "Value of [%s] is not found in" % Token,
>                                             ExtraData=PackageList, File=self.MetaFile,
>Line=Record[-1])
>diff --git a/BaseTools/Source/Python/build/BuildReport.py
>b/BaseTools/Source/Python/build/BuildReport.py
>index 897167c..0dbbba0 100644
>--- a/BaseTools/Source/Python/build/BuildReport.py
>+++ b/BaseTools/Source/Python/build/BuildReport.py
>@@ -278,10 +278,16 @@ class DepexParser(object):
>                     GuidValue = GuidStructureStringToGuidString(Package.Ppis[Ppi])
>                     self._GuidDb[GuidValue.upper()] = Ppi
>                 for Guid in Package.Guids:
>                     GuidValue = GuidStructureStringToGuidString(Package.Guids[Guid])
>                     self._GuidDb[GuidValue.upper()] = Guid
>+            for Ma in Pa.ModuleAutoGenList:
>+                for Pcd in Ma.FixedVoidTypePcds:
>+                    PcdValue = Ma.FixedVoidTypePcds[Pcd]
>+                    if len(PcdValue.split(',')) == 16:
>+                        GuidValue = GuidStructureByteArrayToGuidString(PcdValue)
>+                        self._GuidDb[GuidValue.upper()] = Pcd
>
>     ##
>     # Parse the binary dependency expression files.
>     #
>     # This function parses the binary dependency expression file and translate
>it
>--
>2.6.1.windows.1
>
>_______________________________________________
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel


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

* Re: [Patch V2] BaseTools: enable FixedAtBuild (VOID*) PCD use in the [DEPEX] section
  2018-07-06  1:55 ` Gao, Liming
@ 2018-07-06  1:58   ` Zhu, Yonghong
  2018-07-06  2:06     ` Gao, Liming
  0 siblings, 1 reply; 4+ messages in thread
From: Zhu, Yonghong @ 2018-07-06  1:58 UTC (permalink / raw)
  To: Gao, Liming, edk2-devel@lists.01.org

In  GetGuidValue() function it already have this logic to handle it.

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Gao, Liming 
Sent: Friday, July 06, 2018 9:55 AM
To: Zhu, Yonghong <yonghong.zhu@intel.com>; edk2-devel@lists.01.org
Subject: RE: [edk2] [Patch V2] BaseTools: enable FixedAtBuild (VOID*) PCD use in the [DEPEX] section

Yonghong:
  On error handling, could you check VOID* PCD length to make sure its size is 16 when it is used in [Depex] section?

Thanks
Liming
>-----Original Message-----
>From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of 
>Yonghong Zhu
>Sent: Thursday, July 05, 2018 3:28 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>Subject: [edk2] [Patch V2] BaseTools: enable FixedAtBuild (VOID*) PCD 
>use in the [DEPEX] section
>
>From: Yunhua Feng <yunhuax.feng@intel.com>
>
>V2: limit the PCD used in the [Depex] section should be used in the 
>module
>
>The PCD item used in INF [Depex] section must be defined as 
>FixedAtBuild type and VOID* datum type, and the size of the PCD must be 16 bytes.
>
>Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=443
>Cc: Liming Gao <liming.gao@intel.com>
>Cc: Yonghong Zhu <yonghong.zhu@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
>---
> BaseTools/Source/Python/AutoGen/AutoGen.py        | 31
>++++++++++++++++++++---
> BaseTools/Source/Python/AutoGen/GenDepex.py       |  6 +++++
> BaseTools/Source/Python/Workspace/InfBuildData.py | 15 +++++++----
> BaseTools/Source/Python/build/BuildReport.py      |  6 +++++
> 4 files changed, 50 insertions(+), 8 deletions(-)
>
>diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
>b/BaseTools/Source/Python/AutoGen/AutoGen.py
>index 6d76afd..7d4539e 100644
>--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
>+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
>@@ -2745,10 +2745,14 @@ class ModuleAutoGen(AutoGen):
>         ## Store the FixedAtBuild Pcds
>         #
>         self._FixedAtBuildPcds         = []
>         self.ConstPcd                  = {}
>
>+        ##Store the VOID* type FixedAtBuild Pcds
>+        #
>+        self._FixedPcdVoidTypeDict = {}
>+
>     def __repr__(self):
>         return "%s [%s]" % (self.MetaFile, self.Arch)
>
>     # Get FixedAtBuild Pcds of this Module
>     def _GetFixedAtBuildPcds(self):
>@@ -2758,11 +2762,20 @@ class ModuleAutoGen(AutoGen):
>             if Pcd.Type != TAB_PCDS_FIXED_AT_BUILD:
>                 continue
>             if Pcd not in self._FixedAtBuildPcds:
>                 self._FixedAtBuildPcds.append(Pcd)
>
>-        return self._FixedAtBuildPcds
>+        return self._FixedAtBuildPcds
>+
>+    def _GetFixedAtBuildVoidTypePcds(self):
>+        if self._FixedPcdVoidTypeDict:
>+            return self._FixedPcdVoidTypeDict
>+        for Pcd in self.ModulePcdList:
>+            if Pcd.Type == TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType 
>+ ==
>TAB_VOID:
>+                if '{}.{}'.format(Pcd.TokenSpaceGuidCName, 
>+ Pcd.TokenCName) not
>in self._FixedPcdVoidTypeDict:
>+
>self._FixedPcdVoidTypeDict['{}.{}'.format(Pcd.TokenSpaceGuidCName,
>Pcd.TokenCName)] = Pcd.DefaultValue
>+        return self._FixedPcdVoidTypeDict
>
>     def _GetUniqueBaseName(self):
>         BaseName = self.Name
>         for Module in self.PlatformInfo.ModuleAutoGenList:
>             if Module.MetaFile == self.MetaFile:
>@@ -3029,11 +3042,11 @@ class ModuleAutoGen(AutoGen):
>             self._DepexDict = {}
>             if self.DxsFile or self.IsLibrary or 
>TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:
>                 return self._DepexDict
>
>             self._DepexDict[self.ModuleType] = []
>-
>+            self._GetFixedAtBuildVoidTypePcds()
>             for ModuleType in self._DepexDict:
>                 DepexList = self._DepexDict[ModuleType]
>                 #
>                 # Append depex from dependent libraries, if not "BEFORE", "AFTER"
>expresion
>                 #
>@@ -3041,11 +3054,22 @@ class ModuleAutoGen(AutoGen):
>                     Inherited = False
>                     for D in M.Depex[self.Arch, ModuleType]:
>                         if DepexList != []:
>                             DepexList.append('AND')
>                         DepexList.append('(')
>-                        DepexList.extend(D)
>+                        #replace D with value if D is FixedAtBuild PCD
>+                        NewList = []
>+                        for item in D:
>+                            if '.' not in item:
>+                                NewList.append(item)
>+                            else:
>+                                if item not in self._FixedPcdVoidTypeDict:
>+                                    EdkLogger.error("build", 
>+ FORMAT_INVALID, "{} used in
>[Depex] section should be used as FixedAtBuild type and VOID* datum 
>type in the module.".format(item))
>+                                else:
>+                                    Value = self._FixedPcdVoidTypeDict[item]
>+                                    NewList.append(Value)
>+                        DepexList.extend(NewList)
>                         if DepexList[-1] == 'END':  # no need of a END at this time
>                             DepexList.pop()
>                         DepexList.append(')')
>                         Inherited = True
>                     if Inherited:
>@@ -4409,10 +4433,11 @@ class ModuleAutoGen(AutoGen):
>     BuildOptionIncPathList  = property(_GetBuildOptionIncPathList)
>     BuildCommand            = property(_GetBuildCommand)
>
>     FixedAtBuildPcds         = property(_GetFixedAtBuildPcds)
>     UniqueBaseName          = property(_GetUniqueBaseName)
>+    FixedVoidTypePcds       = property(_GetFixedAtBuildVoidTypePcds)
>
> # This acts like the main() function for the script, unless it is 
>'import'ed into another script.
> if __name__ == '__main__':
>     pass
>
>diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py
>b/BaseTools/Source/Python/AutoGen/GenDepex.py
>index d3b1eae..c12b613 100644
>--- a/BaseTools/Source/Python/AutoGen/GenDepex.py
>+++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
>@@ -20,10 +20,12 @@ from Common.LongFilePathSupport import 
>OpenLongFilePath as open  from io import BytesIO  from struct import 
>pack  from Common.BuildToolError import *  from Common.Misc import 
>SaveFileOnChange  from Common.Misc import 
>GuidStructureStringToGuidString
>+from Common.Misc import GuidStructureByteArrayToGuidString
>+from Common.Misc import GuidStringToGuidStructureString
> from Common import EdkLogger as EdkLogger from Common.BuildVersion 
> import gBUILD_VERSION from Common.DataType import *
>
> ## Regular expression for matching "DEPENDENCY_START ...
>DEPENDENCY_END"
>@@ -331,10 +333,14 @@ class DependencyExpression:
>     #   @retval array   The byte array representing the GUID value
>     #
>     def GetGuidValue(self, Guid):
>         GuidValueString = Guid.replace("{", "").replace("}", "").replace(" ", "")
>         GuidValueList = GuidValueString.split(",")
>+        if len(GuidValueList) != 11 and len(GuidValueList) == 16:
>+            GuidValueString =
>GuidStringToGuidStructureString(GuidStructureByteArrayToGuidString(Guid
>))
>+            GuidValueString = GuidValueString.replace("{", 
>+ "").replace("}",
>"").replace(" ", "")
>+            GuidValueList = GuidValueString.split(",")
>         if len(GuidValueList) != 11:
>             EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid GUID 
>value string or opcode: %s" % Guid)
>         return pack("1I2H8B", *(int(value, 16) for value in 
>GuidValueList))
>
>     ## Save the binary form of dependency expression in file diff 
>--git a/BaseTools/Source/Python/Workspace/InfBuildData.py
>b/BaseTools/Source/Python/Workspace/InfBuildData.py
>index 165e03f..efb3de1 100644
>--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
>@@ -909,16 +909,21 @@ class InfBuildData(ModuleBuildClassObject):
>                         if Module is None:
>                             EdkLogger.error('build', 
>RESOURCE_NOT_AVAILABLE, "Module is not found in active platform",
>                                             ExtraData=Token, File=self.MetaFile, Line=Record[-1])
>                         DepexList.append(Module.Guid)
>                     else:
>-                        # get the GUID value now
>-                        Value = ProtocolValue(Token, self.Packages, self.MetaFile.Path)
>-                        if Value is None:
>-                            Value = PpiValue(Token, self.Packages, self.MetaFile.Path)
>+                        # it use the Fixed PCD format
>+                        if '.' in Token:
>+                            Value = Token
>+                        else:
>+                            # get the GUID value now
>+                            Value = ProtocolValue(Token, 
>+ self.Packages,
>self.MetaFile.Path)
>                             if Value is None:
>-                                Value = GuidValue(Token, self.Packages, self.MetaFile.Path)
>+                                Value = PpiValue(Token, self.Packages, self.MetaFile.Path)
>+                                if Value is None:
>+                                    Value = GuidValue(Token, 
>+ self.Packages,
>self.MetaFile.Path)
>+
>                         if Value is None:
>                             PackageList = "\n\t".join(str(P) for P in self.Packages)
>                             EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
>                                             "Value of [%s] is not found in" % Token,
>                                             ExtraData=PackageList, 
>File=self.MetaFile,
>Line=Record[-1])
>diff --git a/BaseTools/Source/Python/build/BuildReport.py
>b/BaseTools/Source/Python/build/BuildReport.py
>index 897167c..0dbbba0 100644
>--- a/BaseTools/Source/Python/build/BuildReport.py
>+++ b/BaseTools/Source/Python/build/BuildReport.py
>@@ -278,10 +278,16 @@ class DepexParser(object):
>                     GuidValue = GuidStructureStringToGuidString(Package.Ppis[Ppi])
>                     self._GuidDb[GuidValue.upper()] = Ppi
>                 for Guid in Package.Guids:
>                     GuidValue = GuidStructureStringToGuidString(Package.Guids[Guid])
>                     self._GuidDb[GuidValue.upper()] = Guid
>+            for Ma in Pa.ModuleAutoGenList:
>+                for Pcd in Ma.FixedVoidTypePcds:
>+                    PcdValue = Ma.FixedVoidTypePcds[Pcd]
>+                    if len(PcdValue.split(',')) == 16:
>+                        GuidValue = GuidStructureByteArrayToGuidString(PcdValue)
>+                        self._GuidDb[GuidValue.upper()] = Pcd
>
>     ##
>     # Parse the binary dependency expression files.
>     #
>     # This function parses the binary dependency expression file and 
>translate it
>--
>2.6.1.windows.1
>
>_______________________________________________
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel


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

* Re: [Patch V2] BaseTools: enable FixedAtBuild (VOID*) PCD use in the [DEPEX] section
  2018-07-06  1:58   ` Zhu, Yonghong
@ 2018-07-06  2:06     ` Gao, Liming
  0 siblings, 0 replies; 4+ messages in thread
From: Gao, Liming @ 2018-07-06  2:06 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org

Yes. It is too late. The error message says the byte value is wrong. But, it doesn't mention which PCD is wrong.  

>-----Original Message-----
>From: Zhu, Yonghong
>Sent: Friday, July 06, 2018 9:58 AM
>To: Gao, Liming <liming.gao@intel.com>; edk2-devel@lists.01.org
>Cc: Zhu, Yonghong <yonghong.zhu@intel.com>
>Subject: RE: [edk2] [Patch V2] BaseTools: enable FixedAtBuild (VOID*) PCD
>use in the [DEPEX] section
>
>In  GetGuidValue() function it already have this logic to handle it.
>
>Best Regards,
>Zhu Yonghong
>
>
>-----Original Message-----
>From: Gao, Liming
>Sent: Friday, July 06, 2018 9:55 AM
>To: Zhu, Yonghong <yonghong.zhu@intel.com>; edk2-devel@lists.01.org
>Subject: RE: [edk2] [Patch V2] BaseTools: enable FixedAtBuild (VOID*) PCD
>use in the [DEPEX] section
>
>Yonghong:
>  On error handling, could you check VOID* PCD length to make sure its size is
>16 when it is used in [Depex] section?
>
>Thanks
>Liming
>>-----Original Message-----
>>From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>>Yonghong Zhu
>>Sent: Thursday, July 05, 2018 3:28 PM
>>To: edk2-devel@lists.01.org
>>Cc: Gao, Liming <liming.gao@intel.com>
>>Subject: [edk2] [Patch V2] BaseTools: enable FixedAtBuild (VOID*) PCD
>>use in the [DEPEX] section
>>
>>From: Yunhua Feng <yunhuax.feng@intel.com>
>>
>>V2: limit the PCD used in the [Depex] section should be used in the
>>module
>>
>>The PCD item used in INF [Depex] section must be defined as
>>FixedAtBuild type and VOID* datum type, and the size of the PCD must be
>16 bytes.
>>
>>Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=443
>>Cc: Liming Gao <liming.gao@intel.com>
>>Cc: Yonghong Zhu <yonghong.zhu@intel.com>
>>Contributed-under: TianoCore Contribution Agreement 1.1
>>Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
>>---
>> BaseTools/Source/Python/AutoGen/AutoGen.py        | 31
>>++++++++++++++++++++---
>> BaseTools/Source/Python/AutoGen/GenDepex.py       |  6 +++++
>> BaseTools/Source/Python/Workspace/InfBuildData.py | 15 +++++++----
>> BaseTools/Source/Python/build/BuildReport.py      |  6 +++++
>> 4 files changed, 50 insertions(+), 8 deletions(-)
>>
>>diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
>>b/BaseTools/Source/Python/AutoGen/AutoGen.py
>>index 6d76afd..7d4539e 100644
>>--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
>>+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
>>@@ -2745,10 +2745,14 @@ class ModuleAutoGen(AutoGen):
>>         ## Store the FixedAtBuild Pcds
>>         #
>>         self._FixedAtBuildPcds         = []
>>         self.ConstPcd                  = {}
>>
>>+        ##Store the VOID* type FixedAtBuild Pcds
>>+        #
>>+        self._FixedPcdVoidTypeDict = {}
>>+
>>     def __repr__(self):
>>         return "%s [%s]" % (self.MetaFile, self.Arch)
>>
>>     # Get FixedAtBuild Pcds of this Module
>>     def _GetFixedAtBuildPcds(self):
>>@@ -2758,11 +2762,20 @@ class ModuleAutoGen(AutoGen):
>>             if Pcd.Type != TAB_PCDS_FIXED_AT_BUILD:
>>                 continue
>>             if Pcd not in self._FixedAtBuildPcds:
>>                 self._FixedAtBuildPcds.append(Pcd)
>>
>>-        return self._FixedAtBuildPcds
>>+        return self._FixedAtBuildPcds
>>+
>>+    def _GetFixedAtBuildVoidTypePcds(self):
>>+        if self._FixedPcdVoidTypeDict:
>>+            return self._FixedPcdVoidTypeDict
>>+        for Pcd in self.ModulePcdList:
>>+            if Pcd.Type == TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType
>>+ ==
>>TAB_VOID:
>>+                if '{}.{}'.format(Pcd.TokenSpaceGuidCName,
>>+ Pcd.TokenCName) not
>>in self._FixedPcdVoidTypeDict:
>>+
>>self._FixedPcdVoidTypeDict['{}.{}'.format(Pcd.TokenSpaceGuidCName,
>>Pcd.TokenCName)] = Pcd.DefaultValue
>>+        return self._FixedPcdVoidTypeDict
>>
>>     def _GetUniqueBaseName(self):
>>         BaseName = self.Name
>>         for Module in self.PlatformInfo.ModuleAutoGenList:
>>             if Module.MetaFile == self.MetaFile:
>>@@ -3029,11 +3042,11 @@ class ModuleAutoGen(AutoGen):
>>             self._DepexDict = {}
>>             if self.DxsFile or self.IsLibrary or
>>TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:
>>                 return self._DepexDict
>>
>>             self._DepexDict[self.ModuleType] = []
>>-
>>+            self._GetFixedAtBuildVoidTypePcds()
>>             for ModuleType in self._DepexDict:
>>                 DepexList = self._DepexDict[ModuleType]
>>                 #
>>                 # Append depex from dependent libraries, if not "BEFORE", "AFTER"
>>expresion
>>                 #
>>@@ -3041,11 +3054,22 @@ class ModuleAutoGen(AutoGen):
>>                     Inherited = False
>>                     for D in M.Depex[self.Arch, ModuleType]:
>>                         if DepexList != []:
>>                             DepexList.append('AND')
>>                         DepexList.append('(')
>>-                        DepexList.extend(D)
>>+                        #replace D with value if D is FixedAtBuild PCD
>>+                        NewList = []
>>+                        for item in D:
>>+                            if '.' not in item:
>>+                                NewList.append(item)
>>+                            else:
>>+                                if item not in self._FixedPcdVoidTypeDict:
>>+                                    EdkLogger.error("build",
>>+ FORMAT_INVALID, "{} used in
>>[Depex] section should be used as FixedAtBuild type and VOID* datum
>>type in the module.".format(item))
>>+                                else:
>>+                                    Value = self._FixedPcdVoidTypeDict[item]
>>+                                    NewList.append(Value)
>>+                        DepexList.extend(NewList)
>>                         if DepexList[-1] == 'END':  # no need of a END at this time
>>                             DepexList.pop()
>>                         DepexList.append(')')
>>                         Inherited = True
>>                     if Inherited:
>>@@ -4409,10 +4433,11 @@ class ModuleAutoGen(AutoGen):
>>     BuildOptionIncPathList  = property(_GetBuildOptionIncPathList)
>>     BuildCommand            = property(_GetBuildCommand)
>>
>>     FixedAtBuildPcds         = property(_GetFixedAtBuildPcds)
>>     UniqueBaseName          = property(_GetUniqueBaseName)
>>+    FixedVoidTypePcds       = property(_GetFixedAtBuildVoidTypePcds)
>>
>> # This acts like the main() function for the script, unless it is
>>'import'ed into another script.
>> if __name__ == '__main__':
>>     pass
>>
>>diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py
>>b/BaseTools/Source/Python/AutoGen/GenDepex.py
>>index d3b1eae..c12b613 100644
>>--- a/BaseTools/Source/Python/AutoGen/GenDepex.py
>>+++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
>>@@ -20,10 +20,12 @@ from Common.LongFilePathSupport import
>>OpenLongFilePath as open  from io import BytesIO  from struct import
>>pack  from Common.BuildToolError import *  from Common.Misc import
>>SaveFileOnChange  from Common.Misc import
>>GuidStructureStringToGuidString
>>+from Common.Misc import GuidStructureByteArrayToGuidString
>>+from Common.Misc import GuidStringToGuidStructureString
>> from Common import EdkLogger as EdkLogger from Common.BuildVersion
>> import gBUILD_VERSION from Common.DataType import *
>>
>> ## Regular expression for matching "DEPENDENCY_START ...
>>DEPENDENCY_END"
>>@@ -331,10 +333,14 @@ class DependencyExpression:
>>     #   @retval array   The byte array representing the GUID value
>>     #
>>     def GetGuidValue(self, Guid):
>>         GuidValueString = Guid.replace("{", "").replace("}", "").replace(" ", "")
>>         GuidValueList = GuidValueString.split(",")
>>+        if len(GuidValueList) != 11 and len(GuidValueList) == 16:
>>+            GuidValueString =
>>GuidStringToGuidStructureString(GuidStructureByteArrayToGuidString(Guid
>>))
>>+            GuidValueString = GuidValueString.replace("{",
>>+ "").replace("}",
>>"").replace(" ", "")
>>+            GuidValueList = GuidValueString.split(",")
>>         if len(GuidValueList) != 11:
>>             EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid GUID
>>value string or opcode: %s" % Guid)
>>         return pack("1I2H8B", *(int(value, 16) for value in
>>GuidValueList))
>>
>>     ## Save the binary form of dependency expression in file diff
>>--git a/BaseTools/Source/Python/Workspace/InfBuildData.py
>>b/BaseTools/Source/Python/Workspace/InfBuildData.py
>>index 165e03f..efb3de1 100644
>>--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
>>+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
>>@@ -909,16 +909,21 @@ class InfBuildData(ModuleBuildClassObject):
>>                         if Module is None:
>>                             EdkLogger.error('build',
>>RESOURCE_NOT_AVAILABLE, "Module is not found in active platform",
>>                                             ExtraData=Token, File=self.MetaFile, Line=Record[-1])
>>                         DepexList.append(Module.Guid)
>>                     else:
>>-                        # get the GUID value now
>>-                        Value = ProtocolValue(Token, self.Packages, self.MetaFile.Path)
>>-                        if Value is None:
>>-                            Value = PpiValue(Token, self.Packages, self.MetaFile.Path)
>>+                        # it use the Fixed PCD format
>>+                        if '.' in Token:
>>+                            Value = Token
>>+                        else:
>>+                            # get the GUID value now
>>+                            Value = ProtocolValue(Token,
>>+ self.Packages,
>>self.MetaFile.Path)
>>                             if Value is None:
>>-                                Value = GuidValue(Token, self.Packages, self.MetaFile.Path)
>>+                                Value = PpiValue(Token, self.Packages, self.MetaFile.Path)
>>+                                if Value is None:
>>+                                    Value = GuidValue(Token,
>>+ self.Packages,
>>self.MetaFile.Path)
>>+
>>                         if Value is None:
>>                             PackageList = "\n\t".join(str(P) for P in self.Packages)
>>                             EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
>>                                             "Value of [%s] is not found in" % Token,
>>                                             ExtraData=PackageList,
>>File=self.MetaFile,
>>Line=Record[-1])
>>diff --git a/BaseTools/Source/Python/build/BuildReport.py
>>b/BaseTools/Source/Python/build/BuildReport.py
>>index 897167c..0dbbba0 100644
>>--- a/BaseTools/Source/Python/build/BuildReport.py
>>+++ b/BaseTools/Source/Python/build/BuildReport.py
>>@@ -278,10 +278,16 @@ class DepexParser(object):
>>                     GuidValue = GuidStructureStringToGuidString(Package.Ppis[Ppi])
>>                     self._GuidDb[GuidValue.upper()] = Ppi
>>                 for Guid in Package.Guids:
>>                     GuidValue =
>GuidStructureStringToGuidString(Package.Guids[Guid])
>>                     self._GuidDb[GuidValue.upper()] = Guid
>>+            for Ma in Pa.ModuleAutoGenList:
>>+                for Pcd in Ma.FixedVoidTypePcds:
>>+                    PcdValue = Ma.FixedVoidTypePcds[Pcd]
>>+                    if len(PcdValue.split(',')) == 16:
>>+                        GuidValue = GuidStructureByteArrayToGuidString(PcdValue)
>>+                        self._GuidDb[GuidValue.upper()] = Pcd
>>
>>     ##
>>     # Parse the binary dependency expression files.
>>     #
>>     # This function parses the binary dependency expression file and
>>translate it
>>--
>>2.6.1.windows.1
>>
>>_______________________________________________
>>edk2-devel mailing list
>>edk2-devel@lists.01.org
>>https://lists.01.org/mailman/listinfo/edk2-devel


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

end of thread, other threads:[~2018-07-06  2:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-05  7:27 [Patch V2] BaseTools: enable FixedAtBuild (VOID*) PCD use in the [DEPEX] section Yonghong Zhu
2018-07-06  1:55 ` Gao, Liming
2018-07-06  1:58   ` Zhu, Yonghong
2018-07-06  2:06     ` Gao, Liming

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