* [Patch 2/2] BaseTools: Fixed the pcd value override issue.
@ 2018-02-23 9:53 BobCF
0 siblings, 0 replies; only message in thread
From: BobCF @ 2018-02-23 9:53 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 | 27 +++++++++++-----------
.../Source/Python/Workspace/BuildClassObject.py | 4 ++++
BaseTools/Source/Python/Workspace/DecBuildData.py | 1 +
BaseTools/Source/Python/Workspace/DscBuildData.py | 24 +++++++++++++++----
4 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index afe6f2f99c..110174fb17 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -1549,24 +1549,23 @@ 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('=')
- if pcdValue.startswith('H'):
- pcdValue = 'H' + '"' + pcdValue[1:] + '"'
- ExtraOption += " --pcd " + pcdName + '=' + pcdValue
- elif pcdValue.startswith("L'"):
- ExtraOption += "--pcd " + pcdName + '=' + pcdValue
- elif pcdValue.startswith('L'):
- pcdValue = 'L' + '"' + pcdValue[1:] + '"'
- 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('=')
+ if pcdValue.startswith('H'):
+ pcdValue = 'H' + '"' + pcdValue[1:] + '"'
+ ExtraOption += " --pcd " + pcdName + '=' + pcdValue
+ elif pcdValue.startswith("L'"):
+ ExtraOption += "--pcd " + pcdName + '=' + pcdValue
+ elif pcdValue.startswith('L'):
+ pcdValue = 'L' + '"' + pcdValue[1:] + '"'
+ 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 f029169489..18101a0add 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -386,10 +386,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 5d2922ba44..3246a2afd8 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -895,16 +895,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]:
@@ -1668,10 +1667,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] only message in thread
only message in thread, other threads:[~2018-02-23 9:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-23 9:53 [Patch 2/2] BaseTools: Fixed the pcd value override issue BobCF
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox