summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/Workspace
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/Python/Workspace')
-rw-r--r--BaseTools/Source/Python/Workspace/DscBuildData.py16
-rw-r--r--BaseTools/Source/Python/Workspace/InfBuildData.py7
-rw-r--r--BaseTools/Source/Python/Workspace/MetaFileParser.py17
-rw-r--r--BaseTools/Source/Python/Workspace/WorkspaceCommon.py8
4 files changed, 34 insertions, 14 deletions
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index e42210079d..f9cd429f29 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -800,7 +800,7 @@ class DscBuildData(PlatformBuildClassObject):
ModuleData = self._Bdb[ModuleFile, self._Arch, self._Target, self._Toolchain]
PkgSet.update(ModuleData.Packages)
- self._DecPcds = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain,PkgSet)
+ self._DecPcds, self._GuidDict = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain,PkgSet)
if (PcdCName, TokenSpaceGuid) not in self._DecPcds:
@@ -821,6 +821,8 @@ class DscBuildData(PlatformBuildClassObject):
ValueList[Index] = ValueExpression(ValueList[Index], GlobalData.gPlatformPcds)(True)
except WrnExpression, Value:
ValueList[Index] = Value.result
+ except BadExpression, Value:
+ EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=self._LineIndex + 1)
except EvaluationException, Excpt:
if hasattr(Excpt, 'Pcd'):
if Excpt.Pcd in GlobalData.gPlatformOtherPcds:
@@ -834,11 +836,13 @@ class DscBuildData(PlatformBuildClassObject):
else:
EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),
File=self.MetaFile, Line=LineNo)
- if ValueList[Index] == 'True':
- ValueList[Index] = '1'
- elif ValueList[Index] == 'False':
- ValueList[Index] = '0'
if ValueList[Index]:
+ DatumType = self._DecPcds[PcdCName, TokenSpaceGuid].DatumType
+ try:
+ ValueList[Index] = ValueExpressionEx(ValueList[Index], DatumType, self._GuidDict)(True)
+ except BadExpression, Value:
+ EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=LineNo,
+ ExtraData="PCD [%s.%s] Value \"%s\" " % (TokenSpaceGuid, PcdCName, ValueList[Index]))
Valid, ErrStr = CheckPcdDatum(self._DecPcds[PcdCName, TokenSpaceGuid].DatumType, ValueList[Index])
if not Valid:
EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=self.MetaFile, Line=LineNo,
@@ -2058,7 +2062,7 @@ class DscBuildData(PlatformBuildClassObject):
continue
ModuleData = self._Bdb[ModuleFile, self._Arch, self._Target, self._Toolchain]
PkgSet.update(ModuleData.Packages)
- self._DecPcds = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain,PkgSet)
+ self._DecPcds, self._GuidDict = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain,PkgSet)
return self._DecPcds
_Macros = property(_GetMacros)
Arch = property(_GetArch, _SetArch)
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index fd94067c93..7ea9b56d5d 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -16,6 +16,7 @@ from Common.String import *
from Common.DataType import *
from Common.Misc import *
from types import *
+from MetaFileParser import *
from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
## Module build information from INF file
@@ -1144,6 +1145,12 @@ class InfBuildData(ModuleBuildClassObject):
Pcd.InfDefaultValue = Pcd.DefaultValue
if Pcd.DefaultValue in [None, '']:
Pcd.DefaultValue = PcdInPackage.DefaultValue
+ else:
+ try:
+ Pcd.DefaultValue = ValueExpressionEx(Pcd.DefaultValue, Pcd.DatumType, self.Guids)(True)
+ except BadExpression, Value:
+ EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %(TokenSpaceGuid, PcdRealName, Pcd.DefaultValue, Value),
+ File=self.MetaFile, Line=LineNo)
break
else:
EdkLogger.error(
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 3038447850..b2b0e282eb 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -27,7 +27,7 @@ import Common.GlobalData as GlobalData
from CommonDataClass.DataClass import *
from Common.DataType import *
from Common.String import *
-from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression
+from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, ParseFieldValue
from Common.Expression import *
from CommonDataClass.Exceptions import *
from Common.LongFilePathSupport import OpenLongFilePath as open
@@ -182,6 +182,7 @@ class MetaFileParser(object):
self._PostProcessed = False
# Different version of meta-file has different way to parse.
self._Version = 0
+ self._GuidDict = {} # for Parser PCD value {GUID(gTokeSpaceGuidName)}
## Store the parsed data in table
def _Store(self, *Args):
@@ -1871,6 +1872,8 @@ class DecParser(MetaFileParser):
File=self.MetaFile, Line=self._LineIndex + 1)
self._ValueList[0] = TokenList[0]
self._ValueList[1] = TokenList[1]
+ if self._ValueList[0] not in self._GuidDict:
+ self._GuidDict[self._ValueList[0]] = self._ValueList[1]
## PCD sections parser
#
@@ -1987,12 +1990,14 @@ class DecParser(MetaFileParser):
ValueList[0] = ValueExpression(PcdValue, self._AllPcdDict)(True)
except WrnExpression, Value:
ValueList[0] = Value.result
+ except BadExpression, Value:
+ EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=self._LineIndex + 1)
- if ValueList[0] == 'True':
- ValueList[0] = '1'
- if ValueList[0] == 'False':
- ValueList[0] = '0'
-
+ if ValueList[0]:
+ try:
+ ValueList[0] = ValueExpressionEx(ValueList[0], ValueList[1], self._GuidDict)(True)
+ except BadExpression, Value:
+ EdkLogger.error('Parser', FORMAT_INVALID, Value, ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
# check format of default value against the datum type
IsValid, Cause = CheckPcdDatum(ValueList[1], ValueList[0])
if not IsValid:
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
index c289b9d2b5..c760e57b8f 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
@@ -1,7 +1,7 @@
## @file
# Common routines used by workspace
#
-# Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2012 - 2017, 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
@@ -43,13 +43,17 @@ def GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain):
# @param Target: Current target
# @param Toolchain: Current toolchain
# @retval: A dictionary contains instances of PcdClassObject with key (PcdCName, TokenSpaceGuid)
+# @retval: A dictionary contains real GUIDs of TokenSpaceGuid
#
def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain,additionalPkgs):
PkgList = GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain)
PkgList = set(PkgList)
PkgList |= additionalPkgs
DecPcds = {}
+ GuidDict = {}
for Pkg in PkgList:
+ Guids = Pkg.Guids
+ GuidDict.update(Guids)
for Pcd in Pkg.Pcds:
PcdCName = Pcd[0]
PcdTokenName = Pcd[1]
@@ -60,7 +64,7 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain,additionalPk
break
if (PcdCName, PcdTokenName) not in DecPcds.keys():
DecPcds[PcdCName, PcdTokenName] = Pkg.Pcds[Pcd]
- return DecPcds
+ return DecPcds, GuidDict
## Get all dependent libraries for a module
#