]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/FfsInfStatement.py
BaseTools: Update --pcd parser to support flexible pcd format
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FfsInfStatement.py
index dfff892e21491e51c251c4a88dc3b6906bb44800..a348233911718de64e1890b81b1156f427e6248e 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process FFS generation from INF statement\r
 #\r
-#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #  Copyright (c) 2014-2016 Hewlett-Packard Development Company, L.P.<BR>\r
 #\r
 #  This program and the accompanying materials\r
@@ -274,7 +274,9 @@ class FfsInfStatement(FfsInfStatementClassObject):
             if GlobalData.BuildOptionPcd:\r
                 for pcd in GlobalData.BuildOptionPcd:\r
                     if PcdKey == (pcd[1], pcd[0]):\r
-                        DefaultValue = pcd[2]\r
+                        if pcd[2]:\r
+                            continue\r
+                        DefaultValue = pcd[3]\r
                         BuildOptionOverride = True\r
                         break\r
 \r
@@ -288,15 +290,15 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 except BadExpression:\r
                     EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] Value "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValue), File=self.InfFileName)\r
 \r
-            if Pcd.DefaultValue:\r
+            if Pcd.InfDefaultValue:\r
                 try:\r
-                    Pcd.DefaultValue = ValueExpressionEx(Pcd.DefaultValue, Pcd.DatumType, Platform._GuidDict)(True)\r
+                    Pcd.InfDefaultValue = ValueExpressionEx(Pcd.InfDefaultValue, Pcd.DatumType, Platform._GuidDict)(True)\r
                 except BadExpression:\r
                     EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] Value "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DefaultValue),File=self.InfFileName)\r
 \r
             # Check value, if value are equal, no need to patch\r
             if Pcd.DatumType == "VOID*":\r
-                if Pcd.DefaultValue == DefaultValue or DefaultValue in [None, '']:\r
+                if Pcd.InfDefaultValue == DefaultValue or DefaultValue in [None, '']:\r
                     continue\r
                 # Get the string size from FDF or DSC\r
                 if DefaultValue[0] == 'L':\r
@@ -310,15 +312,15 @@ class FfsInfStatement(FfsInfStatementClassObject):
                     Pcd.MaxDatumSize = PatchPcd.MaxDatumSize\r
                 # If no defined the maximum size in DSC, try to get current size from INF\r
                 if Pcd.MaxDatumSize in ['', None]:\r
-                    Pcd.MaxDatumSize = str(len(Pcd.DefaultValue.split(',')))\r
+                    Pcd.MaxDatumSize = str(len(Pcd.InfDefaultValue.split(',')))\r
             else:\r
                 Base1 = Base2 = 10\r
-                if Pcd.DefaultValue.upper().startswith('0X'):\r
+                if Pcd.InfDefaultValue.upper().startswith('0X'):\r
                     Base1 = 16\r
                 if DefaultValue.upper().startswith('0X'):\r
                     Base2 = 16\r
                 try:\r
-                    PcdValueInImg = int(Pcd.DefaultValue, Base1)\r
+                    PcdValueInImg = int(Pcd.InfDefaultValue, Base1)\r
                     PcdValueInDscOrFdf = int(DefaultValue, Base2)\r
                     if PcdValueInImg == PcdValueInDscOrFdf:\r
                         continue\r