Fixed the ENV() usage
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Fri, 14 Sep 2007 05:49:02 +0000 (05:49 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Fri, 14 Sep 2007 05:49:02 +0000 (05:49 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@732 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Common/ToolDefClassObject.py

index e3af5b8..14a8da4 100755 (executable)
@@ -19,7 +19,8 @@ from Dictionary import *
 from BuildToolError import *\r
 from TargetTxtClassObject import *\r
 \r
-gMacroRefPattern = re.compile('(DEF\([^\(\)]+\)|ENV\([^\(\)]+\))')\r
+gMacroRefPattern = re.compile('(DEF\([^\(\)]+\))')\r
+gEnvRefPattern = re.compile('(ENV\([^\(\)]+\))')\r
 gMacroDefPattern = re.compile("DEFINE\s+([^\s]+)")\r
 \r
 class ToolDefClassObject(object):\r
@@ -68,6 +69,12 @@ class ToolDefClassObject(object):
 \r
             MacroDefinition = gMacroDefPattern.findall(Name)\r
             if MacroDefinition != []:\r
+                EnvReference = gEnvRefPattern.findall(Value)\r
+                for Ref in EnvReference:\r
+                    if Ref not in self.MacroDictionary:\r
+                        raise ParserError(msg="Environment [%s] has not been defined" % Ref)\r
+                    Value = Value.replace(Ref, self.MacroDictionary[Ref])\r
+\r
                 MacroName = MacroDefinition[0].strip()\r
                 self.MacroDictionary["DEF(%s)" % MacroName] = Value\r
                 EdkLogger.verbose("Line %d: Found macro: %s = %s" % ((Index + 1), MacroName, Value))\r