[edk2] [Patch V2] BaseTools: Enhance BaseTools supports FixedAtBuild usage in VFR file

Yonghong Zhu posted 1 patch 7 years, 8 months ago
Failed in applying to current master (apply log)
BaseTools/Source/Python/AutoGen/AutoGen.py | 13 ++++++++++++-
BaseTools/Source/Python/AutoGen/GenC.py    | 25 ++++++++++++++++++++++++-
BaseTools/Source/Python/Common/DataType.py |  3 ++-
3 files changed, 38 insertions(+), 3 deletions(-)
[edk2] [Patch V2] BaseTools: Enhance BaseTools supports FixedAtBuild usage in VFR file
Posted by Yonghong Zhu 7 years, 8 months ago
This patch is to update BaseTools generate Fixed PCD APIs and Value into
$(MODULE_NAME)StrDefs.h for VFR only. If the module has VFR files, and it
directly consumes FixedAtBuild PCD, BaseTool will generate those
FixedAtBuild PCD value into its $(MODULE_NAME)StrDefs.h. FixedPcdGetXX
macro are always generated. Every FixedPcd _PCD_VALUE_PcdName will be
generated without the postfix U or UL or ULL.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=348
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 13 ++++++++++++-
 BaseTools/Source/Python/AutoGen/GenC.py    | 25 ++++++++++++++++++++++++-
 BaseTools/Source/Python/Common/DataType.py |  3 ++-
 3 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index f35ae25..c35f0b2 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1,9 +1,9 @@
 ## @file
 # Generate AutoGen.h, AutoGen.c and *.depex files
 #
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
 # which accompanies this distribution.  The full text of the license may be found at
 # http://opensource.org/licenses/bsd-license.php
 #
@@ -2589,10 +2589,11 @@ class ModuleAutoGen(AutoGen):
 
         self._IncludePathList = None
         self._IncludePathLength = 0
         self._AutoGenFileList = None
         self._UnicodeFileList = None
+        self._VfrFileList = None
         self._IdfFileList = None
         self._SourceFileList  = None
         self._ObjectFileList  = None
         self._BinaryFileList  = None
 
@@ -3114,10 +3115,19 @@ class ModuleAutoGen(AutoGen):
                 self._UnicodeFileList = self.FileTypes[TAB_UNICODE_FILE]
             else:
                 self._UnicodeFileList = []
         return self._UnicodeFileList
 
+    ## Return the list of vfr files
+    def _GetVfrFileList(self):
+        if self._VfrFileList == None:
+            if TAB_VFR_FILE in self.FileTypes:
+                self._VfrFileList = self.FileTypes[TAB_VFR_FILE]
+            else:
+                self._VfrFileList = []
+        return self._VfrFileList
+
     ## Return the list of Image Definition files
     def _GetIdfFileList(self):
         if self._IdfFileList == None:
             if TAB_IMAGE_FILE in self.FileTypes:
                 self._IdfFileList = self.FileTypes[TAB_IMAGE_FILE]
@@ -4078,10 +4088,11 @@ class ModuleAutoGen(AutoGen):
 
     IncludePathList = property(_GetIncludePathList)
     IncludePathLength = property(_GetIncludePathLength)
     AutoGenFileList = property(_GetAutoGenFileList)
     UnicodeFileList = property(_GetUnicodeFileList)
+    VfrFileList     = property(_GetVfrFileList)
     SourceFileList  = property(_GetSourceFileList)
     BinaryFileList  = property(_GetBinaryFiles) # FileType : [File List]
     Targets         = property(_GetTargets)
     IntroTargetList = property(_GetIntroTargetList)
     CodaTargetList  = property(_GetFinalTargetList)
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 63cfe04..c1d64cc 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1,9 +1,9 @@
 ## @file
 # Routines for generating AutoGen.h and AutoGen.c
 #
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
 # which accompanies this distribution.  The full text of the license may be found at
 # http://opensource.org/licenses/bsd-license.php
 #
