BaseTools: Structure Pcd in CommandLine.
authorFeng, Bob C <bob.c.feng@intel.com>
Wed, 31 Jan 2018 08:49:14 +0000 (16:49 +0800)
committerLiming Gao <liming.gao@intel.com>
Thu, 1 Feb 2018 01:21:47 +0000 (09:21 +0800)
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/Common/Expression.py
BaseTools/Source/Python/Common/Misc.py
BaseTools/Source/Python/GenFds/FfsInfStatement.py
BaseTools/Source/Python/GenFds/GenFds.py
BaseTools/Source/Python/Workspace/DscBuildData.py
BaseTools/Source/Python/build/build.py

index 1cf50e872fcd0f695bcdce1b2596000d5a4c367e..405bfa145a22b66251b5ec92c0a2d0da8095f6cc 100644 (file)
@@ -398,89 +398,10 @@ class WorkspaceAutoGen(AutoGen):
         for Arch in self.ArchList:\r
             Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r
 \r
-            DecPcds = {}\r
-            DecPcdsKey = set()\r
-            PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\r
-            if GlobalData.BuildOptionPcd:\r
-                for i, pcd in enumerate(GlobalData.BuildOptionPcd):\r
-                    if type(pcd) is tuple:\r
-                        continue\r
-                    (pcdname, pcdvalue) = pcd.split('=')\r
-                    if not pcdvalue:\r
-                        EdkLogger.error('build', AUTOGEN_ERROR, "No Value specified for the PCD %s." % (pcdname))\r
-                    if '.' in pcdname:\r
-                        (TokenSpaceGuidCName, TokenCName) = pcdname.split('.')\r
-                        HasTokenSpace = True\r
-                    else:\r
-                        TokenCName = pcdname\r
-                        TokenSpaceGuidCName = ''\r
-                        HasTokenSpace = False\r
-                    TokenSpaceGuidCNameList = []\r
-                    FoundFlag = False\r
-                    PcdDatumType = ''\r
-                    NewValue = ''\r
-                    for package in PGen.PackageList:\r
-                        Guids = package.Guids\r
-                        self._GuidDict.update(Guids)\r
-                    for package in PGen.PackageList:\r
-                        for key in package.Pcds:\r
-                            PcdItem = package.Pcds[key]\r
-                            if HasTokenSpace:\r
-                                if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName):\r
-                                    PcdDatumType = PcdItem.DatumType\r
-                                    if pcdvalue.startswith('H'):\r
-                                        try:\r
-                                            pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True)\r
-                                        except BadExpression, Value:\r
-                                            if Value.result > 1:\r
-                                                EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %\r
-                                                                (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
-                                        pcdvalue = 'H' + pcdvalue\r
-                                    NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
-                                    FoundFlag = True\r
-                            else:\r
-                                if PcdItem.TokenCName == TokenCName:\r
-                                    if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList:\r
-                                        if len (TokenSpaceGuidCNameList) < 1:\r
-                                            TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName)\r
-                                            PcdDatumType = PcdItem.DatumType\r
-                                            TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName\r
-                                            if pcdvalue.startswith('H'):\r
-                                                try:\r
-                                                    pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True)\r
-                                                except BadExpression, Value:\r
-                                                    EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
-                                                                    (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
-                                                pcdvalue = 'H' + pcdvalue\r
-                                            NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
-                                            FoundFlag = True\r
-                                        else:\r
-                                            EdkLogger.error(\r
-                                                    'build',\r
-                                                     AUTOGEN_ERROR,\r
-                                                    "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (TokenCName, PcdItem.TokenSpaceGuidCName, TokenSpaceGuidCNameList[0])\r
-                                                    )\r
 \r
-                    GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, NewValue)\r
 \r
-                    if not FoundFlag:\r
-                        if HasTokenSpace:\r
-                            EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s.%s is not found in the DEC file." % (TokenSpaceGuidCName, TokenCName))\r
-                        else:\r
-                            EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s is not found in the DEC file." % (TokenCName))\r
 \r
-                    for BuildData in PGen.BuildDatabase._CACHE_.values():\r
-                        if BuildData.Arch != Arch:\r
-                            continue\r
-                        if BuildData.MetaFile.Ext == '.dec':\r
-                            continue\r
-                        for key in BuildData.Pcds:\r
-                            PcdItem = BuildData.Pcds[key]\r
-                            if (TokenSpaceGuidCName, TokenCName) == (PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName):\r
-                                PcdItem.DefaultValue = NewValue\r
 \r
-                    if (TokenCName, TokenSpaceGuidCName) in PcdSet:\r
-                        PcdSet[(TokenCName, TokenSpaceGuidCName)] = NewValue\r
 \r
             SourcePcdDict = {'DynamicEx':[], 'PatchableInModule':[],'Dynamic':[],'FixedAtBuild':[]}\r
             BinaryPcdDict = {'DynamicEx':[], 'PatchableInModule':[]}\r
@@ -488,6 +409,7 @@ class WorkspaceAutoGen(AutoGen):
             BinaryPcdDict_Keys = BinaryPcdDict.keys()\r
 \r
             # generate the SourcePcdDict and BinaryPcdDict\r
+            PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\r
             for BuildData in PGen.BuildDatabase._CACHE_.values():\r
                 if BuildData.Arch != Arch:\r
                     continue\r
@@ -630,6 +552,8 @@ class WorkspaceAutoGen(AutoGen):
                 ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, Toolchain]\r
                 PkgSet.update(ModuleData.Packages)\r
             Pkgs = list(PkgSet) + list(PGen.PackageList)\r
+            DecPcds = {}\r
+            DecPcdsKey = set()\r
             for Pkg in Pkgs:\r
                 for Pcd in Pkg.Pcds:\r
                     DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd]\r
@@ -1446,15 +1370,25 @@ class PlatformAutoGen(AutoGen):
     def CollectPlatformDynamicPcds(self):\r
         # Override the platform Pcd's value by build option\r
         if GlobalData.BuildOptionPcd:\r
-            for key in self.Platform.Pcds:\r
-                PlatformPcd = self.Platform.Pcds[key]\r
-                for PcdItem in GlobalData.BuildOptionPcd:\r
-                    if (PlatformPcd.TokenSpaceGuidCName, PlatformPcd.TokenCName) == (PcdItem[0], PcdItem[1]):\r
-                        PlatformPcd.DefaultValue = PcdItem[2]\r
-                        if PlatformPcd.SkuInfoList:\r
-                            Sku = PlatformPcd.SkuInfoList[PlatformPcd.SkuInfoList.keys()[0]]\r
-                            Sku.DefaultValue = PcdItem[2]\r
-                        break\r
+            for PcdItem in GlobalData.BuildOptionPcd:\r
+                PlatformPcd = self.Platform.Pcds.get((PcdItem[1],PcdItem[0]))\r
+                if PlatformPcd:\r
+                    if PlatformPcd.DatumType in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64,'BOOLEAN']:\r
+                        for sku in PlatformPcd.SkuInfoList:\r
+                            PlatformPcd.SkuInfoList[sku].DefaultValue = PcdItem[2]\r
+                    else:\r
+                        PcdDefaultValue = StringToArray(PcdItem[2])\r
+                        for sku in PlatformPcd.SkuInfoList:\r
+                            skuinfo = PlatformPcd.SkuInfoList[sku]\r
+                            if skuinfo.VariableGuid:\r
+                                skuinfo.HiiDefaultValue = PcdDefaultValue\r
+                            else:\r
+                                skuinfo.DefaultValue = PcdDefaultValue\r
+                        PlatformPcd.DefaultValue = PcdDefaultValue\r
+                        if PlatformPcd.MaxDatumSize:\r
+                            PlatformPcd.MaxDatumSize = str(max([int(PlatformPcd.MaxDatumSize),len(PcdDefaultValue.split(","))]))\r
+                        else:\r
+                            PlatformPcd.MaxDatumSize = str(len(PcdDefaultValue.split(",")))\r
 \r
         for key in self.Platform.Pcds:\r
             for SinglePcd in GlobalData.MixedPcd:\r
index 486c537029571bd04c0d2cbac8e3633bcf65e44d..b8c48460ff6dc91868cf8d58748ec4fce1b6f085 100644 (file)
@@ -791,7 +791,7 @@ class ValueExpressionEx(ValueExpression):
                     raise BadExpression('Type %s PCD Value Size is Larger than 4 byte' % self.PcdType)\r
                 if self.PcdType == 'UINT64' and Size > 8:\r
                     raise BadExpression('Type %s PCD Value Size is Larger than 8 byte' % self.PcdType)\r
-            if self.PcdType in ['VOID*']:\r
+            else:\r
                 try:\r
                     TmpValue = long(PcdValue)\r
                     TmpList = []\r
index ef52154f47a197739cce467876506cf61904767d..b34cb4c3be6008dff3dc164e2e83154b23655e41 100644 (file)
@@ -2348,7 +2348,7 @@ def PackRegistryFormatGuid(Guid):
                 )\r
 \r
 def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Value):\r
-    if PcdDatumType == 'VOID*':\r
+    if PcdDatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64,'BOOLEAN']:\r
         if Value.startswith('L'):\r
             if not Value[1]:\r
                 EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')\r
index baee543698520702ab851d123d986cfcdca85063..b0b242be8d7104f745a0bdf4fdba5cdaf0d08ca3 100644 (file)
@@ -237,6 +237,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
         InfPcds = Inf.Pcds\r
         Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
         FdfPcdDict = GenFdsGlobalVariable.FdfParser.Profile.PcdDict\r
+        PlatformPcds = Platform.Pcds\r
 \r
         # Workaround here: both build and GenFds tool convert the workspace path to lower case\r
         # But INF file path in FDF and DSC file may have real case characters.\r
index 4a5d6f476abdd2bdc3cffaee86f4c790f812c603..dcba9f24cb6b7894f49e45128685f833a8fec401 100644 (file)
@@ -302,9 +302,7 @@ def main():
         if ArchList != None:\r
             GenFdsGlobalVariable.ArchList = ArchList\r
 \r
-        if Options.OptionPcd:\r
-            GlobalData.BuildOptionPcd = Options.OptionPcd\r
-            CheckBuildOptionPcd()\r
+        # Dsc Build Data will handle Pcd Settings from CommandLine.\r
 \r
         """Modify images from build output if the feature of loading driver at fixed address is on."""\r
         if GenFdsGlobalVariable.FixedLoadAddress:\r
index 84f7b6a23749743bbbb8ee2a0f856924f9b81e72..ad5b267fd158c38d5bf54ee1324a2221439be3f3 100644 (file)
@@ -162,7 +162,6 @@ class DscBuildData(PlatformBuildClassObject):
             self.OutputPath = os.path.dirname(self.DscFile)\r
         self.DefaultStores = None\r
         self.SkuIdMgr = SkuClass(self.SkuName, self.SkuIds)\r
-        arraystr = self.SkuIdMgr.DumpSkuIdArrary()\r
 \r
     ## XXX[key] = value\r
     def __setitem__(self, key, value):\r
@@ -451,7 +450,6 @@ class DscBuildData(PlatformBuildClassObject):
     ## Override SKUID_IDENTIFIER\r
     def _SetSkuName(self, Value):\r
         self._SkuName = Value\r
-        self._Pcds = None\r
 \r
     def _GetFdfFile(self):\r
         if self._FlashDefinition == None:\r
@@ -889,10 +887,164 @@ class DscBuildData(PlatformBuildClassObject):
                     skuobj.DefaultStoreDict['STANDARD'] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename])\r
         return Pcds\r
 \r
