public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 1/2] BaseTools: Fixed Pcd value override issue.
@ 2018-03-02 10:11 BobCF
  2018-03-02 10:11 ` [Patch 2/2] BaseTools: Fixed build failed issue BobCF
  2018-03-02 13:35 ` [Patch 1/2] BaseTools: Fixed Pcd value override issue Gao, Liming
  0 siblings, 2 replies; 4+ messages in thread
From: BobCF @ 2018-03-02 10:11 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

1. Handle the Pcd maxsize issue for the case
that the length of Pcd value from CommandLine
bigger that its maxsize

2. The Pcd value override in commandline.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py         |  26 ---
 BaseTools/Source/Python/AutoGen/GenPcdDb.py        |  12 --
 .../Source/Python/Workspace/BuildClassObject.py    |   4 +
 BaseTools/Source/Python/Workspace/DscBuildData.py  | 175 ++++++++++++++++++---
 BaseTools/Source/Python/build/build.py             |   2 +-
 5 files changed, 157 insertions(+), 62 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index e2589cfbae..439e360955 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1366,31 +1366,10 @@ class PlatformAutoGen(AutoGen):
     #
     #  Gather dynamic PCDs list from each module and their settings from platform
     #  This interface should be invoked explicitly when platform action is created.
     #
     def CollectPlatformDynamicPcds(self):
-        # Override the platform Pcd's value by build option
-        if GlobalData.BuildOptionPcd:
-            for PcdItem in GlobalData.BuildOptionPcd:
-                PlatformPcd = self.Platform.Pcds.get((PcdItem[1],PcdItem[0]))
-                if PlatformPcd:
-                    if PlatformPcd.DatumType in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64,'BOOLEAN']:
-                        for sku in PlatformPcd.SkuInfoList:
-                            PlatformPcd.SkuInfoList[sku].DefaultValue = PcdItem[2]
-                    else:
-                        PcdDefaultValue = StringToArray(PcdItem[2])
-                        for sku in PlatformPcd.SkuInfoList:
-                            skuinfo = PlatformPcd.SkuInfoList[sku]
-                            if skuinfo.VariableGuid:
-                                skuinfo.HiiDefaultValue = PcdDefaultValue
-                            else:
-                                skuinfo.DefaultValue = PcdDefaultValue
-                        PlatformPcd.DefaultValue = PcdDefaultValue
-                        if PlatformPcd.MaxDatumSize:
-                            PlatformPcd.MaxDatumSize = str(max([int(PlatformPcd.MaxDatumSize),len(PcdDefaultValue.split(","))]))
-                        else:
-                            PlatformPcd.MaxDatumSize = str(len(PcdDefaultValue.split(",")))
 
         for key in self.Platform.Pcds:
             for SinglePcd in GlobalData.MixedPcd:
                 if (self.Platform.Pcds[key].TokenCName, self.Platform.Pcds[key].TokenSpaceGuidCName) == SinglePcd:
                     for item in GlobalData.MixedPcd[SinglePcd]:
@@ -2371,15 +2350,10 @@ class PlatformAutoGen(AutoGen):
         for PcdItem in GlobalData.MixedPcd:
             if (ToPcd.TokenCName, ToPcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
                 TokenCName = PcdItem[0]
                 break
         if FromPcd != None:
-            if GlobalData.BuildOptionPcd:
-                for pcd in GlobalData.BuildOptionPcd:
-                    if (FromPcd.TokenSpaceGuidCName, FromPcd.TokenCName) == (pcd[0], pcd[1]):
-                        FromPcd.DefaultValue = pcd[2]
-                        break
             if ToPcd.Pending and FromPcd.Type not in [None, '']:
                 ToPcd.Type = FromPcd.Type
             elif (ToPcd.Type not in [None, '']) and (FromPcd.Type not in [None, ''])\
                 and (ToPcd.Type != FromPcd.Type) and (ToPcd.Type in FromPcd.Type):
                 if ToPcd.Type.strip() == "DynamicEx":
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index 82360ae57d..e2848e7aaf 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -1182,16 +1182,10 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
 
         for PcdItem in GlobalData.MixedPcd:
             if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
                 CName = PcdItem[0]
 
-        if GlobalData.BuildOptionPcd:
-            for PcdItem in GlobalData.BuildOptionPcd:
-                if (Pcd.TokenSpaceGuidCName, CName) == (PcdItem[0], PcdItem[1]):
-                    Pcd.DefaultValue = PcdItem[2]
-                    break
-
         EdkLogger.debug(EdkLogger.DEBUG_3, "PCD: %s %s (%s : %s)" % (CName, TokenSpaceGuidCName, Pcd.Phase, Phase))
 
         if Pcd.Phase == 'PEI':
             NumberOfPeiLocalTokens += 1
         if Pcd.Phase == 'DXE':
@@ -1503,16 +1497,10 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
 
         for PcdItem in GlobalData.MixedPcd:
             if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
                 CName = PcdItem[0]
 
-        if GlobalData.BuildOptionPcd:
-            for PcdItem in GlobalData.BuildOptionPcd:
-                if (Pcd.TokenSpaceGuidCName, CName) == (PcdItem[0], PcdItem[1]):
-                    Pcd.DefaultValue = PcdItem[2]
-                    break
-
         EdkLogger.debug(EdkLogger.DEBUG_1, "PCD = %s.%s" % (CName, TokenSpaceGuidCName))
         EdkLogger.debug(EdkLogger.DEBUG_1, "phase = %s" % Phase)
         EdkLogger.debug(EdkLogger.DEBUG_1, "GeneratedTokenNumber = %s" % str(GeneratedTokenNumber))
         
         #
diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index edf2bdf4b9..711ba492ef 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -127,10 +127,12 @@ class StructurePcd(PcdClassObject):
         self.StructName = None
         self.PcdDefineLineNo = 0
         self.PkgPath = ""
         self.DefaultValueFromDec = ""
         self.ValueChain = dict()
+        self.PcdValueFromComm = ""
+        self.PcdFieldValueFromComm = collections.OrderedDict({})
     def __repr__(self):
         return self.TypeName
 
     def AddDefaultValue (self, FieldName, Value, FileName="", LineNo=0):
         if FieldName in self.DefaultValues:
@@ -186,10 +188,12 @@ class StructurePcd(PcdClassObject):
             self.FlexibleFieldName = PcdObject.FlexibleFieldName if PcdObject.FlexibleFieldName else self.FlexibleFieldName
             self.StructName = PcdObject.DatumType if PcdObject.DatumType else self.StructName
             self.PcdDefineLineNo = PcdObject.PcdDefineLineNo if PcdObject.PcdDefineLineNo else self.PcdDefineLineNo
             self.PkgPath = PcdObject.PkgPath if PcdObject.PkgPath else self.PkgPath
             self.ValueChain = PcdObject.ValueChain if PcdObject.ValueChain else self.ValueChain
+            self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm
+            self.PcdFieldValueFromComm = PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm
 
 ## LibraryClassObject
 #
 # This Class defines LibraryClassObject used in BuildDatabase
 #
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index a5089a900b..239531cd1c 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1131,14 +1131,15 @@ class DscBuildData(PlatformBuildClassObject):
             self._Pcds.update(self._GetDynamicPcd(MODEL_PCD_DYNAMIC_EX_DEFAULT))
             self._Pcds.update(self._GetDynamicHiiPcd(MODEL_PCD_DYNAMIC_EX_HII))
             self._Pcds.update(self._GetDynamicVpdPcd(MODEL_PCD_DYNAMIC_EX_VPD))
 
             self._Pcds = self.CompletePcdValues(self._Pcds)
+            self._Pcds = self.OverrideByFdfCommOverAll(self._Pcds)
             self._Pcds = self.UpdateStructuredPcds(MODEL_PCD_TYPE_LIST, self._Pcds)
             self._Pcds = self.CompleteHiiPcdsDefaultStores(self._Pcds)
             self._Pcds = self._FilterPcdBySkuUsage(self._Pcds)
-            self._Pcds = self.OverrideByFdfCommOverAll(self._Pcds)
+
             self.RecoverCommandLinePcd()
         return self._Pcds
 
     def _dumpPcdInfo(self,Pcds):
         for pcd in Pcds:
@@ -1201,24 +1202,28 @@ class DscBuildData(PlatformBuildClassObject):
                 structure_pcd_data[(item[0],item[1])] = []
             structure_pcd_data[(item[0],item[1])].append(item)
 
         return structure_pcd_data
     def OverrideByFdfComm(self,StruPcds):
-        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 {}
+        StructurePcdInCom = OrderedDict()
+        for item in GlobalData.BuildOptionPcd:
+            if len(item) == 5 and (item[1],item[0]) in StruPcds:
+                StructurePcdInCom[(item[0],item[1],item[2] )] = (item[3],item[4])
         GlobalPcds = set([(item[0],item[1]) for item in StructurePcdInCom.keys()])
         for Pcd in StruPcds.values():
             if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) not in GlobalPcds:
                 continue
-            FieldValues = {item[2]:StructurePcdInCom[item] for item in StructurePcdInCom if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) == (item[0],item[1]) and item[2]}
-            for sku in Pcd.SkuOverrideValues:
-                for defaultstore in Pcd.SkuOverrideValues[sku]:
-                    for field in FieldValues:
-                        if field not in Pcd.SkuOverrideValues[sku][defaultstore]:
-                            Pcd.SkuOverrideValues[sku][defaultstore][field] = ["","",""]
-                        Pcd.SkuOverrideValues[sku][defaultstore][field][0] = FieldValues[field][0]
-                        Pcd.SkuOverrideValues[sku][defaultstore][field][1] = FieldValues[field][1][0]
-                        Pcd.SkuOverrideValues[sku][defaultstore][field][2] = FieldValues[field][1][1]
+            FieldValues = OrderedDict()
+            for item in StructurePcdInCom:
+                if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) == (item[0],item[1]) and item[2]:
+                    FieldValues[item[2]] = StructurePcdInCom[item]
+            for field in FieldValues:
+                if field not in Pcd.PcdFieldValueFromComm:
+                    Pcd.PcdFieldValueFromComm[field] = ["","",""]
+                Pcd.PcdFieldValueFromComm[field][0] = FieldValues[field][0]
+                Pcd.PcdFieldValueFromComm[field][1] = FieldValues[field][1][0]
+                Pcd.PcdFieldValueFromComm[field][2] = FieldValues[field][1][1]
         return StruPcds
     def OverrideByFdfCommOverAll(self,AllPcds):
         def CheckStructureInComm(commpcds):
             if not commpcds:
                 return False
@@ -1232,19 +1237,35 @@ class DscBuildData(PlatformBuildClassObject):
         else:
             NoFiledValues = {(item[0],item[1]):[item[2]] for item in GlobalData.BuildOptionPcd}
         for Guid,Name in NoFiledValues:
             if (Name,Guid) in AllPcds:
                 Pcd = AllPcds.get((Name,Guid))
-                Pcd.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
-                for sku in Pcd.SkuInfoList:
-                    SkuInfo = Pcd.SkuInfoList[sku]
-                    if SkuInfo.DefaultValue:
-                        SkuInfo.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
-                    else:
-                        SkuInfo.HiiDefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
-                        for defaultstore in SkuInfo.DefaultStoreDict:
-                            SkuInfo.DefaultStoreDict[defaultstore] = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
+                if isinstance(self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName), None),StructurePcd):
+                    self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName)).PcdValueFromComm = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
+                else:
+                    Pcd.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
+                    for sku in Pcd.SkuInfoList:
+                        SkuInfo = Pcd.SkuInfoList[sku]
+                        if SkuInfo.DefaultValue:
+                            SkuInfo.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
+                        else:
+                            SkuInfo.HiiDefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
+                            for defaultstore in SkuInfo.DefaultStoreDict:
+                                SkuInfo.DefaultStoreDict[defaultstore] = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
+                    if Pcd.DatumType == "VOID*":
+                        if Pcd.MaxDatumSize is None:
+                            Pcd.MaxDatumSize = '0'
+                        MaxSize = int(Pcd.MaxDatumSize,10)
+                        if Pcd.DefaultValue.startswith("{") and Pcd.DefaultValue.endswith("}"):
+                            MaxSize = max([len(Pcd.DefaultValue.split(",")),MaxSize])
+                        elif Pcd.DefaultValue.startswith("\"") or Pcd.DefaultValue.startswith("\'"):
+                            MaxSize = max([len(Pcd.DefaultValue)-2+1,MaxSize])
+                        elif Pcd.DefaultValue.startswith("L\""):
+                            MaxSize = max([2*(len(Pcd.DefaultValue)-3+1),MaxSize])
+                        else:
+                            MaxSize = max([len(Pcd.DefaultValue),MaxSize])
+                        Pcd.MaxDatumSize = str(MaxSize)
             else:
                 PcdInDec = self.DecPcds.get((Name,Guid))
                 if PcdInDec:
                     if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
                                         self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
@@ -1541,14 +1562,12 @@ class DscBuildData(PlatformBuildClassObject):
         if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1:
             return True
         if Value[0] == '{' and Value[-1] == '}':
             return True
         if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:
-            print 'foo = ', list(Value[2:-1])
             return True
         if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:
-            print 'bar = ', list(Value[1:-1])
             return True
         return False
 
     def ExecuteCommand (self, Command):
         try:
@@ -1565,10 +1584,31 @@ class DscBuildData(PlatformBuildClassObject):
                 Result = Result + '\\x%02x' % (Value & 0xff)
                 Value = Value >> 8
         Result = Result + '"'
         return Result
 
+    def GetPcdMaxSize(self,Pcd):
+        MaxSize = int(Pcd.MaxDatumSize,10) if Pcd.MaxDatumSize else 0
+        if Pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT64']:
+            if Pcd.PcdValueFromComm:
+                if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"):
+                    MaxSize = max([len(Pcd.PcdValueFromComm.split(",")),MaxSize])
+                elif Pcd.PcdValueFromComm.startswith("\"") or Pcd.PcdValueFromComm.startswith("\'"):
+                    MaxSize = max([len(Pcd.PcdValueFromComm)-2+1,MaxSize])
+                elif Pcd.PcdValueFromComm.startswith("L\""):
+                    MaxSize = max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize])
+                else:
+                    MaxSize = max([len(Pcd.PcdValueFromComm),MaxSize])
+        elif Pcd.DatumType not in ['BOOLEAN','UINT8']:
+            MaxSize = 1
+        elif Pcd.DatumType  == 'UINT16':
+            MaxSize = 2
+        elif Pcd.DatumType  == 'UINT32':
+            MaxSize = 4
+        elif Pcd.DatumType  == 'UINT64':
+            MaxSize = 8
+        return MaxSize
     def GenerateSizeFunction(self,Pcd):
         CApp = "// Default Value in Dec \n"
         CApp = CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
         for FieldList in [Pcd.DefaultValues]:
             if not FieldList:
@@ -1623,10 +1663,35 @@ class DscBuildData(PlatformBuildClassObject):
                                 FieldName = FieldName.split(']', 1)[1]
                             FieldName = NewFieldName + FieldName
                             while '[' in FieldName:
                                 FieldName = FieldName.rsplit('[', 1)[0]
                                 CApp = CApp + '  __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])
+        if Pcd.PcdFieldValueFromComm:
+            CApp = CApp + "// From Command Line \n"
+        for FieldName in Pcd.PcdFieldValueFromComm:
+            FieldName = "." + FieldName
+            IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
+            if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')):
+                try:
+                    Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True)
+                except BadExpression:
+                    EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
+                                    (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))
+                Value, ValueSize = ParseFieldValue(Value)
+                CApp = CApp + '  __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
+            else:
+                NewFieldName = ''
+                FieldName_ori = FieldName.strip('.')
+                while '[' in  FieldName:
+                    NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]'
+                    ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])
+                    FieldName = FieldName.split(']', 1)[1]
+                FieldName = NewFieldName + FieldName
+                while '[' in FieldName:
+                    FieldName = FieldName.rsplit('[', 1)[0]
+                    CApp = CApp + '  __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])
+        CApp = CApp + "  *Size = (%d > *Size ? %d : *Size); // The Pcd maxsize is %d \n" % (self.GetPcdMaxSize(Pcd),self.GetPcdMaxSize(Pcd),self.GetPcdMaxSize(Pcd))
         CApp = CApp + "}\n"
         return CApp
     def GenerateSizeStatments(self,Pcd):
         CApp = '  Size = sizeof(%s);\n' % (Pcd.DatumType)
         CApp = CApp + '  Cal_%s_%s_Size(&Size);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
@@ -1762,10 +1827,72 @@ class DscBuildData(PlatformBuildClassObject):
         CApp = CApp + "}\n"
         return CApp
     def GenerateInitValueStatement(self,Pcd,SkuName,DefaultStoreName):
         CApp = '  Assign_%s_%s_%s_%s_Value(Pcd);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,SkuName,DefaultStoreName)
         return CApp
+    def GenerateCommandLineValue(self,Pcd):
+        CApp = "// Value in CommandLine\n"
+        CApp = CApp + "void Assign_%s_%s_CommandLine_Value(%s *Pcd){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,Pcd.DatumType)
+        CApp = CApp + '  UINT32  FieldSize;\n'
+        CApp = CApp + '  CHAR8   *Value;\n'
+
+        pcddefaultvalue = Pcd.PcdValueFromComm
+        for FieldList in [pcddefaultvalue,Pcd.PcdFieldValueFromComm]:
+            if not FieldList:
+                continue
+            if pcddefaultvalue and FieldList == pcddefaultvalue:
+                IsArray = self.IsFieldValueAnArray(FieldList)
+                if IsArray:
+                    try:
+                        FieldList = ValueExpressionEx(FieldList, "VOID*")(True)
+                    except BadExpression:
+                        EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DSC: %s" %
+                                        (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList))
+                Value, ValueSize = ParseFieldValue (FieldList)
+
+                if isinstance(Value, str):
+                    CApp = CApp + '  Pcd = %s; // From Command Line \n' % (Value)
+                elif IsArray:
+                #
+                # Use memcpy() to copy value into field
+                #
+                    CApp = CApp + '  Value     = %s; // From Command Line.\n' % (self.IntToCString(Value, ValueSize))
+                    CApp = CApp + '  memcpy (Pcd, Value, %d);\n' % (ValueSize)
+                continue
+            for FieldName in FieldList:
+                IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])
+                if IsArray:
+                    try:
+                        FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True)
+                    except BadExpression:
+                        EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
+                                        (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2]))
+                    except:
+                        print "error"
+                try:
+                    Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])
+                except Exception:
+                    EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2]))
+                if isinstance(Value, str):
+                    CApp = CApp + '  Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
+                elif IsArray:
+                #
+                # Use memcpy() to copy value into field
+                #
+                    CApp = CApp + '  FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName)
+                    CApp = CApp + '  Value     = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
+                    CApp = CApp + '  memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)
+                else:
+                    if ValueSize > 4:
+                        CApp = CApp + '  Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
+                    else:
+                        CApp = CApp + '  Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
+        CApp = CApp + "}\n"
+        return CApp
+    def GenerateCommandLineValueStatement(self,Pcd):
+        CApp = '  Assign_%s_%s_CommandLine_Value(Pcd);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
+        return CApp
     def GenerateInitializeFunc(self, SkuName, DefaultStore, Pcd, InitByteValue, CApp):
         OverrideValues = {DefaultStore:""}
         if Pcd.SkuOverrideValues:
             OverrideValues = Pcd.SkuOverrideValues[SkuName]
         for DefaultStoreName in OverrideValues.keys():
@@ -1833,10 +1960,11 @@ class DscBuildData(PlatformBuildClassObject):
                     if skuname == SkuName:
                         break
             else:
                 CApp = CApp + "// SkuName: DEFAULT,  DefaultStoreName: STANDARD \n"
                 CApp = CApp + self.GenerateInitValueStatement(Pcd,"DEFAULT","STANDARD")
+            CApp = CApp + self.GenerateCommandLineValueStatement(Pcd)
             #
             # Set new PCD value and size
             #
             CApp = CApp + '  PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *)Pcd);\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
 
@@ -1868,10 +1996,11 @@ class DscBuildData(PlatformBuildClassObject):
         CApp = CApp + '\n'
         for PcdName in StructuredPcds:
             Pcd = StructuredPcds[PcdName]
             CApp = CApp + self.GenerateSizeFunction(Pcd)
             CApp = CApp + self.GenerateDefaultValueAssignFunction(Pcd)
+            CApp = CApp + self.GenerateCommandLineValue(Pcd)
             if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
                         self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
                 CApp = CApp + self.GenerateInitValueFunction(Pcd,self.SkuIdMgr.SystemSkuId, 'STANDARD')
             else:
                 for SkuName in self.SkuIdMgr.SkuOverrideOrder():
@@ -2372,11 +2501,11 @@ class DscBuildData(PlatformBuildClassObject):
 
             if pcd.MaxDatumSize.strip():
                 MaxSize = int(pcd.MaxDatumSize, 0)
             else:
                 MaxSize = 0
-            if pcdDecObject.DatumType == 'VOID*':
+            if pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT64']:
                 for (_, skuobj) in pcd.SkuInfoList.items():
                     datalen = 0
                     skuobj.HiiDefaultValue = StringToArray(skuobj.HiiDefaultValue)
                     datalen = len(skuobj.HiiDefaultValue.split(","))
                     if datalen > MaxSize:
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index bb130a02cc..85612d90ce 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -770,11 +770,11 @@ class Build():
         self.TargetTxt      = TargetTxtClassObject()
         self.ToolDef        = ToolDefClassObject()
         self.AutoGenTime    = 0
         self.MakeTime       = 0
         self.GenFdsTime     = 0
-        GlobalData.BuildOptionPcd     = BuildOptions.OptionPcd if BuildOptions.OptionPcd else {}
+        GlobalData.BuildOptionPcd     = BuildOptions.OptionPcd if BuildOptions.OptionPcd else []
         #Set global flag for build mode
         GlobalData.gIgnoreSource = BuildOptions.IgnoreSources
         GlobalData.gUseHashCache = BuildOptions.UseHashCache
         GlobalData.gBinCacheDest   = BuildOptions.BinCacheDest
         GlobalData.gBinCacheSource = BuildOptions.BinCacheSource
-- 
2.14.3.windows.1



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

* [Patch 2/2] BaseTools: Fixed build failed issue.
  2018-03-02 10:11 [Patch 1/2] BaseTools: Fixed Pcd value override issue BobCF
@ 2018-03-02 10:11 ` BobCF
  2018-03-02 13:35   ` Gao, Liming
  2018-03-02 13:35 ` [Patch 1/2] BaseTools: Fixed Pcd value override issue Gao, Liming
  1 sibling, 1 reply; 4+ messages in thread
From: BobCF @ 2018-03-02 10:11 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

Case 1. A Pcd has no default sku setting in DSC.
Case 2. Build as Single SKU.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 239531cd1c..cd633e964d 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1317,14 +1317,14 @@ class DscBuildData(PlatformBuildClassObject):
             if str_pcd_dec:
                 str_pcd_obj_str = StructurePcd()
                 str_pcd_obj_str.copy(str_pcd_dec)
                 if str_pcd_obj:
                     str_pcd_obj_str.copy(str_pcd_obj)
-                if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
-                    str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
-                else:
-                    str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
+                    if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
+                        str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
+                    else:
+                        str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
                 for str_pcd_data in StrPcdSet[str_pcd]:
                     if str_pcd_data[3] in SkuIds:
                         str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5])
                 S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str
             else:
@@ -1762,10 +1762,13 @@ class DscBuildData(PlatformBuildClassObject):
         CApp = CApp + "// SkuName: %s,  DefaultStoreName: %s \n" % ('DEFAULT', 'STANDARD')
         inherit_OverrideValues = Pcd.SkuOverrideValues[SkuName]
         if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD'):
             pcddefaultvalue = Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue
         else:
+            if not Pcd.DscRawValue:
+                # handle the case that structure pcd is not appear in DSC
+                self.CopyDscRawValue(Pcd)
             pcddefaultvalue = Pcd.DscRawValue.get(SkuName,{}).get(DefaultStoreName)
         for FieldList in [pcddefaultvalue,inherit_OverrideValues.get(DefaultStoreName)]:
             if not FieldList:
                 continue
             if pcddefaultvalue and FieldList == pcddefaultvalue:
@@ -1958,12 +1961,12 @@ class DscBuildData(PlatformBuildClassObject):
                         CApp = CApp + "// SkuName: %s,  DefaultStoreName: %s \n" % (skuname, defaultstorenameitem)
                         CApp = CApp + self.GenerateInitValueStatement(Pcd,skuname,defaultstorenameitem)
                     if skuname == SkuName:
                         break
             else:
-                CApp = CApp + "// SkuName: DEFAULT,  DefaultStoreName: STANDARD \n"
-                CApp = CApp + self.GenerateInitValueStatement(Pcd,"DEFAULT","STANDARD")
+                CApp = CApp + "// SkuName: %s,  DefaultStoreName: STANDARD \n" % self.SkuIdMgr.SystemSkuId
+                CApp = CApp + self.GenerateInitValueStatement(Pcd,self.SkuIdMgr.SystemSkuId,"STANDARD")
             CApp = CApp + self.GenerateCommandLineValueStatement(Pcd)
             #
             # Set new PCD value and size
             #
             CApp = CApp + '  PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *)Pcd);\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
@@ -2325,10 +2328,14 @@ class DscBuildData(PlatformBuildClassObject):
         else:
             return False
     def CopyDscRawValue(self,Pcd):
         if Pcd.DscRawValue is None:
             Pcd.DscRawValue = dict()
+        if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
+            if self.SkuIdMgr.SystemSkuId not in Pcd.DscRawValue:
+                Pcd.DscRawValue[self.SkuIdMgr.SystemSkuId] = {}
+            Pcd.DscRawValue[self.SkuIdMgr.SystemSkuId]['STANDARD'] = Pcd.DefaultValue
         for skuname in Pcd.SkuInfoList:
             Pcd.DscRawValue[skuname] = {}
             if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
                 for defaultstore in Pcd.SkuInfoList[skuname].DefaultStoreDict:
                     Pcd.DscRawValue[skuname][defaultstore] = Pcd.SkuInfoList[skuname].DefaultStoreDict[defaultstore]
@@ -2339,19 +2346,19 @@ class DscBuildData(PlatformBuildClassObject):
         DefaultStoreObj = DefaultStore(self._GetDefaultStores())
         SkuIds = {skuname:skuid for skuname,skuid in self.SkuIdMgr.AvailableSkuIdSet.items() if skuname !='COMMON'}
         DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])
         for PcdCName, TokenSpaceGuid in PcdSet:
             PcdObj = PcdSet[(PcdCName, TokenSpaceGuid)]
+            self.CopyDscRawValue(PcdObj)
             if PcdObj.Type not in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_DEFAULT],
                         self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],
                         self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_VPD],
                         self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_DEFAULT],
                         self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII],
                         self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_VPD]]:
                 Pcds[PcdCName, TokenSpaceGuid]= PcdObj
                 continue
-            self.CopyDscRawValue(PcdObj)
             PcdType = PcdObj.Type
             if PcdType in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
                 for skuid in PcdObj.SkuInfoList:
                     skuobj = PcdObj.SkuInfoList[skuid]
                     mindefaultstorename = DefaultStoreObj.GetMin(set([defaultstorename  for defaultstorename in skuobj.DefaultStoreDict]))
-- 
2.14.3.windows.1



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

* Re: [Patch 1/2] BaseTools: Fixed Pcd value override issue.
  2018-03-02 10:11 [Patch 1/2] BaseTools: Fixed Pcd value override issue BobCF
  2018-03-02 10:11 ` [Patch 2/2] BaseTools: Fixed build failed issue BobCF
@ 2018-03-02 13:35 ` Gao, Liming
  1 sibling, 0 replies; 4+ messages in thread
From: Gao, Liming @ 2018-03-02 13:35 UTC (permalink / raw)
  To: Feng, Bob C, edk2-devel@lists.01.org

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of BobCF
> Sent: Friday, March 2, 2018 6:11 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [Patch 1/2] BaseTools: Fixed Pcd value override issue.
> 
> 1. Handle the Pcd maxsize issue for the case
> that the length of Pcd value from CommandLine
> bigger that its maxsize
> 
> 2. The Pcd value override in commandline.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bob Feng <bob.c.feng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> ---
>  BaseTools/Source/Python/AutoGen/AutoGen.py         |  26 ---
>  BaseTools/Source/Python/AutoGen/GenPcdDb.py        |  12 --
>  .../Source/Python/Workspace/BuildClassObject.py    |   4 +
>  BaseTools/Source/Python/Workspace/DscBuildData.py  | 175 ++++++++++++++++++---
>  BaseTools/Source/Python/build/build.py             |   2 +-
>  5 files changed, 157 insertions(+), 62 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
> index e2589cfbae..439e360955 100644
> --- a/BaseTools/Source/Python/AutoGen/AutoGen.py
> +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
> @@ -1366,31 +1366,10 @@ class PlatformAutoGen(AutoGen):
>      #
>      #  Gather dynamic PCDs list from each module and their settings from platform
>      #  This interface should be invoked explicitly when platform action is created.
>      #
>      def CollectPlatformDynamicPcds(self):
> -        # Override the platform Pcd's value by build option
> -        if GlobalData.BuildOptionPcd:
> -            for PcdItem in GlobalData.BuildOptionPcd:
> -                PlatformPcd = self.Platform.Pcds.get((PcdItem[1],PcdItem[0]))
> -                if PlatformPcd:
> -                    if PlatformPcd.DatumType in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64,'BOOLEAN']:
> -                        for sku in PlatformPcd.SkuInfoList:
> -                            PlatformPcd.SkuInfoList[sku].DefaultValue = PcdItem[2]
> -                    else:
> -                        PcdDefaultValue = StringToArray(PcdItem[2])
> -                        for sku in PlatformPcd.SkuInfoList:
> -                            skuinfo = PlatformPcd.SkuInfoList[sku]
> -                            if skuinfo.VariableGuid:
> -                                skuinfo.HiiDefaultValue = PcdDefaultValue
> -                            else:
> -                                skuinfo.DefaultValue = PcdDefaultValue
> -                        PlatformPcd.DefaultValue = PcdDefaultValue
> -                        if PlatformPcd.MaxDatumSize:
> -                            PlatformPcd.MaxDatumSize =
> str(max([int(PlatformPcd.MaxDatumSize),len(PcdDefaultValue.split(","))]))
> -                        else:
> -                            PlatformPcd.MaxDatumSize = str(len(PcdDefaultValue.split(",")))
> 
>          for key in self.Platform.Pcds:
>              for SinglePcd in GlobalData.MixedPcd:
>                  if (self.Platform.Pcds[key].TokenCName, self.Platform.Pcds[key].TokenSpaceGuidCName) == SinglePcd:
>                      for item in GlobalData.MixedPcd[SinglePcd]:
> @@ -2371,15 +2350,10 @@ class PlatformAutoGen(AutoGen):
>          for PcdItem in GlobalData.MixedPcd:
>              if (ToPcd.TokenCName, ToPcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
>                  TokenCName = PcdItem[0]
>                  break
>          if FromPcd != None:
> -            if GlobalData.BuildOptionPcd:
> -                for pcd in GlobalData.BuildOptionPcd:
> -                    if (FromPcd.TokenSpaceGuidCName, FromPcd.TokenCName) == (pcd[0], pcd[1]):
> -                        FromPcd.DefaultValue = pcd[2]
> -                        break
>              if ToPcd.Pending and FromPcd.Type not in [None, '']:
>                  ToPcd.Type = FromPcd.Type
>              elif (ToPcd.Type not in [None, '']) and (FromPcd.Type not in [None, ''])\
>                  and (ToPcd.Type != FromPcd.Type) and (ToPcd.Type in FromPcd.Type):
>                  if ToPcd.Type.strip() == "DynamicEx":
> diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
> index 82360ae57d..e2848e7aaf 100644
> --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
> +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
> @@ -1182,16 +1182,10 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
> 
>          for PcdItem in GlobalData.MixedPcd:
>              if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
>                  CName = PcdItem[0]
> 
> -        if GlobalData.BuildOptionPcd:
> -            for PcdItem in GlobalData.BuildOptionPcd:
> -                if (Pcd.TokenSpaceGuidCName, CName) == (PcdItem[0], PcdItem[1]):
> -                    Pcd.DefaultValue = PcdItem[2]
> -                    break
> -
>          EdkLogger.debug(EdkLogger.DEBUG_3, "PCD: %s %s (%s : %s)" % (CName, TokenSpaceGuidCName, Pcd.Phase, Phase))
> 
>          if Pcd.Phase == 'PEI':
>              NumberOfPeiLocalTokens += 1
>          if Pcd.Phase == 'DXE':
> @@ -1503,16 +1497,10 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
> 
>          for PcdItem in GlobalData.MixedPcd:
>              if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
>                  CName = PcdItem[0]
> 
> -        if GlobalData.BuildOptionPcd:
> -            for PcdItem in GlobalData.BuildOptionPcd:
> -                if (Pcd.TokenSpaceGuidCName, CName) == (PcdItem[0], PcdItem[1]):
> -                    Pcd.DefaultValue = PcdItem[2]
> -                    break
> -
>          EdkLogger.debug(EdkLogger.DEBUG_1, "PCD = %s.%s" % (CName, TokenSpaceGuidCName))
>          EdkLogger.debug(EdkLogger.DEBUG_1, "phase = %s" % Phase)
>          EdkLogger.debug(EdkLogger.DEBUG_1, "GeneratedTokenNumber = %s" % str(GeneratedTokenNumber))
> 
>          #
> diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
> index edf2bdf4b9..711ba492ef 100644
> --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
> +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
> @@ -127,10 +127,12 @@ class StructurePcd(PcdClassObject):
>          self.StructName = None
>          self.PcdDefineLineNo = 0
>          self.PkgPath = ""
>          self.DefaultValueFromDec = ""
>          self.ValueChain = dict()
> +        self.PcdValueFromComm = ""
> +        self.PcdFieldValueFromComm = collections.OrderedDict({})
>      def __repr__(self):
>          return self.TypeName
> 
>      def AddDefaultValue (self, FieldName, Value, FileName="", LineNo=0):
>          if FieldName in self.DefaultValues:
> @@ -186,10 +188,12 @@ class StructurePcd(PcdClassObject):
>              self.FlexibleFieldName = PcdObject.FlexibleFieldName if PcdObject.FlexibleFieldName else self.FlexibleFieldName
>              self.StructName = PcdObject.DatumType if PcdObject.DatumType else self.StructName
>              self.PcdDefineLineNo = PcdObject.PcdDefineLineNo if PcdObject.PcdDefineLineNo else self.PcdDefineLineNo
>              self.PkgPath = PcdObject.PkgPath if PcdObject.PkgPath else self.PkgPath
>              self.ValueChain = PcdObject.ValueChain if PcdObject.ValueChain else self.ValueChain
> +            self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else
> self.PcdValueFromComm
> +            self.PcdFieldValueFromComm = PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm else
> self.PcdFieldValueFromComm
> 
>  ## LibraryClassObject
>  #
>  # This Class defines LibraryClassObject used in BuildDatabase
>  #
> diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
> index a5089a900b..239531cd1c 100644
> --- a/BaseTools/Source/Python/Workspace/DscBuildData.py
> +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
> @@ -1131,14 +1131,15 @@ class DscBuildData(PlatformBuildClassObject):
>              self._Pcds.update(self._GetDynamicPcd(MODEL_PCD_DYNAMIC_EX_DEFAULT))
>              self._Pcds.update(self._GetDynamicHiiPcd(MODEL_PCD_DYNAMIC_EX_HII))
>              self._Pcds.update(self._GetDynamicVpdPcd(MODEL_PCD_DYNAMIC_EX_VPD))
> 
>              self._Pcds = self.CompletePcdValues(self._Pcds)
> +            self._Pcds = self.OverrideByFdfCommOverAll(self._Pcds)
>              self._Pcds = self.UpdateStructuredPcds(MODEL_PCD_TYPE_LIST, self._Pcds)
>              self._Pcds = self.CompleteHiiPcdsDefaultStores(self._Pcds)
>              self._Pcds = self._FilterPcdBySkuUsage(self._Pcds)
> -            self._Pcds = self.OverrideByFdfCommOverAll(self._Pcds)
> +
>              self.RecoverCommandLinePcd()
>          return self._Pcds
> 
>      def _dumpPcdInfo(self,Pcds):
>          for pcd in Pcds:
> @@ -1201,24 +1202,28 @@ class DscBuildData(PlatformBuildClassObject):
>                  structure_pcd_data[(item[0],item[1])] = []
>              structure_pcd_data[(item[0],item[1])].append(item)
> 
>          return structure_pcd_data
>      def OverrideByFdfComm(self,StruPcds):
> -        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 {}
> +        StructurePcdInCom = OrderedDict()
> +        for item in GlobalData.BuildOptionPcd:
> +            if len(item) == 5 and (item[1],item[0]) in StruPcds:
> +                StructurePcdInCom[(item[0],item[1],item[2] )] = (item[3],item[4])
>          GlobalPcds = set([(item[0],item[1]) for item in StructurePcdInCom.keys()])
>          for Pcd in StruPcds.values():
>              if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) not in GlobalPcds:
>                  continue
> -            FieldValues = {item[2]:StructurePcdInCom[item] for item in StructurePcdInCom if
> (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) == (item[0],item[1]) and item[2]}
> -            for sku in Pcd.SkuOverrideValues:
> -                for defaultstore in Pcd.SkuOverrideValues[sku]:
> -                    for field in FieldValues:
> -                        if field not in Pcd.SkuOverrideValues[sku][defaultstore]:
> -                            Pcd.SkuOverrideValues[sku][defaultstore][field] = ["","",""]
> -                        Pcd.SkuOverrideValues[sku][defaultstore][field][0] = FieldValues[field][0]
> -                        Pcd.SkuOverrideValues[sku][defaultstore][field][1] = FieldValues[field][1][0]
> -                        Pcd.SkuOverrideValues[sku][defaultstore][field][2] = FieldValues[field][1][1]
> +            FieldValues = OrderedDict()
> +            for item in StructurePcdInCom:
> +                if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) == (item[0],item[1]) and item[2]:
> +                    FieldValues[item[2]] = StructurePcdInCom[item]
> +            for field in FieldValues:
> +                if field not in Pcd.PcdFieldValueFromComm:
> +                    Pcd.PcdFieldValueFromComm[field] = ["","",""]
> +                Pcd.PcdFieldValueFromComm[field][0] = FieldValues[field][0]
> +                Pcd.PcdFieldValueFromComm[field][1] = FieldValues[field][1][0]
> +                Pcd.PcdFieldValueFromComm[field][2] = FieldValues[field][1][1]
>          return StruPcds
>      def OverrideByFdfCommOverAll(self,AllPcds):
>          def CheckStructureInComm(commpcds):
>              if not commpcds:
>                  return False
> @@ -1232,19 +1237,35 @@ class DscBuildData(PlatformBuildClassObject):
>          else:
>              NoFiledValues = {(item[0],item[1]):[item[2]] for item in GlobalData.BuildOptionPcd}
>          for Guid,Name in NoFiledValues:
>              if (Name,Guid) in AllPcds:
>                  Pcd = AllPcds.get((Name,Guid))
> -                Pcd.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
> -                for sku in Pcd.SkuInfoList:
> -                    SkuInfo = Pcd.SkuInfoList[sku]
> -                    if SkuInfo.DefaultValue:
> -                        SkuInfo.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
> -                    else:
> -                        SkuInfo.HiiDefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
> -                        for defaultstore in SkuInfo.DefaultStoreDict:
> -                            SkuInfo.DefaultStoreDict[defaultstore] =
> NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
> +                if isinstance(self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName), None),StructurePcd):
> +                    self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName)).PcdValueFromComm =
> NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
> +                else:
> +                    Pcd.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
> +                    for sku in Pcd.SkuInfoList:
> +                        SkuInfo = Pcd.SkuInfoList[sku]
> +                        if SkuInfo.DefaultValue:
> +                            SkuInfo.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
> +                        else:
> +                            SkuInfo.HiiDefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
> +                            for defaultstore in SkuInfo.DefaultStoreDict:
> +                                SkuInfo.DefaultStoreDict[defaultstore] =
> NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
> +                    if Pcd.DatumType == "VOID*":
> +                        if Pcd.MaxDatumSize is None:
> +                            Pcd.MaxDatumSize = '0'
> +                        MaxSize = int(Pcd.MaxDatumSize,10)
> +                        if Pcd.DefaultValue.startswith("{") and Pcd.DefaultValue.endswith("}"):
> +                            MaxSize = max([len(Pcd.DefaultValue.split(",")),MaxSize])
> +                        elif Pcd.DefaultValue.startswith("\"") or Pcd.DefaultValue.startswith("\'"):
> +                            MaxSize = max([len(Pcd.DefaultValue)-2+1,MaxSize])
> +                        elif Pcd.DefaultValue.startswith("L\""):
> +                            MaxSize = max([2*(len(Pcd.DefaultValue)-3+1),MaxSize])
> +                        else:
> +                            MaxSize = max([len(Pcd.DefaultValue),MaxSize])
> +                        Pcd.MaxDatumSize = str(MaxSize)
>              else:
>                  PcdInDec = self.DecPcds.get((Name,Guid))
>                  if PcdInDec:
>                      if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
>                                          self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
> @@ -1541,14 +1562,12 @@ class DscBuildData(PlatformBuildClassObject):
>          if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1:
>              return True
>          if Value[0] == '{' and Value[-1] == '}':
>              return True
>          if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:
> -            print 'foo = ', list(Value[2:-1])
>              return True
>          if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:
> -            print 'bar = ', list(Value[1:-1])
>              return True
>          return False
> 
>      def ExecuteCommand (self, Command):
>          try:
> @@ -1565,10 +1584,31 @@ class DscBuildData(PlatformBuildClassObject):
>                  Result = Result + '\\x%02x' % (Value & 0xff)
>                  Value = Value >> 8
>          Result = Result + '"'
>          return Result
> 
> +    def GetPcdMaxSize(self,Pcd):
> +        MaxSize = int(Pcd.MaxDatumSize,10) if Pcd.MaxDatumSize else 0
> +        if Pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT64']:
> +            if Pcd.PcdValueFromComm:
> +                if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"):
> +                    MaxSize = max([len(Pcd.PcdValueFromComm.split(",")),MaxSize])
> +                elif Pcd.PcdValueFromComm.startswith("\"") or Pcd.PcdValueFromComm.startswith("\'"):
> +                    MaxSize = max([len(Pcd.PcdValueFromComm)-2+1,MaxSize])
> +                elif Pcd.PcdValueFromComm.startswith("L\""):
> +                    MaxSize = max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize])
> +                else:
> +                    MaxSize = max([len(Pcd.PcdValueFromComm),MaxSize])
> +        elif Pcd.DatumType not in ['BOOLEAN','UINT8']:
> +            MaxSize = 1
> +        elif Pcd.DatumType  == 'UINT16':
> +            MaxSize = 2
> +        elif Pcd.DatumType  == 'UINT32':
> +            MaxSize = 4
> +        elif Pcd.DatumType  == 'UINT64':
> +            MaxSize = 8
> +        return MaxSize
>      def GenerateSizeFunction(self,Pcd):
>          CApp = "// Default Value in Dec \n"
>          CApp = CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
>          for FieldList in [Pcd.DefaultValues]:
>              if not FieldList:
> @@ -1623,10 +1663,35 @@ class DscBuildData(PlatformBuildClassObject):
>                                  FieldName = FieldName.split(']', 1)[1]
>                              FieldName = NewFieldName + FieldName
>                              while '[' in FieldName:
>                                  FieldName = FieldName.rsplit('[', 1)[0]
>                                  CApp = CApp + '  __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' %
> (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2],
> FieldList[FieldName_ori][0])
> +        if Pcd.PcdFieldValueFromComm:
> +            CApp = CApp + "// From Command Line \n"
> +        for FieldName in Pcd.PcdFieldValueFromComm:
> +            FieldName = "." + FieldName
> +            IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])
> +            if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and
> FieldList[FieldName.strip(".")][0].endswith('}')):
> +                try:
> +                    Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True)
> +                except BadExpression:
> +                    EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
> +                                    (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))),
> FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))
> +                Value, ValueSize = ParseFieldValue(Value)
> +                CApp = CApp + '  __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %%
> __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize,
> Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1],
> FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);
> +            else:
> +                NewFieldName = ''
> +                FieldName_ori = FieldName.strip('.')
> +                while '[' in  FieldName:
> +                    NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]'
> +                    ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])
> +                    FieldName = FieldName.split(']', 1)[1]
> +                FieldName = NewFieldName + FieldName
> +                while '[' in FieldName:
> +                    FieldName = FieldName.rsplit('[', 1)[0]
> +                    CApp = CApp + '  __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType,
> FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])
> +        CApp = CApp + "  *Size = (%d > *Size ? %d : *Size); // The Pcd maxsize is %d \n" %
> (self.GetPcdMaxSize(Pcd),self.GetPcdMaxSize(Pcd),self.GetPcdMaxSize(Pcd))
>          CApp = CApp + "}\n"
>          return CApp
>      def GenerateSizeStatments(self,Pcd):
>          CApp = '  Size = sizeof(%s);\n' % (Pcd.DatumType)
>          CApp = CApp + '  Cal_%s_%s_Size(&Size);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
> @@ -1762,10 +1827,72 @@ class DscBuildData(PlatformBuildClassObject):
>          CApp = CApp + "}\n"
>          return CApp
>      def GenerateInitValueStatement(self,Pcd,SkuName,DefaultStoreName):
>          CApp = '  Assign_%s_%s_%s_%s_Value(Pcd);\n' % (Pcd.TokenSpaceGuidCName,
> Pcd.TokenCName,SkuName,DefaultStoreName)
>          return CApp
> +    def GenerateCommandLineValue(self,Pcd):
> +        CApp = "// Value in CommandLine\n"
> +        CApp = CApp + "void Assign_%s_%s_CommandLine_Value(%s *Pcd){\n" % (Pcd.TokenSpaceGuidCName,
> Pcd.TokenCName,Pcd.DatumType)
> +        CApp = CApp + '  UINT32  FieldSize;\n'
> +        CApp = CApp + '  CHAR8   *Value;\n'
> +
> +        pcddefaultvalue = Pcd.PcdValueFromComm
> +        for FieldList in [pcddefaultvalue,Pcd.PcdFieldValueFromComm]:
> +            if not FieldList:
> +                continue
> +            if pcddefaultvalue and FieldList == pcddefaultvalue:
> +                IsArray = self.IsFieldValueAnArray(FieldList)
> +                if IsArray:
> +                    try:
> +                        FieldList = ValueExpressionEx(FieldList, "VOID*")(True)
> +                    except BadExpression:
> +                        EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DSC: %s" %
> +                                        (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList))
> +                Value, ValueSize = ParseFieldValue (FieldList)
> +
> +                if isinstance(Value, str):
> +                    CApp = CApp + '  Pcd = %s; // From Command Line \n' % (Value)
> +                elif IsArray:
> +                #
> +                # Use memcpy() to copy value into field
> +                #
> +                    CApp = CApp + '  Value     = %s; // From Command Line.\n' % (self.IntToCString(Value, ValueSize))
> +                    CApp = CApp + '  memcpy (Pcd, Value, %d);\n' % (ValueSize)
> +                continue
> +            for FieldName in FieldList:
> +                IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])
> +                if IsArray:
> +                    try:
> +                        FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True)
> +                    except BadExpression:
> +                        EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
> +                                        (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)),
> FieldList[FieldName][1], FieldList[FieldName][2]))
> +                    except:
> +                        print "error"
> +                try:
> +                    Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])
> +                except Exception:
> +                    EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
> (".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2]))
> +                if isinstance(Value, str):
> +                    CApp = CApp + '  Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value,
> FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
> +                elif IsArray:
> +                #
> +                # Use memcpy() to copy value into field
> +                #
> +                    CApp = CApp + '  FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName)
> +                    CApp = CApp + '  Value     = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize),
> FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
> +                    CApp = CApp + '  memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' %
> (FieldName, ValueSize, ValueSize)
> +                else:
> +                    if ValueSize > 4:
> +                        CApp = CApp + '  Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value,
> FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
> +                    else:
> +                        CApp = CApp + '  Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName, Value,
> FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
> +        CApp = CApp + "}\n"
> +        return CApp
> +    def GenerateCommandLineValueStatement(self,Pcd):
> +        CApp = '  Assign_%s_%s_CommandLine_Value(Pcd);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
> +        return CApp
>      def GenerateInitializeFunc(self, SkuName, DefaultStore, Pcd, InitByteValue, CApp):
>          OverrideValues = {DefaultStore:""}
>          if Pcd.SkuOverrideValues:
>              OverrideValues = Pcd.SkuOverrideValues[SkuName]
>          for DefaultStoreName in OverrideValues.keys():
> @@ -1833,10 +1960,11 @@ class DscBuildData(PlatformBuildClassObject):
>                      if skuname == SkuName:
>                          break
>              else:
>                  CApp = CApp + "// SkuName: DEFAULT,  DefaultStoreName: STANDARD \n"
>                  CApp = CApp + self.GenerateInitValueStatement(Pcd,"DEFAULT","STANDARD")
> +            CApp = CApp + self.GenerateCommandLineValueStatement(Pcd)
>              #
>              # Set new PCD value and size
>              #
>              CApp = CApp + '  PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *)Pcd);\n' % (SkuName, DefaultStoreName,
> Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
> 
> @@ -1868,10 +1996,11 @@ class DscBuildData(PlatformBuildClassObject):
>          CApp = CApp + '\n'
>          for PcdName in StructuredPcds:
>              Pcd = StructuredPcds[PcdName]
>              CApp = CApp + self.GenerateSizeFunction(Pcd)
>              CApp = CApp + self.GenerateDefaultValueAssignFunction(Pcd)
> +            CApp = CApp + self.GenerateCommandLineValue(Pcd)
>              if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
>                          self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
>                  CApp = CApp + self.GenerateInitValueFunction(Pcd,self.SkuIdMgr.SystemSkuId, 'STANDARD')
>              else:
>                  for SkuName in self.SkuIdMgr.SkuOverrideOrder():
> @@ -2372,11 +2501,11 @@ class DscBuildData(PlatformBuildClassObject):
> 
>              if pcd.MaxDatumSize.strip():
>                  MaxSize = int(pcd.MaxDatumSize, 0)
>              else:
>                  MaxSize = 0
> -            if pcdDecObject.DatumType == 'VOID*':
> +            if pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT64']:
>                  for (_, skuobj) in pcd.SkuInfoList.items():
>                      datalen = 0
>                      skuobj.HiiDefaultValue = StringToArray(skuobj.HiiDefaultValue)
>                      datalen = len(skuobj.HiiDefaultValue.split(","))
>                      if datalen > MaxSize:
> diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
> index bb130a02cc..85612d90ce 100644
> --- a/BaseTools/Source/Python/build/build.py
> +++ b/BaseTools/Source/Python/build/build.py
> @@ -770,11 +770,11 @@ class Build():
>          self.TargetTxt      = TargetTxtClassObject()
>          self.ToolDef        = ToolDefClassObject()
>          self.AutoGenTime    = 0
>          self.MakeTime       = 0
>          self.GenFdsTime     = 0
> -        GlobalData.BuildOptionPcd     = BuildOptions.OptionPcd if BuildOptions.OptionPcd else {}
> +        GlobalData.BuildOptionPcd     = BuildOptions.OptionPcd if BuildOptions.OptionPcd else []
>          #Set global flag for build mode
>          GlobalData.gIgnoreSource = BuildOptions.IgnoreSources
>          GlobalData.gUseHashCache = BuildOptions.UseHashCache
>          GlobalData.gBinCacheDest   = BuildOptions.BinCacheDest
>          GlobalData.gBinCacheSource = BuildOptions.BinCacheSource
> --
> 2.14.3.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 2/2] BaseTools: Fixed build failed issue.
  2018-03-02 10:11 ` [Patch 2/2] BaseTools: Fixed build failed issue BobCF
@ 2018-03-02 13:35   ` Gao, Liming
  0 siblings, 0 replies; 4+ messages in thread
From: Gao, Liming @ 2018-03-02 13:35 UTC (permalink / raw)
  To: Feng, Bob C, edk2-devel@lists.01.org

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Feng, Bob C
> Sent: Friday, March 2, 2018 6:11 PM
> To: edk2-devel@lists.01.org
> Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [Patch 2/2] BaseTools: Fixed build failed issue.
> 
> Case 1. A Pcd has no default sku setting in DSC.
> Case 2. Build as Single SKU.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bob Feng <bob.c.feng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> ---
>  BaseTools/Source/Python/Workspace/DscBuildData.py | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
> index 239531cd1c..cd633e964d 100644
> --- a/BaseTools/Source/Python/Workspace/DscBuildData.py
> +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
> @@ -1317,14 +1317,14 @@ class DscBuildData(PlatformBuildClassObject):
>              if str_pcd_dec:
>                  str_pcd_obj_str = StructurePcd()
>                  str_pcd_obj_str.copy(str_pcd_dec)
>                  if str_pcd_obj:
>                      str_pcd_obj_str.copy(str_pcd_obj)
> -                if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],
> self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
> -                    str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore:
> str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for
> defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
> -                else:
> -                    str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore:
> str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore
> in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
> +                    if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],
> self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
> +                        str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore:
> str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for
> defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
> +                    else:
> +                        str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore:
> str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore
> in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
>                  for str_pcd_data in StrPcdSet[str_pcd]:
>                      if str_pcd_data[3] in SkuIds:
>                          str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3]
> == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File if
> self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else
> len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5])
>                  S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str
>              else:
> @@ -1762,10 +1762,13 @@ class DscBuildData(PlatformBuildClassObject):
>          CApp = CApp + "// SkuName: %s,  DefaultStoreName: %s \n" % ('DEFAULT', 'STANDARD')
>          inherit_OverrideValues = Pcd.SkuOverrideValues[SkuName]
>          if (SkuName,DefaultStoreName) == ('DEFAULT','STANDARD'):
>              pcddefaultvalue = Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC
> else Pcd.DefaultValue
>          else:
> +            if not Pcd.DscRawValue:
> +                # handle the case that structure pcd is not appear in DSC
> +                self.CopyDscRawValue(Pcd)
>              pcddefaultvalue = Pcd.DscRawValue.get(SkuName,{}).get(DefaultStoreName)
>          for FieldList in [pcddefaultvalue,inherit_OverrideValues.get(DefaultStoreName)]:
>              if not FieldList:
>                  continue
>              if pcddefaultvalue and FieldList == pcddefaultvalue:
> @@ -1958,12 +1961,12 @@ class DscBuildData(PlatformBuildClassObject):
>                          CApp = CApp + "// SkuName: %s,  DefaultStoreName: %s \n" % (skuname, defaultstorenameitem)
>                          CApp = CApp + self.GenerateInitValueStatement(Pcd,skuname,defaultstorenameitem)
>                      if skuname == SkuName:
>                          break
>              else:
> -                CApp = CApp + "// SkuName: DEFAULT,  DefaultStoreName: STANDARD \n"
> -                CApp = CApp + self.GenerateInitValueStatement(Pcd,"DEFAULT","STANDARD")
> +                CApp = CApp + "// SkuName: %s,  DefaultStoreName: STANDARD \n" % self.SkuIdMgr.SystemSkuId
> +                CApp = CApp + self.GenerateInitValueStatement(Pcd,self.SkuIdMgr.SystemSkuId,"STANDARD")
>              CApp = CApp + self.GenerateCommandLineValueStatement(Pcd)
>              #
>              # Set new PCD value and size
>              #
>              CApp = CApp + '  PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *)Pcd);\n' % (SkuName, DefaultStoreName,
> Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
> @@ -2325,10 +2328,14 @@ class DscBuildData(PlatformBuildClassObject):
>          else:
>              return False
>      def CopyDscRawValue(self,Pcd):
>          if Pcd.DscRawValue is None:
>              Pcd.DscRawValue = dict()
> +        if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
> self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
> +            if self.SkuIdMgr.SystemSkuId not in Pcd.DscRawValue:
> +                Pcd.DscRawValue[self.SkuIdMgr.SystemSkuId] = {}
> +            Pcd.DscRawValue[self.SkuIdMgr.SystemSkuId]['STANDARD'] = Pcd.DefaultValue
>          for skuname in Pcd.SkuInfoList:
>              Pcd.DscRawValue[skuname] = {}
>              if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],
> self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
>                  for defaultstore in Pcd.SkuInfoList[skuname].DefaultStoreDict:
>                      Pcd.DscRawValue[skuname][defaultstore] = Pcd.SkuInfoList[skuname].DefaultStoreDict[defaultstore]
> @@ -2339,19 +2346,19 @@ class DscBuildData(PlatformBuildClassObject):
>          DefaultStoreObj = DefaultStore(self._GetDefaultStores())
>          SkuIds = {skuname:skuid for skuname,skuid in self.SkuIdMgr.AvailableSkuIdSet.items() if skuname !='COMMON'}
>          DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in
> skuobj.DefaultStoreDict.keys()])
>          for PcdCName, TokenSpaceGuid in PcdSet:
>              PcdObj = PcdSet[(PcdCName, TokenSpaceGuid)]
> +            self.CopyDscRawValue(PcdObj)
>              if PcdObj.Type not in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_DEFAULT],
>                          self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],
>                          self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_VPD],
>                          self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_DEFAULT],
>                          self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII],
>                          self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_VPD]]:
>                  Pcds[PcdCName, TokenSpaceGuid]= PcdObj
>                  continue
> -            self.CopyDscRawValue(PcdObj)
>              PcdType = PcdObj.Type
>              if PcdType in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],
> self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
>                  for skuid in PcdObj.SkuInfoList:
>                      skuobj = PcdObj.SkuInfoList[skuid]
>                      mindefaultstorename = DefaultStoreObj.GetMin(set([defaultstorename  for defaultstorename in
> skuobj.DefaultStoreDict]))
> --
> 2.14.3.windows.1



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

end of thread, other threads:[~2018-03-02 13:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-02 10:11 [Patch 1/2] BaseTools: Fixed Pcd value override issue BobCF
2018-03-02 10:11 ` [Patch 2/2] BaseTools: Fixed build failed issue BobCF
2018-03-02 13:35   ` Gao, Liming
2018-03-02 13:35 ` [Patch 1/2] BaseTools: Fixed Pcd value override issue Gao, Liming

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