@@ -1958,10 +1958,33 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBuffer,
             if Guid in Info.Module.GetGuidsUsedByPcd():
                 continue
             GuidMacros.append('#define %s %s' % (Guid, Info.Module.Guids[Guid]))
         for Guid, Value in Info.Module.Protocols.items() + Info.Module.Ppis.items():
             GuidMacros.append('#define %s %s' % (Guid, Value))
+        # supports FixedAtBuild usage in VFR file
+        if Info.VfrFileList and Info.ModulePcdList:
+            GuidMacros.append('#define %s %s' % ('FixedPcdGetBool(TokenName)', '_PCD_VALUE_##TokenName'))
+            GuidMacros.append('#define %s %s' % ('FixedPcdGet8(TokenName)', '_PCD_VALUE_##TokenName'))
+            GuidMacros.append('#define %s %s' % ('FixedPcdGet16(TokenName)', '_PCD_VALUE_##TokenName'))
+            GuidMacros.append('#define %s %s' % ('FixedPcdGet32(TokenName)', '_PCD_VALUE_##TokenName'))
+            GuidMacros.append('#define %s %s' % ('FixedPcdGet64(TokenName)', '_PCD_VALUE_##TokenName'))
+            for Pcd in Info.ModulePcdList:
+                if Pcd.Type == TAB_PCDS_FIXED_AT_BUILD:
+                    TokenCName = Pcd.TokenCName
+                    Value = Pcd.DefaultValue
+                    if Pcd.DatumType == 'BOOLEAN':
+                        BoolValue = Value.upper()
+                        if BoolValue == 'TRUE':
+                            Value = '1'
+                        elif BoolValue == 'FALSE':
+                            Value = '0'
+                    for PcdItem in GlobalData.MixedPcd:
+                        if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
+                            TokenCName = PcdItem[0]
+                            break
+                    GuidMacros.append('#define %s %s' % ('_PCD_VALUE_'+TokenCName, Value))
+
         if GuidMacros:
             StringH.Append('\n#ifdef VFRCOMPILE\n%s\n#endif\n' % '\n'.join(GuidMacros))
 
         StringH.Append("\n#endif\n")
         AutoGenH.Append('#include "%s"\n' % FileName)
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 60cbfbe..6edc0c0 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -1,9 +1,9 @@
 ## @file
 # This file is used to define common static strings used by INF/DEC/DSC files
 #
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 # Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
 # which accompanies this distribution.  The full text of the license may be found at
 # http://opensource.org/licenses/bsd-license.php
@@ -472,10 +472,11 @@ TAB_UNICODE_FILE = "UNICODE-TEXT-FILE"
 TAB_IMAGE_FILE = "IMAGE-DEFINITION-FILE"
 TAB_DEPENDENCY_EXPRESSION_FILE = "DEPENDENCY-EXPRESSION-FILE"
 TAB_UNKNOWN_FILE = "UNKNOWN-TYPE-FILE"
 TAB_DEFAULT_BINARY_FILE = "_BINARY_FILE_"
 TAB_OBJECT_FILE = "OBJECT-FILE"
+TAB_VFR_FILE = 'VISUAL-FORM-REPRESENTATION-FILE'
 
 # used by BRG
 TAB_BRG_PCD = 'PCD'
 TAB_BRG_LIBRARY = 'Library'
 
-- 
2.6.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch V2] BaseTools: Enhance BaseTools supports FixedAtBuild usage in VFR file
Posted by Gao, Liming 7 years, 8 months ago
Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Zhu, Yonghong
>Sent: Monday, February 13, 2017 2:03 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>Subject: [Patch V2] BaseTools: Enhance BaseTools supports FixedAtBuild
>usage in VFR file
>
>This patch is to update BaseTools generate Fixed PCD APIs and Value into
>$(MODULE_NAME)StrDefs.h for VFR only. If the module has VFR files, and it
>directly consumes FixedAtBuild PCD, BaseTool will generate those
>FixedAtBuild PCD value into its $(MODULE_NAME)StrDefs.h. FixedPcdGetXX
>macro are always generated. Every FixedPcd _PCD_VALUE_PcdName will be
>generated without the postfix U or UL or ULL.
>
>Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=348
>Cc: Liming Gao <liming.gao@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
>---
> BaseTools/Source/Python/AutoGen/AutoGen.py | 13 ++++++++++++-
> BaseTools/Source/Python/AutoGen/GenC.py    | 25
>++++++++++++++++++++++++-
> BaseTools/Source/Python/Common/DataType.py |  3 ++-
> 3 files changed, 38 insertions(+), 3 deletions(-)
>
>diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
>b/BaseTools/Source/Python/AutoGen/AutoGen.py
>index f35ae25..c35f0b2 100644
>--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
>+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
>@@ -1,9 +1,9 @@
> ## @file
> # Generate AutoGen.h, AutoGen.c and *.depex files
> #
>-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
>+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD
>License
> # which accompanies this distribution.  The full text of the license may be
>found at
> # http://opensource.org/licenses/bsd-license.php
> #
>@@ -2589,10 +2589,11 @@ class ModuleAutoGen(AutoGen):
>
>         self._IncludePathList = None
>         self._IncludePathLength = 0
>         self._AutoGenFileList = None
>         self._UnicodeFileList = None
>+        self._VfrFileList = None
>         self._IdfFileList = None
>         self._SourceFileList  = None
>         self._ObjectFileList  = None
>         self._BinaryFileList  = None
>
>@@ -3114,10 +3115,19 @@ class ModuleAutoGen(AutoGen):
>                 self._UnicodeFileList = self.FileTypes[TAB_UNICODE_FILE]
>             else:
>                 self._UnicodeFileList = []
>         return self._UnicodeFileList
>
>+    ## Return the list of vfr files
>+    def _GetVfrFileList(self):
>+        if self._VfrFileList == None:
>+            if TAB_VFR_FILE in self.FileTypes:
>+                self._VfrFileList = self.FileTypes[TAB_VFR_FILE]
>+            else:
>+                self._VfrFileList = []
>+        return self._VfrFileList
>+
>     ## Return the list of Image Definition files
>     def _GetIdfFileList(self):
>         if self._IdfFileList == None:
>             if TAB_IMAGE_FILE in self.FileTypes:
>                 self._IdfFileList = self.FileTypes[TAB_IMAGE_FILE]
>@@ -4078,10 +4088,11 @@ class ModuleAutoGen(AutoGen):
>
>     IncludePathList = property(_GetIncludePathList)
>     IncludePathLength = property(_GetIncludePathLength)
>     AutoGenFileList = property(_GetAutoGenFileList)
>     UnicodeFileList = property(_GetUnicodeFileList)
>+    VfrFileList     = property(_GetVfrFileList)
>     SourceFileList  = property(_GetSourceFileList)
>     BinaryFileList  = property(_GetBinaryFiles) # FileType : [File List]
>     Targets         = property(_GetTargets)
>     IntroTargetList = property(_GetIntroTargetList)
>     CodaTargetList  = property(_GetFinalTargetList)
>diff --git a/BaseTools/Source/Python/AutoGen/GenC.py
>b/BaseTools/Source/Python/AutoGen/GenC.py
>index 63cfe04..c1d64cc 100644
>--- a/BaseTools/Source/Python/AutoGen/GenC.py
>+++ b/BaseTools/Source/Python/AutoGen/GenC.py
>@@ -1,9 +1,9 @@
> ## @file
> # Routines for generating AutoGen.h and AutoGen.c
> #
>-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
>+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD
>License
> # which accompanies this distribution.  The full text of the license may be
>found at
> # http://opensource.org/licenses/bsd-license.php
> #
>@@ -1958,10 +1958,33 @@ def CreateCode(Info, AutoGenC, AutoGenH,
>StringH, UniGenCFlag, UniGenBinBuffer,
>             if Guid in Info.Module.GetGuidsUsedByPcd():
>                 continue
>             GuidMacros.append('#define %s %s' % (Guid,
>Info.Module.Guids[Guid]))
>         for Guid, Value in Info.Module.Protocols.items() +
>Info.Module.Ppis.items():
>             GuidMacros.append('#define %s %s' % (Guid, Value))
>+        # supports FixedAtBuild usage in VFR file
>+        if Info.VfrFileList and Info.ModulePcdList:
>+            GuidMacros.append('#define %s %s' %
>('FixedPcdGetBool(TokenName)', '_PCD_VALUE_##TokenName'))
>+            GuidMacros.append('#define %s %s' % ('FixedPcdGet8(TokenName)',
>'_PCD_VALUE_##TokenName'))
>+            GuidMacros.append('#define %s %s' % ('FixedPcdGet16(TokenName)',
>'_PCD_VALUE_##TokenName'))
>+            GuidMacros.append('#define %s %s' % ('FixedPcdGet32(TokenName)',
>'_PCD_VALUE_##TokenName'))
>+            GuidMacros.append('#define %s %s' % ('FixedPcdGet64(TokenName)',
>'_PCD_VALUE_##TokenName'))
>+            for Pcd in Info.ModulePcdList:
>+                if Pcd.Type == TAB_PCDS_FIXED_AT_BUILD:
>+                    TokenCName = Pcd.TokenCName
>+                    Value = Pcd.DefaultValue
>+                    if Pcd.DatumType == 'BOOLEAN':
>+                        BoolValue = Value.upper()
>+                        if BoolValue == 'TRUE':
>+                            Value = '1'
>+                        elif BoolValue == 'FALSE':
>+                            Value = '0'
>+                    for PcdItem in GlobalData.MixedPcd:
>+                        if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in
>GlobalData.MixedPcd[PcdItem]:
>+                            TokenCName = PcdItem[0]
>+                            break
>+                    GuidMacros.append('#define %s %s' %
>('_PCD_VALUE_'+TokenCName, Value))
>+
>         if GuidMacros:
>             StringH.Append('\n#ifdef VFRCOMPILE\n%s\n#endif\n' %
>'\n'.join(GuidMacros))
>
>         StringH.Append("\n#endif\n")
>         AutoGenH.Append('#include "%s"\n' % FileName)
>diff --git a/BaseTools/Source/Python/Common/DataType.py
>b/BaseTools/Source/Python/Common/DataType.py
>index 60cbfbe..6edc0c0 100644
>--- a/BaseTools/Source/Python/Common/DataType.py
>+++ b/BaseTools/Source/Python/Common/DataType.py
>@@ -1,9 +1,9 @@
> ## @file
> # This file is used to define common static strings used by INF/DEC/DSC files
> #
>-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
>+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> # Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD
>License
> # which accompanies this distribution.  The full text of the license may be
>found at
> # http://opensource.org/licenses/bsd-license.php
>@@ -472,10 +472,11 @@ TAB_UNICODE_FILE = "UNICODE-TEXT-FILE"
> TAB_IMAGE_FILE = "IMAGE-DEFINITION-FILE"
> TAB_DEPENDENCY_EXPRESSION_FILE = "DEPENDENCY-EXPRESSION-FILE"
> TAB_UNKNOWN_FILE = "UNKNOWN-TYPE-FILE"
> TAB_DEFAULT_BINARY_FILE = "_BINARY_FILE_"
> TAB_OBJECT_FILE = "OBJECT-FILE"
>+TAB_VFR_FILE = 'VISUAL-FORM-REPRESENTATION-FILE'
>
> # used by BRG
> TAB_BRG_PCD = 'PCD'
> TAB_BRG_LIBRARY = 'Library'
>
>--
>2.6.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel