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] BaseTools: Fixed Pcd from command line issue.
Date: Thu, 8 Mar 2018 13:56:21 +0800 [thread overview]
Message-ID: <20180308055621.10952-1-bob.c.feng@intel.com> (raw)
Save the pcd command line value in Pcd object
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/GenC.py | 15 +++--------
BaseTools/Source/Python/AutoGen/GenMake.py | 28 +++++++------------
.../Source/Python/Workspace/BuildClassObject.py | 4 +--
BaseTools/Source/Python/Workspace/DscBuildData.py | 31 +++++++++++-----------
4 files changed, 31 insertions(+), 47 deletions(-)
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 3e98506cc8..481c4dda14 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -914,15 +914,12 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
PcdTokenName = '_PCD_TOKEN_' + TokenCName
PatchPcdSizeTokenName = '_PCD_PATCHABLE_' + TokenCName +'_SIZE'
PatchPcdSizeVariableName = '_gPcd_BinaryPatch_Size_' + TokenCName
FixPcdSizeTokenName = '_PCD_SIZE_' + TokenCName
- if GlobalData.BuildOptionPcd:
- for PcdItem in GlobalData.BuildOptionPcd:
- if (Pcd.TokenSpaceGuidCName, TokenCName) == (PcdItem[0], PcdItem[1]):
- Pcd.DefaultValue = PcdItem[2]
- break
+ if Pcd.PcdValueFromComm:
+ Pcd.DefaultValue = Pcd.PcdValueFromComm
if Pcd.Type in gDynamicExPcd:
TokenNumber = int(Pcd.TokenValue, 0)
# Add TokenSpaceGuidValue value to PcdTokenName to discriminate the DynamicEx PCDs with
# different Guids but same TokenCName
@@ -1213,16 +1210,12 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
PcdTokenName = '_PCD_TOKEN_' + TokenCName
FixPcdSizeTokenName = '_PCD_SIZE_' + TokenCName
PatchPcdSizeTokenName = '_PCD_PATCHABLE_' + TokenCName +'_SIZE'
PatchPcdSizeVariableName = '_gPcd_BinaryPatch_Size_' + TokenCName
- if GlobalData.BuildOptionPcd:
- for PcdItem in GlobalData.BuildOptionPcd:
- if (Pcd.TokenSpaceGuidCName, TokenCName) == (PcdItem[0], PcdItem[1]):
- Pcd.DefaultValue = PcdItem[2]
- break
-
+ if Pcd.PcdValueFromComm:
+ Pcd.DefaultValue = Pcd.PcdValueFromComm
#
# Write PCDs
#
if Pcd.Type in gDynamicExPcd:
TokenNumber = int(Pcd.TokenValue, 0)
diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 1b0cf17e25..60bd625cd2 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -1549,29 +1549,19 @@ class TopLevelMakefile(BuildFile):
if GlobalData.gEnableGenfdsMultiThread:
ExtraOption += " --genfds-multi-thread"
if GlobalData.gIgnoreSource:
ExtraOption += " --ignore-sources"
- 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 pcd in GlobalData.BuildOptionPcd:
+ if pcd[2]:
+ pcdname = '.'.join(pcd[0:3])
+ else:
+ pcdname = '.'.join(pcd[0:2])
+ if pcd[3].startswith('{'):
+ ExtraOption += " --pcd " + pcdname + '=' + 'H' + '"' + pcd[3] + '"'
+ else:
+ ExtraOption += " --pcd " + pcdname + '=' + pcd[3]
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 711ba492ef..1352fa21c8 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -66,10 +66,11 @@ class PcdClassObject(object):
self.expressions = expressions
self.DscDefaultValue = None
self.DscRawValue = None
if IsDsc:
self.DscDefaultValue = Value
+ self.PcdValueFromComm = ""
## Convert the class to a string
#
# Convert each member of the class to string
# Organize to a signle line format string
@@ -127,11 +128,10 @@ 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):
@@ -175,10 +175,11 @@ class StructurePcd(PcdClassObject):
self.IsFromDsc = PcdObject.IsFromDsc if PcdObject.IsFromDsc else self.IsFromDsc
self.validateranges = PcdObject.validateranges if PcdObject.validateranges else self.validateranges
self.validlists = PcdObject.validlists if PcdObject.validlists else self.validlists
self.expressions = PcdObject.expressions if PcdObject.expressions else self.expressions
self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue
+ self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm
if type(PcdObject) is StructurePcd:
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
@@ -188,11 +189,10 @@ 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 9d787702c2..e72b7779ce 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -891,22 +891,22 @@ class DscBuildData(PlatformBuildClassObject):
mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet)
skuobj.DefaultStoreDict['STANDARD'] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename])
return Pcds
def RecoverCommandLinePcd(self):
- pcdset = []
- if GlobalData.BuildOptionPcd:
- for pcd in GlobalData.BuildOptionPcd:
- if pcd[2] == "":
- pcdset.append((pcd[0],pcd[1],pcd[3]))
- 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 UpdateCommandLineValue(pcd):
+ if pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
+ self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
+ pcd.PcdValueFromComm = pcd.DefaultValue
+ elif pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
+ pcd.PcdValueFromComm = pcd.SkuInfoList.get("DEFAULT").HiiDefaultValue
+ else:
+ pcd.PcdValueFromComm = pcd.SkuInfoList.get("DEFAULT").DefaultValue
+ for pcd in self._Pcds:
+ if isinstance(self._Pcds[pcd],StructurePcd) and (self._Pcds[pcd].PcdValueFromComm or self._Pcds[pcd].PcdFieldValueFromComm):
+ UpdateCommandLineValue(self._Pcds[pcd])
+
def GetFieldValueFromComm(self,ValueStr,TokenSpaceGuidCName, TokenCName, FieldName):
PredictedFieldType = "VOID*"
if ValueStr.startswith('L'):
if not ValueStr[1]:
EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')
@@ -1240,10 +1240,11 @@ class DscBuildData(PlatformBuildClassObject):
if (Name,Guid) in AllPcds:
Pcd = AllPcds.get((Name,Guid))
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.PcdValueFromComm = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]
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]
@@ -1264,13 +1265,12 @@ class DscBuildData(PlatformBuildClassObject):
else:
MaxSize = max([len(Pcd.DefaultValue),MaxSize])
Pcd.MaxDatumSize = str(MaxSize)
else:
PcdInDec = self.DecPcds.get((Name,Guid))
- if isinstance(PcdInDec,StructurePcd):
- PcdInDec.PcdValueFromComm = NoFiledValues[(Guid,Name)][0]
if PcdInDec:
+ PcdInDec.PcdValueFromComm = NoFiledValues[(Guid,Name)][0]
if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
self.Pcds[Name, Guid] = copy.deepcopy(PcdInDec)
self.Pcds[Name, Guid].DefaultValue = NoFiledValues[( Guid,Name)][0]
return AllPcds
@@ -1709,10 +1709,11 @@ class DscBuildData(PlatformBuildClassObject):
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))
+ DefaultValueFromDec = StringToArray(DefaultValueFromDec)
Value, ValueSize = ParseFieldValue (DefaultValueFromDec)
if isinstance(Value, str):
CApp = CApp + ' Pcd = %s; // From DEC Default Value %s\n' % (Value, Pcd.DefaultValueFromDec)
elif IsArray:
#
@@ -1848,11 +1849,11 @@ class DscBuildData(PlatformBuildClassObject):
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" %
+ EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from Command: %s" %
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList))
Value, ValueSize = ParseFieldValue (FieldList)
if isinstance(Value, str):
CApp = CApp + ' Pcd = %s; // From Command Line \n' % (Value)
--
2.14.3.windows.1
next reply other threads:[~2018-03-08 5:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-08 5:56 BobCF [this message]
2018-03-09 2:09 ` [Patch] BaseTools: Fixed Pcd from command line issue Gao, Liming
-- strict thread matches above, loose matches on Subject: below --
2018-03-08 3:27 BobCF
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=20180308055621.10952-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