public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 1/4] BaseTools: Fixed the pcd value override issue.
@ 2018-02-28  5:59 BobCF
  2018-02-28  5:59 ` [Patch 2/4] BaseTools: Improve build performance BobCF
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: BobCF @ 2018-02-28  5:59 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

1. the issue in the overriding value from command line.
2. dec fully value < dec field assign value <
   dsc fully value < dsc field assign value

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/GenMake.py         | 39 +++++++++++-----------
 .../Source/Python/Workspace/BuildClassObject.py    |  4 +++
 BaseTools/Source/Python/Workspace/DecBuildData.py  |  1 +
 BaseTools/Source/Python/Workspace/DscBuildData.py  | 24 ++++++++++---
 4 files changed, 44 insertions(+), 24 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 4b924d21e0..1b0cf17e25 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -1549,30 +1549,29 @@ class TopLevelMakefile(BuildFile):
         if GlobalData.gEnableGenfdsMultiThread:
             ExtraOption += " --genfds-multi-thread"
         if GlobalData.gIgnoreSource:
             ExtraOption += " --ignore-sources"
 
-        if GlobalData.BuildOptionPcd:
-            for index, option in enumerate(GlobalData.gCommand):
-                if "--pcd" == option and GlobalData.gCommand[index+1]:
-                    pcdName, pcdValue = GlobalData.gCommand[index+1].split('=')
-                    for Item in GlobalData.BuildOptionPcd:
-                        if '.'.join(Item[0:2]) == pcdName:
-                            pcdValue = Item[2]
-                            if pcdValue.startswith('L') or pcdValue.startswith('"'):
-                                pcdValue, Size = ParseFieldValue(pcdValue)
-                                NewVal = '{'
-                                for S in range(Size):
-                                    NewVal = NewVal + '0x%02X' % ((pcdValue >> S * 8) & 0xff)
-                                    NewVal += ','
-                                pcdValue =  NewVal[:-1] + '}'
-                            break
-                    if pcdValue.startswith('{'):
-                        pcdValue = 'H' + '"' + pcdValue + '"'
-                        ExtraOption += " --pcd " + pcdName + '=' + pcdValue
-                    else:
-                        ExtraOption += " --pcd " + GlobalData.gCommand[index+1]
+        for index, option in enumerate(GlobalData.gCommand):
+            if "--pcd" == option and GlobalData.gCommand[index+1]:
+                pcdName, pcdValue = GlobalData.gCommand[index+1].split('=')
+                for Item in GlobalData.BuildOptionPcd:
+                    if '.'.join(Item[0:2]) == pcdName:
+                        pcdValue = Item[2]
+                        if pcdValue.startswith('L') or pcdValue.startswith('"'):
+                            pcdValue, Size = ParseFieldValue(pcdValue)
+                            NewVal = '{'
+                            for S in range(Size):
+                                NewVal = NewVal + '0x%02X' % ((pcdValue >> S * 8) & 0xff)
+                                NewVal += ','
+                            pcdValue =  NewVal[:-1] + '}'
+                        break
+                if pcdValue.startswith('{'):
+                    pcdValue = 'H' + '"' + pcdValue + '"'
+                    ExtraOption += " --pcd " + pcdName + '=' + pcdValue
+                else:
+                    ExtraOption += " --pcd " + GlobalData.gCommand[index+1]
 
         MakefileName = self._FILE_NAME_[self._FileType]
         SubBuildCommandList = []
         for A in PlatformInfo.ArchList:
             Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":os.path.join("$(BUILD_DIR)", A, MakefileName)}
diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index f499cbd58b..05a83e84ac 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -124,19 +124,22 @@ class StructurePcd(PcdClassObject):
         self.SkuOverrideValues = collections.OrderedDict({})
         self.FlexibleFieldName = None
         self.StructName = None
         self.PcdDefineLineNo = 0
         self.PkgPath = ""
+        self.DefaultValueFromDec = ""
     def __repr__(self):
         return self.TypeName
 
     def AddDefaultValue (self, FieldName, Value, FileName="", LineNo=0):
         if FieldName in self.DefaultValues:
             del self.DefaultValues[FieldName]
         self.DefaultValues[FieldName] = [Value.strip(), FileName, LineNo]
         return self.DefaultValues[FieldName]
 
+    def SetDecDefaultValue(self,DefaultValue):
+        self.DefaultValueFromDec = DefaultValue
     def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreName, FileName="", LineNo=0):
         if SkuName not in self.SkuOverrideValues:
             self.SkuOverrideValues[SkuName] = collections.OrderedDict({})
         if DefaultStoreName not in self.SkuOverrideValues[SkuName]:
             self.SkuOverrideValues[SkuName][DefaultStoreName] = collections.OrderedDict({})
@@ -173,10 +176,11 @@ class StructurePcd(PcdClassObject):
             self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile
             self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs
             self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues
             self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode
             self.DefaultFromDSC=None
+            self.DefaultValueFromDec = PcdObject.DefaultValueFromDec if PcdObject.DefaultValueFromDec else self.DefaultValueFromDec
             self.SkuOverrideValues = PcdObject.SkuOverrideValues if PcdObject.SkuOverrideValues else self.SkuOverrideValues
             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
diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py
index 99c3bf14f1..61f15086d0 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -383,10 +383,11 @@ class DecBuildData(PackageBuildClassObject):
                     struct_pcd.copy(item)
                     struct_pcd.TokenValue = struct_pcd.TokenValue.strip("{").strip()
                     struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName = pcdname.split(".")
                     struct_pcd.PcdDefineLineNo = LineNo
                     struct_pcd.PkgPath = self.MetaFile.File
+                    struct_pcd.SetDecDefaultValue(item.DefaultValue)
                 else:
                     struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo)
 
             struct_pcd.PackageDecs = dep_pkgs
             if not struct_pcd.StructuredPcdIncludeFile:
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index ea8d1847f7..393ad0265f 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -892,16 +892,15 @@ class DscBuildData(PlatformBuildClassObject):
         if GlobalData.BuildOptionPcd:
             for pcd in GlobalData.BuildOptionPcd:
                 if pcd[2] == "":
                     pcdset.append((pcd[0],pcd[1],pcd[3]))
                 else:
-                    pcdobj = self._Pcds.get((pcd[1],pcd[0]))
-                    if pcdobj:
-                        pcdset.append((pcd[0],pcd[1], pcdobj.DefaultValue))
-                    else:
+                    if (pcd[1],pcd[0]) not in self._Pcds:
                         pcdvalue = pcd[3] if len(pcd) == 4 else pcd[2]
                         pcdset.append((pcd[0],pcd[1],pcdvalue))
+                    #else:
+                        # remove the settings from command line since it has been handled.
         GlobalData.BuildOptionPcd = pcdset
     def GetFieldValueFromComm(self,ValueStr,TokenSpaceGuidCName, TokenCName, FieldName):
         PredictedFieldType = "VOID*"
         if ValueStr.startswith('L'):
             if not ValueStr[1]:
@@ -1674,10 +1673,27 @@ class DscBuildData(PlatformBuildClassObject):
 
             #
             # Assign field values in PCD
             #
             CApp = CApp + "// Default value in Dec \n"
+            DefaultValueFromDec = Pcd.DefaultValueFromDec
+            IsArray = self.IsFieldValueAnArray(Pcd.DefaultValueFromDec)
+            if IsArray:
+                try:
+                    DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, "VOID*")(True)
+                except BadExpression:
+                    EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DEC: %s" %
+                                    (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValueFromDec))
+            Value, ValueSize = ParseFieldValue (DefaultValueFromDec)
+            if isinstance(Value, str):
+                CApp = CApp + '  Pcd = %s; // From DEC Default Value %s\n' % (Value, Pcd.DefaultValueFromDec)
+            elif IsArray:
+            #
+            # Use memcpy() to copy value into field
+            #
+                CApp = CApp + '  Value     = %s; // From DEC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultValueFromDec)
+                CApp = CApp + '  memcpy (Pcd, Value, %d);\n' % (ValueSize)
             for FieldList in [Pcd.DefaultValues]:
                 if not FieldList:
                     continue
                 for FieldName in FieldList:
                     IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])
-- 
2.14.3.windows.1



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

end of thread, other threads:[~2018-02-28  6:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-28  5:59 [Patch 1/4] BaseTools: Fixed the pcd value override issue BobCF
2018-02-28  5:59 ` [Patch 2/4] BaseTools: Improve build performance BobCF
2018-02-28  5:59 ` [Patch 3/4] BaseTool: GUID assignment fail BobCF
2018-02-28  5:59 ` [Patch 4/4] BaseTools: Improve build performance BobCF
2018-02-28  6:46 ` [Patch 1/4] BaseTools: Fixed the 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