+    def RecoverCommandLinePcd(self):\r
+        pcdset = []\r
+        if GlobalData.BuildOptionPcd:\r
+            for pcd in GlobalData.BuildOptionPcd:\r
+                if pcd[2] == "":\r
+                    pcdset.append((pcd[0],pcd[1],pcd[3]))\r
+                else:\r
+                    pcdobj = self._Pcds.get((pcd[1],pcd[0]))\r
+                    if pcdobj:\r
+                        pcdset.append((pcd[0],pcd[1], pcdobj.DefaultValue))\r
+                    else:\r
+                        pcdset.append((pcd[0],pcd[1],pcd[3]))\r
+        GlobalData.BuildOptionPcd = pcdset\r
+    def GetFieldValueFromComm(self,ValueStr,TokenSpaceGuidCName, TokenCName, FieldName):\r
+        PredictedFieldType = "VOID*"\r
+        if ValueStr.startswith('L'):\r
+            if not ValueStr[1]:\r
+                EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')\r
+            ValueStr = ValueStr[0] + '"' + ValueStr[1:] + '"'\r
+            PredictedFieldType = "VOID*"\r
+        elif ValueStr.startswith('H') or ValueStr.startswith('{'):\r
+            EdkLogger.error("build", FORMAT_INVALID, 'Currently we do not support assign H"{...}" format for Pcd field.', ExtraData="%s.%s.%s from command line" % (TokenSpaceGuidCName, TokenCName, FieldName))\r
+            ValueStr = ValueStr[1:]\r
+            PredictedFieldType = "VOID*"\r
+        elif ValueStr.upper() in ['TRUE', '0X1', '0X01', '1', 'FALSE', '0X0', '0X00', '0']:\r
+            PredictedFieldType = "BOOLEAN"\r
+        elif ValueStr.isdigit() or ValueStr.upper().startswith('0X'):\r
+            PredictedFieldType = TAB_UINT16\r
+        else:\r
+            if not ValueStr[0]:\r
+                EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')\r
+            ValueStr = '"' + ValueStr + '"'\r
+            PredictedFieldType = "VOID*"\r
+        IsValid, Cause = CheckPcdDatum(PredictedFieldType, ValueStr)\r
+        if not IsValid:\r
+            EdkLogger.error("build", FORMAT_INVALID, Cause, ExtraData="%s.%s.%s from command line" % (TokenSpaceGuidCName, TokenCName, FieldName))\r
+        if PredictedFieldType == 'BOOLEAN':\r
+            ValueStr = ValueStr.upper()\r
+            if ValueStr == 'TRUE' or ValueStr == '1':\r
+                ValueStr = '1'\r
+            elif ValueStr == 'FALSE' or ValueStr == '0':\r
+                ValueStr = '0'\r
+        return  ValueStr\r
+    def __ParsePcdFromCommandLine(self):\r
+        if GlobalData.BuildOptionPcd:\r
+            for i, pcd in enumerate(GlobalData.BuildOptionPcd):\r
+                if type(pcd) is tuple:\r
+                    continue\r
+                (pcdname, pcdvalue) = pcd.split('=')\r
+                if not pcdvalue:\r
+                    EdkLogger.error('build', AUTOGEN_ERROR, "No Value specified for the PCD %s." % (pcdname))\r
+                if '.' in pcdname:\r
+                    (Name1, Name2) = pcdname.split('.',1)\r
+                    if "." in Name2:\r
+                        (Name3, FieldName) = Name2.split(".",1)\r
+                        if ((Name3,Name1)) in self.DecPcds:\r
+                            HasTokenSpace = True\r
+                            TokenCName = Name3\r
+                            TokenSpaceGuidCName = Name1\r
+                        else:\r
+                            FieldName = Name2\r
+                            TokenCName = Name1\r
+                            TokenSpaceGuidCName = ''\r
+                            HasTokenSpace = False\r
+                    else:\r
+                        if ((Name2,Name1)) in self.DecPcds:\r
+                            HasTokenSpace = True\r
+                            TokenCName = Name2\r
+                            TokenSpaceGuidCName = Name1\r
+                            FieldName =""\r
+                        else:\r
+                            FieldName = Name2\r
+                            TokenCName = Name1\r
+                            TokenSpaceGuidCName = ''\r
+                            HasTokenSpace = False\r
+                else:\r
+                    FieldName = ""\r
+                    TokenCName = pcdname\r
+                    TokenSpaceGuidCName = ''\r
+                    HasTokenSpace = False\r
+                TokenSpaceGuidCNameList = []\r
+                FoundFlag = False\r
+                PcdDatumType = ''\r
+                NewValue = ''\r
+                if not HasTokenSpace:\r
+                    for key in self.DecPcds:\r
+                        if TokenCName == key[0]:\r
+                            if TokenSpaceGuidCName:\r
+                                EdkLogger.error(\r
+                                                'build',\r
+                                                 AUTOGEN_ERROR,\r
+                                                "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (TokenCName, TokenSpaceGuidCName, key[1])\r
+                                                )\r
+                            else:\r
+                                TokenSpaceGuidCName = key[1]\r
+                                FoundFlag = True\r
+                else:\r
+                    if (TokenCName, TokenSpaceGuidCName) in self.DecPcds:\r
+                        FoundFlag = True\r
+                if FieldName:\r
+                    NewValue = self.GetFieldValueFromComm(pcdvalue, TokenSpaceGuidCName, TokenCName, FieldName)\r
+                    GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, FieldName,NewValue,("build command options",1))\r
+                else:\r
+                    for key in self.DecPcds:\r
+                        PcdItem = self.DecPcds[key]\r
+                        if HasTokenSpace:\r
+                            if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName):\r
+                                PcdDatumType = PcdItem.DatumType\r
+                                if pcdvalue.startswith('H'):\r
+                                    try:\r
+                                        pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True)\r
+                                    except BadExpression, Value:\r
+                                        if Value.result > 1:\r
+                                            EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %\r
+                                                            (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
+                                    pcdvalue = 'H' + pcdvalue\r
+                                NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
+                                FoundFlag = True\r
+                        else:\r
+                            if PcdItem.TokenCName == TokenCName:\r
+                                if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList:\r
+                                    if len (TokenSpaceGuidCNameList) < 1:\r
+                                        TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName)\r
+                                        PcdDatumType = PcdItem.DatumType\r
+                                        TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName\r
+                                        if pcdvalue.startswith('H'):\r
+                                            try:\r
+                                                pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True)\r
+                                            except BadExpression, Value:\r
+                                                EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
+                                                                (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
+                                            pcdvalue = 'H' + pcdvalue\r
+                                        NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
+                                        FoundFlag = True\r
+                                    else:\r
+                                        EdkLogger.error(\r
+                                                'build',\r
+                                                 AUTOGEN_ERROR,\r
+                                                "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (TokenCName, PcdItem.TokenSpaceGuidCName, TokenSpaceGuidCNameList[0])\r
+                                                )\r
+                    GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, FieldName,NewValue,("build command options",1))\r
+                if not FoundFlag:\r
+                    if HasTokenSpace:\r
+                        EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s.%s is not found in the DEC file." % (TokenSpaceGuidCName, TokenCName))\r
+                    else:\r
+                        EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s is not found in the DEC file." % (TokenCName))\r
+                for BuildData in self._Bdb._CACHE_.values():\r
+                    if BuildData.MetaFile.Ext == '.dec' or BuildData.MetaFile.Ext == '.dsc':\r
+                        continue\r
+                    for key in BuildData.Pcds:\r
+                        PcdItem = BuildData.Pcds[key]\r
+                        if (TokenSpaceGuidCName, TokenCName) == (PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName =="":\r
+                            PcdItem.DefaultValue = NewValue\r
     ## Retrieve all PCD settings in platform\r
     def _GetPcds(self):\r
         if self._Pcds == None:\r
             self._Pcds = sdict()\r
+            self.__ParsePcdFromCommandLine()\r
             self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))\r
             self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))\r
             self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))\r
