diff options
author | Bob Feng <bob.c.feng@intel.com> | 2015-04-10 06:59:47 +0000 |
---|---|---|
committer | bobfeng <bobfeng@Edk2> | 2015-04-10 06:59:47 +0000 |
commit | 82a6a9605c35f814bd6187979980258ed1b75abd (patch) | |
tree | 05d5b1bf15a51c30754bcf288da9fd7421c0f0be /BaseTools/Source/Python/Workspace | |
parent | b7668ccee92a7f5d0aaadfc94787e200b2cc1240 (diff) | |
download | edk2-platforms-82a6a9605c35f814bd6187979980258ed1b75abd.tar.xz |
BaseTools/Build: Add SDL support
1.BaseTool add ATTRIBUTE (+/-RT, RO) support in PCD declaration in DSC file
2.BaseTool collect valid PCD value in DEC file and generate data base for runtime sanity check
3.BaseTool support SetPcd error.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: "Bob Feng" <bob.c.feng@intel.com>
Reviewed-by: "Chen, Hesheng" <hesheng.chen@intel.com>
Reviewed-by: "Liu, Yingke D" <yingke.d.liu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17158 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/Workspace')
4 files changed, 75 insertions, 10 deletions
diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 8b98f164fd..ea26e5e5a1 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -1,7 +1,7 @@ ## @file
# This file is used to define each component of the build database
#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -44,7 +44,7 @@ from Common.BuildToolError import * # @var Phase: To store value for Phase, default is "DXE"
#
class PcdClassObject(object):
- def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}, IsOverrided = False, GuidValue = None):
+ def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}, IsOverrided = False, GuidValue = None, validateranges = [], validlists = [], expressions = []):
self.TokenCName = Name
self.TokenSpaceGuidCName = Guid
self.TokenSpaceGuidValue = GuidValue
@@ -59,6 +59,9 @@ class PcdClassObject(object): self.IsOverrided = IsOverrided
self.IsFromBinaryInf = False
self.IsFromDsc = False
+ self.validateranges = validateranges
+ self.validlists = validlists
+ self.expressions = expressions
## Convert the class to a string
#
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index f96c73c1db..eb02b664a6 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -376,7 +376,8 @@ class MetaFileParser(object): File=self.MetaFile,
Line=self._LineIndex + 1
)
-
+ def GetValidExpression(self, TokenSpaceGuid, PcdCName):
+ return self._Table.GetValidExpression(TokenSpaceGuid, PcdCName)
def _GetMacros(self):
Macros = {}
Macros.update(self._FileLocalMacros)
@@ -814,6 +815,7 @@ class DscParser(MetaFileParser): "PLATFORM_VERSION",
"SKUID_IDENTIFIER",
"PCD_INFO_GENERATION",
+ "PCD_VAR_CHECK_GENERATION",
"SUPPORTED_ARCHITECTURES",
"BUILD_TARGETS",
"OUTPUT_DIRECTORY",
diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py index 607225a0ef..89a12cd228 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py @@ -1,7 +1,7 @@ ## @file
# This file is used to create/update/query/erase a meta file table
#
-# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -225,6 +225,26 @@ class PackageTable(MetaFileTable): SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)
return self.Exec(SqlCommand)
+ def GetValidExpression(self, TokenSpaceGuid, PcdCName):
+ SqlCommand = "select Value1 from %s WHERE Value2='%s' and Value3='%s'" % (self.Table, TokenSpaceGuid, PcdCName)
+ self.Cur.execute(SqlCommand)
+ validateranges = []
+ validlists = []
+ expressions = []
+ for row in self.Cur:
+ comment = row[0]
+ comment = comment.strip("#")
+ comment = comment.strip()
+ if comment.startswith("@ValidRange"):
+ comment = comment.replace("@ValidRange", "", 1)
+ validateranges.append(comment.split("|")[1].strip())
+ if comment.startswith("@ValidList"):
+ comment = comment.replace("@ValidList", "", 1)
+ validlists.append(comment.split("|")[1].strip())
+ if comment.startswith("@Expression"):
+ comment = comment.replace("@Expression", "", 1)
+ expressions.append(comment.split("|")[1].strip())
+ return set(validateranges), set(validlists), set(expressions)
## Python class representation of table storing platform data
class PlatformTable(MetaFileTable):
_COLUMN_ = '''
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index 83f730e629..9f79f74e8f 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -1,7 +1,7 @@ ## @file
# This file is used to create a database used by build tool
#
-# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -38,7 +38,7 @@ from Common.Misc import AnalyzeDscPcd from Common.Misc import ProcessDuplicatedInf
import re
from Common.Parsing import IsValidWord
-
+from Common.VariableAttributes import VariableAttributes
import Common.GlobalData as GlobalData
## Platform build information from DSC file
@@ -133,6 +133,7 @@ class DscBuildData(PlatformBuildClassObject): self._SkuName = None
self._SkuIdentifier = None
self._PcdInfoFlag = None
+ self._VarCheckFlag = None
self._FlashDefinition = None
self._BuildNumber = None
self._MakefileName = None
@@ -233,6 +234,8 @@ class DscBuildData(PlatformBuildClassObject): self._SkuIdentifier = Record[2]
elif Name == TAB_DSC_DEFINES_PCD_INFO_GENERATION:
self._PcdInfoFlag = Record[2]
+ elif Name == TAB_DSC_DEFINES_PCD_VAR_CHECK_GENERATION:
+ self._VarCheckFlag = Record[2]
elif Name == TAB_FIX_LOAD_TOP_MEMORY_ADDRESS:
try:
self._LoadFixAddress = int (Record[2], 0)
@@ -352,6 +355,13 @@ class DscBuildData(PlatformBuildClassObject): return True
else:
return False
+ def _GetVarCheckFlag(self):
+ if self._VarCheckFlag == None or self._VarCheckFlag.upper() == 'FALSE':
+ return False
+ elif self._VarCheckFlag.upper() == 'TRUE':
+ return True
+ else:
+ return False
def _GetSkuIdentifier(self):
if self._SkuName:
@@ -898,6 +908,17 @@ class DscBuildData(PlatformBuildClassObject): return Pcds
+ def CompareVarAttr(self, Attr1, Attr2):
+ if not Attr1 or not Attr2: # for empty string
+ return True
+ Attr1s = [attr.strip() for attr in Attr1.split(",")]
+ Attr1Set = set(Attr1s)
+ Attr2s = [attr.strip() for attr in Attr2.split(",")]
+ Attr2Set = set(Attr2s)
+ if Attr2Set == Attr1Set:
+ return True
+ else:
+ return False
## Retrieve dynamic HII PCD settings
#
# @param Type PCD type
@@ -907,6 +928,7 @@ class DscBuildData(PlatformBuildClassObject): def _GetDynamicHiiPcd(self, Type):
SkuObj = SkuClass(self.SkuIdentifier,self.SkuIds)
+ VariableAttrs = {}
Pcds = sdict()
#
@@ -931,8 +953,12 @@ class DscBuildData(PlatformBuildClassObject): Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
- VariableName, VariableGuid, VariableOffset, DefaultValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
+ VariableName, VariableGuid, VariableOffset, DefaultValue, VarAttribute = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
+ rt, Msg = VariableAttributes.ValidateVarAttributes(VarAttribute)
+ if not rt:
+ EdkLogger.error("build", PCD_VARIABLE_ATTRIBUTES_ERROR, "Variable attributes settings for %s is incorrect.\n %s" % (".".join((TokenSpaceGuid, PcdCName)), Msg),
+ ExtraData = "[%s]" % VarAttribute)
ExceedMax = False
FormatCorrect = True
if VariableOffset.isdigit():
@@ -955,8 +981,14 @@ class DscBuildData(PlatformBuildClassObject): if ExceedMax:
EdkLogger.error('Build', OPTION_VALUE_INVALID, "The variable offset value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid,PcdCName)))
+ if (VariableName, VariableGuid) not in VariableAttrs:
+ VariableAttrs[(VariableName, VariableGuid)] = VarAttribute
+ else:
+ if not self.CompareVarAttr(VariableAttrs[(VariableName, VariableGuid)], VarAttribute):
+ EdkLogger.error('Build', PCD_VARIABLE_ATTRIBUTES_CONFLICT_ERROR, "The variable %s.%s for DynamicHii PCDs has conflicting attributes [%s] and [%s] " % (VariableGuid, VariableName, VarAttribute, VariableAttrs[(VariableName, VariableGuid)]))
- SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName], VariableName, VariableGuid, VariableOffset, DefaultValue)
+ SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName], VariableName, VariableGuid, VariableOffset, DefaultValue, VariableAttribute = VarAttribute)
+ pcdDecObject = self._DecPcds[PcdCName, TokenSpaceGuid]
if (PcdCName,TokenSpaceGuid) in Pcds.keys():
pcdObject = Pcds[PcdCName,TokenSpaceGuid]
pcdObject.SkuInfoList[SkuName] = SkuInfo
@@ -971,7 +1003,10 @@ class DscBuildData(PlatformBuildClassObject): '',
{SkuName : SkuInfo},
False,
- None
+ None,
+ pcdDecObject.validateranges,
+ pcdDecObject.validlists,
+ pcdDecObject.expressions
)
@@ -1143,6 +1178,7 @@ class DscBuildData(PlatformBuildClassObject): SkuName = property(_GetSkuName, _SetSkuName)
SkuIdentifier = property(_GetSkuIdentifier)
PcdInfoFlag = property(_GetPcdInfoFlag)
+ VarCheckFlag = property(_GetVarCheckFlag)
FlashDefinition = property(_GetFdfFile)
BuildNumber = property(_GetBuildNumber)
MakefileName = property(_GetMakefileName)
@@ -1462,6 +1498,7 @@ class DecBuildData(PackageBuildClassObject): DefaultValue, DatumType, TokenNumber = AnalyzePcdData(Setting)
+ validateranges, validlists, expressions = self._RawData.GetValidExpression(TokenSpaceGuid, PcdCName)
Pcds[PcdCName, TokenSpaceGuid, self._PCD_TYPE_STRING_[Type]] = PcdClassObject(
PcdCName,
TokenSpaceGuid,
@@ -1472,7 +1509,10 @@ class DecBuildData(PackageBuildClassObject): '',
{},
False,
- None
+ None,
+ list(validateranges),
+ list(validlists),
+ list(expressions)
)
return Pcds
|