public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: BobCF <bob.c.feng@intel.com>
To: edk2-devel@lists.01.org
Cc: Bob Feng <bob.c.feng@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [Patch 1/4] BaseTools: Fixed the pcd value override issue.
Date: Wed, 28 Feb 2018 13:59:18 +0800	[thread overview]
Message-ID: <20180228055921.35432-1-bob.c.feng@intel.com> (raw)

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



             reply	other threads:[~2018-02-28  5:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28  5:59 BobCF [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180228055921.35432-1-bob.c.feng@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox