summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/Common
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/Python/Common')
-rw-r--r--BaseTools/Source/Python/Common/BuildVersion.py2
-rw-r--r--BaseTools/Source/Python/Common/DataType.py9
-rw-r--r--BaseTools/Source/Python/Common/Expression.py22
-rw-r--r--BaseTools/Source/Python/Common/GlobalData.py4
-rw-r--r--BaseTools/Source/Python/Common/String.py4
5 files changed, 32 insertions, 9 deletions
diff --git a/BaseTools/Source/Python/Common/BuildVersion.py b/BaseTools/Source/Python/Common/BuildVersion.py
index b6b02cf8ae..c5dae6daa4 100644
--- a/BaseTools/Source/Python/Common/BuildVersion.py
+++ b/BaseTools/Source/Python/Common/BuildVersion.py
@@ -13,4 +13,4 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
-gBUILD_VERSION = "Build 2474"
+gBUILD_VERSION = "Build 2518"
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index fc0a7ad026..e5e7eaeede 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -29,6 +29,7 @@ TAB_OPTION_START = '<'
TAB_OPTION_END = '>'
TAB_SLASH = '\\'
TAB_BACK_SLASH = '/'
+TAB_LINE_BREAK = '\n'
TAB_EDK_SOURCE = '$(EDK_SOURCE)'
TAB_EFI_SOURCE = '$(EFI_SOURCE)'
@@ -421,3 +422,11 @@ TAB_DEPENDENCY_EXPRESSION_FILE = "DEPENDENCY-EXPRESSION-FILE"
TAB_UNKNOWN_FILE = "UNKNOWN-TYPE-FILE"
TAB_DEFAULT_BINARY_FILE = "_BINARY_FILE_"
+# used by BRG
+TAB_BRG_PCD = 'PCD'
+TAB_BRG_LIBRARY = 'Library'
+
+#
+# Build Rule File Version Definition
+#
+TAB_BUILD_RULE_VERSION = "build_rule_version"
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 8b112d50b3..a4853b78a4 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -36,6 +36,7 @@ ERR_STRING_CMP = 'Unicode string and general string cannot be compared:
ERR_ARRAY_TOKEN = 'Bad C array or C format GUID token: [%s].'
ERR_ARRAY_ELE = 'This must be HEX value for NList or Array: [%s].'
ERR_EMPTY_EXPR = 'Empty expression is not allowed.'
+ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'
## SplitString
# Split string to list according double quote
@@ -88,22 +89,29 @@ def ReplaceExprMacro(String, Macros, ExceptionList = None):
# If an undefined macro name appears in the constant-expression of
# !if or !elif, it is replaced by the integer constant 0.
RetStr += '0'
- elif not InQuote and ExceptionList and Macro in ExceptionList:
+ elif not InQuote:
+ Tklst = RetStr.split()
+ if Tklst and Tklst[-1] in ['IN', 'in'] and ExceptionList and Macro not in ExceptionList:
+ raise BadExpression(ERR_IN_OPERAND)
# Make sure the macro in exception list is encapsulated by double quote
# For example: DEFINE ARCH = IA32 X64
# $(ARCH) is replaced with "IA32 X64"
- RetStr += '"' + Macros[Macro] + '"'
- else:
- if Macros[Macro].strip() != "":
+ if ExceptionList and Macro in ExceptionList:
+ RetStr += '"' + Macros[Macro] + '"'
+ elif Macros[Macro].strip():
RetStr += Macros[Macro]
else:
RetStr += '""'
+ else:
+ RetStr += Macros[Macro]
RetStr += String[MacroEndPos+1:]
String = RetStr
MacroStartPos = String.find('$(')
StrList[i] = RetStr
return ''.join(StrList)
+SupportedInMacroList = ['TARGET', 'TOOL_CHAIN_TAG', 'ARCH', 'FAMILY']
+
class ValueExpression(object):
# Logical operator mapping
LogicalOperators = {
@@ -213,7 +221,7 @@ class ValueExpression(object):
self._Expr = ReplaceExprMacro(Expression.strip(),
SymbolTable,
- ['TARGET', 'TOOL_CHAIN_TAG', 'ARCH'])
+ SupportedInMacroList)
if not self._Expr.strip():
raise BadExpression(ERR_EMPTY_EXPR)
@@ -457,7 +465,9 @@ class ValueExpression(object):
# PCD token
if self.PcdPattern.match(self._Token):
if self._Token not in self._Symb:
- raise BadExpression(ERR_PCD_RESOLVE % self._Token)
+ Ex = BadExpression(ERR_PCD_RESOLVE % self._Token)
+ Ex.Pcd = self._Token
+ raise Ex
self._Token = ValueExpression(self._Symb[self._Token], self._Symb)(True)
if type(self._Token) != type(''):
self._LiteralToken = hex(self._Token)
diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py
index 492aa39962..d566a57844 100644
--- a/BaseTools/Source/Python/Common/GlobalData.py
+++ b/BaseTools/Source/Python/Common/GlobalData.py
@@ -26,6 +26,10 @@ gAllFiles = None
gGlobalDefines = {}
gPlatformDefines = {}
+# PCD name and value pair for fixed at build and feature flag
+gPlatformPcds = {}
+# PCDs with type that are not fixed at build and feature flag
+gPlatformOtherPcds = {}
gActivePlatform = None
gCommandLineDefines = {}
gEdkGlobal = {}
diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py
index 0f2a61b1b9..068a63d1c1 100644
--- a/BaseTools/Source/Python/Common/String.py
+++ b/BaseTools/Source/Python/Common/String.py
@@ -319,7 +319,7 @@ def NormPath(Path, Defines={}):
#
# @retval Path Formatted path
#
-def CleanString(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyleComment=False):
+def CleanString(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyleComment=False, BuildOption=False):
#
# remove whitespace
#
@@ -343,7 +343,7 @@ def CleanString(Line, CommentCharacter=DataType.TAB_COMMENT_SPLIT, AllowCppStyle
Line = Line[0: Index]
break
- if CommentInString:
+ if CommentInString and BuildOption:
Line = Line.replace('"', '')
ChIndex = Line.find('#')
while ChIndex >= 0: