Fixed GenDepex issue
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Thu, 28 Feb 2008 09:41:22 +0000 (09:41 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Thu, 28 Feb 2008 09:41:22 +0000 (09:41 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1030 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/AutoGen/AutoGen.py
Source/Python/AutoGen/GenDepex.py

index c381e1c..352e3bb 100755 (executable)
@@ -856,9 +856,8 @@ class ModuleAutoGen(object):
             if Token.endswith(".inf"):  # module file name\r
                 ModuleFile = os.path.normpath(Token)\r
                 Token = gModuleDatabase[ModuleFile].Guid\r
-            elif Token.upper() in GenDepex.DependencyExpression.SupportedOpcode: # Opcode name\r
-                Token = Token.upper()\r
-            elif Token not in ['(', ')']:   # GUID C Name\r
+            elif Token not in ['(', ')']+GenDepex.DependencyExpression.SupportedOpcode+\\r
+                 GenDepex.DependencyExpression.SupportedOperand:   # GUID C Name\r
                 GuidCName = Token\r
                 for P in Info.DerivedPackageList:\r
                     if GuidCName in P.Protocols:\r
index 93c65fa..881be4a 100644 (file)
@@ -78,8 +78,10 @@ class DependencyExpression:
         }\r
     }\r
 \r
-    # all supported op code\r
-    SupportedOpcode = ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "TRUE", "FALSE", "END", "SOR"]\r
+    # all supported op codes and operands\r
+    SupportedOpcode = ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "END", "SOR"]\r
+    SupportedOperand = ["TRUE", "FALSE"]\r
+\r
     # op code that should not be the last one\r
     NonEndingOpcode = ["AND", "OR", "NOT"]\r
     # op code must not present at the same time\r
@@ -141,14 +143,12 @@ class DependencyExpression:
                         break\r
                     self.PostfixNotation.append(Stack.pop())\r
             elif Token in self.OpcodePriority:\r
-                if Token == "NOT":\r
-                    if LastToken not in self.SupportedOpcode:\r
-                        EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: missing operator before NOT",\r
-                                        ExtraData=str(self))\r
-                else:\r
-                    if LastToken in self.SupportedOpcode:\r
-                        EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: missing operand before " + Token,\r
-                                        ExtraData=str(self))\r
+                if Token == "NOT" and LastToken not in self.SupportedOpcode:\r
+                    EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: missing operator before NOT",\r
+                                    ExtraData=str(self))\r
+                elif Token in self.SupportedOpcode and LastToken in self.SupportedOpcode:\r
+                    EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: missing operand before " + Token,\r
+                                    ExtraData=str(self))\r
 \r
                 while len(Stack) > 0:\r
                     if Stack[-1] == "(" or self.OpcodePriority[Token] >= self.OpcodePriority[Stack[-1]]:\r
@@ -163,7 +163,8 @@ class DependencyExpression:
                         EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: missing operator",\r
                                         ExtraData=str(self))\r
                     if len(self.OpcodeList) == 0 or self.OpcodeList[-1] not in self.ExclusiveOpcode:\r
-                        self.PostfixNotation.append("PUSH")\r
+                        if Token not in self.SupportedOperand:\r
+                            self.PostfixNotation.append("PUSH")\r
                 # check if OP is valid in this phase\r
                 elif Token in self.Opcode[self.Phase]:\r
                     if Token == "END":\r
@@ -222,6 +223,18 @@ class DependencyExpression:
         for Token in self.PostfixNotation:\r
             if Token in self.SupportedOpcode or Token in NewOperand:\r
                 continue\r
+            if Token == 'TRUE':\r
+                if Op == 'AND':\r
+                    continue\r
+                else:\r
+                    NewOperand.append(Token)\r
+                    break\r
+            elif Token == 'FALSE':\r
+                if Op == 'OR':\r
+                    continue\r
+                else:\r
+                    NewOperand.append(Token)\r
+                    break\r
             NewOperand.append(Token)\r
 \r
         self.TokenList = []\r