@@ -907,6 +1059,8 @@ class DscBuildData(PlatformBuildClassObject):
             self._Pcds = self.UpdateStructuredPcds(MODEL_PCD_TYPE_LIST, self._Pcds)\r
             self._Pcds = self.CompleteHiiPcdsDefaultStores(self._Pcds)\r
             self._Pcds = self._FilterPcdBySkuUsage(self._Pcds)\r
+            self._Pcds = self.OverrideByFdfCommOverAll(self._Pcds)\r
+            self.RecoverCommandLinePcd()\r
         return self._Pcds\r
 \r
     def _dumpPcdInfo(self,Pcds):\r
@@ -971,7 +1125,55 @@ class DscBuildData(PlatformBuildClassObject):
             structure_pcd_data[(item[0],item[1])].append(item)\r
 \r
         return structure_pcd_data\r
+    def OverrideByFdfComm(self,StruPcds):\r
+        StructurePcdInCom = {(item[0],item[1],item[2] ):(item[3],item[4]) for item in GlobalData.BuildOptionPcd if len(item) == 5 and (item[1],item[0]) in StruPcds } if GlobalData.BuildOptionPcd else {}\r
+        GlobalPcds = set([(item[0],item[1]) for item in StructurePcdInCom.keys()])\r
+        for Pcd in StruPcds.values():\r
+            if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) not in GlobalPcds:\r
+                continue\r
+            FieldValues = {item[2]:StructurePcdInCom[item] for item in StructurePcdInCom if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) == (item[0],item[1]) and item[2]}\r
+            for sku in Pcd.SkuOverrideValues:\r
+                for defaultstore in Pcd.SkuOverrideValues[sku]:\r
+                    for field in FieldValues:\r
+                        if field not in Pcd.SkuOverrideValues[sku][defaultstore]:\r
+                            Pcd.SkuOverrideValues[sku][defaultstore][field] = ["","",""]\r
+                        Pcd.SkuOverrideValues[sku][defaultstore][field][0] = FieldValues[field][0]\r
+                        Pcd.SkuOverrideValues[sku][defaultstore][field][1] = FieldValues[field][1][0]\r
+                        Pcd.SkuOverrideValues[sku][defaultstore][field][2] = FieldValues[field][1][1]\r
+        return StruPcds\r
+    def OverrideByFdfCommOverAll(self,AllPcds):\r
+        def CheckStructureInComm(commpcds):\r
+            if not commpcds:\r
+                return False\r
+            if len(commpcds[0]) == 5:\r
+                return True\r
+            return False\r
 \r
+        if CheckStructureInComm(GlobalData.BuildOptionPcd):\r
+            StructurePcdInCom = {(item[0],item[1],item[2] ):(item[3],item[4]) for item in GlobalData.BuildOptionPcd } if GlobalData.BuildOptionPcd else {}\r
+            NoFiledValues = {(item[0],item[1]):StructurePcdInCom[item] for item in StructurePcdInCom if not item[2]}\r
+        else:\r
+            NoFiledValues = {(item[0],item[1]):[item[2]] for item in GlobalData.BuildOptionPcd}\r
+        for Guid,Name in NoFiledValues:\r
+            if (Name,Guid) in AllPcds:\r
+                Pcd = AllPcds.get((Name,Guid))\r
+                Pcd.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
+                for sku in Pcd.SkuInfoList:\r
+                    SkuInfo = Pcd.SkuInfoList[sku]\r
+                    if SkuInfo.DefaultValue:\r
+                        SkuInfo.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
+                    else:\r
+                        SkuInfo.HiiDefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
+                        for defaultstore in SkuInfo.DefaultStoreDict:\r
+                            SkuInfo.DefaultStoreDict[defaultstore] = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
+            else:\r
+                PcdInDec = self.DecPcds.get((Name,Guid))\r
+                if PcdInDec:\r
+                    if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],\r
+                                        self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:\r
+                        self.Pcds[Name, Guid] = copy.deepcopy(PcdInDec)\r
+                        self.Pcds[Name, Guid].DefaultValue = NoFiledValues[( Guid,Name)][0]\r
+        return AllPcds\r
     def UpdateStructuredPcds(self, TypeList, AllPcds):\r
 \r
         DynamicPcdType = [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_DEFAULT],\r
@@ -1002,7 +1204,7 @@ class DscBuildData(PlatformBuildClassObject):
                 continue\r
 \r
             if SkuName in SkuIds and "." in TokenSpaceGuid:\r
-                S_PcdSet.append(( TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpression(Setting)[0]))\r
+                S_PcdSet.append([ TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpression(Setting)[0]])\r
 \r
         # handle pcd value override\r
         StrPcdSet = self.GetStructurePcdInfo(S_PcdSet)\r
@@ -1072,7 +1274,7 @@ class DscBuildData(PlatformBuildClassObject):
                     for defaultstoreid in DefaultStores:\r
                         if defaultstoreid not in stru_pcd.SkuOverrideValues[skuid]:\r
                             stru_pcd.SkuOverrideValues[skuid][defaultstoreid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid][mindefaultstorename])\r
-\r
+        S_pcd_set = self.OverrideByFdfComm(S_pcd_set)\r
         Str_Pcd_Values = self.GenerateByteArrayValue(S_pcd_set)\r
         if Str_Pcd_Values:\r
             for (skuname,StoreName,PcdGuid,PcdName,PcdValue) in Str_Pcd_Values:\r
index e4adee2bebca101623369b7e4857a4c342ca6981..24f9962c9d94ed03a4b9aec7ea58ce22c8f1cc27 100644 (file)
@@ -772,7 +772,7 @@ class Build():
         self.AutoGenTime    = 0\r
         self.MakeTime       = 0\r
         self.GenFdsTime     = 0\r
-        GlobalData.BuildOptionPcd     = BuildOptions.OptionPcd\r
+        GlobalData.BuildOptionPcd     = BuildOptions.OptionPcd if BuildOptions.OptionPcd else {}\r
         #Set global flag for build mode\r
         GlobalData.gIgnoreSource = BuildOptions.IgnoreSources\r
         GlobalData.gUseHashCache = BuildOptions.UseHashCache\r