]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Enhance BaseTools supports FixedAtBuild usage in VFR file
authorYonghong Zhu <yonghong.zhu@intel.com>
Mon, 13 Feb 2017 05:10:43 +0000 (13:10 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Tue, 14 Feb 2017 01:02:49 +0000 (09:02 +0800)
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>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/AutoGen/GenC.py
BaseTools/Source/Python/Common/DataType.py

index f35ae252b0c6cbd13a2f584af63932f3be4bc864..c35f0b2fdb86e52699e393ae55954f7d3dfaad49 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Generate AutoGen.h, AutoGen.c and *.depex files\r
 #\r
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -2591,6 +2591,7 @@ class ModuleAutoGen(AutoGen):
         self._IncludePathLength = 0\r
         self._AutoGenFileList = None\r
         self._UnicodeFileList = None\r
+        self._VfrFileList = None\r
         self._IdfFileList = None\r
         self._SourceFileList  = None\r
         self._ObjectFileList  = None\r
@@ -3116,6 +3117,15 @@ class ModuleAutoGen(AutoGen):
                 self._UnicodeFileList = []\r
         return self._UnicodeFileList\r
 \r
+    ## Return the list of vfr files\r
+    def _GetVfrFileList(self):\r
+        if self._VfrFileList == None:\r
+            if TAB_VFR_FILE in self.FileTypes:\r
+                self._VfrFileList = self.FileTypes[TAB_VFR_FILE]\r
+            else:\r
+                self._VfrFileList = []\r
+        return self._VfrFileList\r
+\r
     ## Return the list of Image Definition files\r
     def _GetIdfFileList(self):\r
         if self._IdfFileList == None:\r
@@ -4080,6 +4090,7 @@ class ModuleAutoGen(AutoGen):
     IncludePathLength = property(_GetIncludePathLength)\r
     AutoGenFileList = property(_GetAutoGenFileList)\r
     UnicodeFileList = property(_GetUnicodeFileList)\r
+    VfrFileList     = property(_GetVfrFileList)\r
     SourceFileList  = property(_GetSourceFileList)\r
     BinaryFileList  = property(_GetBinaryFiles) # FileType : [File List]\r
     Targets         = property(_GetTargets)\r
index 63cfe0422bbcac51def87b3648d7182632f699a2..c1d64cccfdba0b4b4305ced4a81e87c2aa7c09de 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Routines for generating AutoGen.h and AutoGen.c\r
 #\r
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -1960,6 +1960,29 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBuffer,
             GuidMacros.append('#define %s %s' % (Guid, Info.Module.Guids[Guid]))\r
         for Guid, Value in Info.Module.Protocols.items() + Info.Module.Ppis.items():\r
             GuidMacros.append('#define %s %s' % (Guid, Value))\r
+        # supports FixedAtBuild usage in VFR file\r
+        if Info.VfrFileList and Info.ModulePcdList:\r
+            GuidMacros.append('#define %s %s' % ('FixedPcdGetBool(TokenName)', '_PCD_VALUE_##TokenName'))\r
+            GuidMacros.append('#define %s %s' % ('FixedPcdGet8(TokenName)', '_PCD_VALUE_##TokenName'))\r
+            GuidMacros.append('#define %s %s' % ('FixedPcdGet16(TokenName)', '_PCD_VALUE_##TokenName'))\r
+            GuidMacros.append('#define %s %s' % ('FixedPcdGet32(TokenName)', '_PCD_VALUE_##TokenName'))\r
+            GuidMacros.append('#define %s %s' % ('FixedPcdGet64(TokenName)', '_PCD_VALUE_##TokenName'))\r
+            for Pcd in Info.ModulePcdList:\r
+                if Pcd.Type == TAB_PCDS_FIXED_AT_BUILD:\r
+                    TokenCName = Pcd.TokenCName\r
+                    Value = Pcd.DefaultValue\r
+                    if Pcd.DatumType == 'BOOLEAN':\r
+                        BoolValue = Value.upper()\r
+                        if BoolValue == 'TRUE':\r
+                            Value = '1'\r
+                        elif BoolValue == 'FALSE':\r
+                            Value = '0'\r
+                    for PcdItem in GlobalData.MixedPcd:\r
+                        if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r
+                            TokenCName = PcdItem[0]\r
+                            break\r
+                    GuidMacros.append('#define %s %s' % ('_PCD_VALUE_'+TokenCName, Value))\r
+\r
         if GuidMacros:\r
             StringH.Append('\n#ifdef VFRCOMPILE\n%s\n#endif\n' % '\n'.join(GuidMacros))\r
 \r
index 60cbfbed2dcda961222d9fd1aa4cac12e5b615a0..6edc0c095048ca2604a828cb76efa4a5f8819ca2 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to define common static strings used by INF/DEC/DSC files\r
 #\r
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 # Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
@@ -474,6 +474,7 @@ TAB_DEPENDENCY_EXPRESSION_FILE = "DEPENDENCY-EXPRESSION-FILE"
 TAB_UNKNOWN_FILE = "UNKNOWN-TYPE-FILE"\r
 TAB_DEFAULT_BINARY_FILE = "_BINARY_FILE_"\r
 TAB_OBJECT_FILE = "OBJECT-FILE"\r
+TAB_VFR_FILE = 'VISUAL-FORM-REPRESENTATION-FILE'\r
 \r
 # used by BRG\r
 TAB_BRG_PCD = 'PCD'\r