Fixed an undefined variable issue
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Thu, 15 May 2008 03:16:57 +0000 (03:16 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Thu, 15 May 2008 03:16:57 +0000 (03:16 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1228 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Common/ToolDefClassObject.py

index 627264f..340a371 100755 (executable)
@@ -32,7 +32,7 @@ gMacroDefPattern = re.compile("DEFINE\s+([^\s]+)")
 ## ToolDefClassObject\r
 #\r
 # This class defined content used in file tools_def.txt\r
-# \r
+#\r
 # @param object:               Inherited from object class\r
 # @param Filename:             Input value for full path of tools_def.txt\r
 #\r
@@ -91,14 +91,22 @@ class ToolDefClassObject(object):
 \r
             MacroDefinition = gMacroDefPattern.findall(Name)\r
             if MacroDefinition != []:\r
-                Value = self.ExpandMacros(Value)\r
+                Done, Value = self.ExpandMacros(Value)\r
+                if not Done:\r
+                    EdkLogger.error("tools_def.txt parser", ATTRIBUTE_NOT_AVAILABLE,\r
+                                    "Macro or Environment has not been defined",\r
+                                ExtraData=Value[4:-1], File=FileName, Line=Index+1)\r
 \r
                 MacroName = MacroDefinition[0].strip()\r
                 self.MacroDictionary["DEF(%s)" % MacroName] = Value\r
                 EdkLogger.debug(EdkLogger.DEBUG_8, "Line %d: Found macro: %s = %s" % ((Index + 1), MacroName, Value))\r
                 continue\r
 \r
-            Value = self.ExpandMacros(Value)\r
+            Done, Value = self.ExpandMacros(Value)\r
+            if not Done:\r
+                EdkLogger.error("tools_def.txt parser", ATTRIBUTE_NOT_AVAILABLE,\r
+                                "Macro or Environment has not been defined",\r
+                                ExtraData=Value[4:-1], File=FileName, Line=Index+1)\r
 \r
             List = Name.split('_')\r
             if len(List) != 5:\r
@@ -155,20 +163,16 @@ class ToolDefClassObject(object):
         EnvReference = gEnvRefPattern.findall(Value)\r
         for Ref in EnvReference:\r
             if Ref not in self.MacroDictionary:\r
-                EdkLogger.error("tools_def.txt parser", RESOURCE_NOT_AVAILABLE,\r
-                                ExtraData="Environment [%s] has not been defined" % Ref,\r
-                                File=FileName, Line=Index+1)\r
+                return False, Ref\r
             Value = Value.replace(Ref, self.MacroDictionary[Ref])\r
 \r
         MacroReference = gMacroRefPattern.findall(Value)\r
         for Ref in MacroReference:\r
             if Ref not in self.MacroDictionary:\r
-                EdkLogger.error("tools_def.txt parser", RESOURCE_NOT_AVAILABLE,\r
-                                ExtraData="Macro [%s] has not been defined" % Ref,\r
-                                File=FileName, Line=Index+1)\r
+                return False, Ref\r
             Value = Value.replace(Ref, self.MacroDictionary[Ref])\r
 \r
-        return Value\r
+        return True, Value\r
 \r
 ## ToolDefDict\r
 #\r