]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/GenDepex.py
BaseTools: Remove equality operator with None
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / GenDepex.py
index b652051ac1af95f27db319d3e0fc43fd9891470c..9acea8f6bfed17d02246f5179f07c1419acd52c1 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to generate DEPEX file for module's dependency expression\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.    The full text of the license may be found at\r
 ## Import Modules\r
 #\r
 import sys\r
-import os\r
+import Common.LongFilePathOs as os\r
 import re\r
 import traceback\r
-\r
+from Common.LongFilePathSupport import OpenLongFilePath as open\r
 from StringIO import StringIO\r
 from struct import pack\r
 from Common.BuildToolError import *\r
 from Common.Misc import SaveFileOnChange\r
 from Common.Misc import GuidStructureStringToGuidString\r
 from Common import EdkLogger as EdkLogger\r
-\r
+from Common.BuildVersion import gBUILD_VERSION\r
 \r
 ## Regular expression for matching "DEPENDENCY_START ... DEPENDENCY_END"\r
 gStartClosePattern = re.compile(".*DEPENDENCY_START(.+)DEPENDENCY_END.*", re.S)\r
@@ -42,6 +42,8 @@ gType2Phase = {
     "UEFI_DRIVER"       :   "DXE",\r
     "UEFI_APPLICATION"  :   "DXE",\r
     "SMM_CORE"          :   "DXE",\r
+    "MM_STANDALONE"     :   "MM",\r
+    "MM_CORE_STANDALONE" :  "MM",\r
 }\r
 \r
 ## Convert dependency expression string into EFI internal representation\r
@@ -98,6 +100,19 @@ class DependencyExpression:
             "FALSE" :   0x07,\r
             "END"   :   0x08,\r
             "SOR"   :   0x09\r
+        },\r
+\r
+        "MM"   : {\r
+            "BEFORE":   0x00,\r
+            "AFTER" :   0x01,\r
+            "PUSH"  :   0x02,\r
+            "AND"   :   0x03,\r
+            "OR"    :   0x04,\r
+            "NOT"   :   0x05,\r
+            "TRUE"  :   0x06,\r
+            "FALSE" :   0x07,\r
+            "END"   :   0x08,\r
+            "SOR"   :   0x09\r
         }\r
     }\r
 \r
@@ -286,10 +301,10 @@ class DependencyExpression:
         # don't generate depex if only TRUE operand left\r
         if self.ModuleType == 'PEIM' and len(NewOperand) == 1 and NewOperand[0] == 'TRUE':\r
             self.PostfixNotation = []\r
-            return            \r
+            return\r
 \r
         # don't generate depex if all operands are architecture protocols\r
-        if self.ModuleType in ['UEFI_DRIVER', 'DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'DXE_SMM_DRIVER'] and \\r
+        if self.ModuleType in ['UEFI_DRIVER', 'DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'DXE_SMM_DRIVER', 'MM_STANDALONE'] and \\r
            Op == 'AND' and \\r
            self.ArchProtocols == set([GuidStructureStringToGuidString(Guid) for Guid in AllOperand]):\r
             self.PostfixNotation = []\r
@@ -345,7 +360,7 @@ class DependencyExpression:
 \r
         FilePath = ""\r
         FileChangeFlag = True\r
-        if File == None:\r
+        if File is None:\r
             sys.stdout.write(Buffer.getvalue())\r
             FilePath = "STDOUT"\r
         else:\r
@@ -354,7 +369,7 @@ class DependencyExpression:
         Buffer.close()\r
         return FileChangeFlag\r
 \r
-versionNumber = "0.04"\r
+versionNumber = ("0.04" + " " + gBUILD_VERSION)\r
 __version__ = "%prog Version " + versionNumber\r
 __copyright__ = "Copyright (c) 2007-2010, Intel Corporation  All rights reserved."\r
 __usage__ = "%prog [options] [dependency_expression_file]"\r
@@ -399,13 +414,13 @@ def Main():
         EdkLogger.SetLevel(EdkLogger.QUIET)\r
     elif Option.verbose:\r
         EdkLogger.SetLevel(EdkLogger.VERBOSE)\r
-    elif Option.debug != None:\r
+    elif Option.debug is not None:\r
         EdkLogger.SetLevel(Option.debug + 1)\r
     else:\r
         EdkLogger.SetLevel(EdkLogger.INFO)\r
 \r
     try:\r
-        if Option.ModuleType == None or Option.ModuleType not in gType2Phase:\r
+        if Option.ModuleType is None or Option.ModuleType not in gType2Phase:\r
             EdkLogger.error("GenDepex", OPTION_MISSING, "Module type is not specified or supported")\r
 \r
         DxsFile = ''\r
@@ -422,13 +437,20 @@ def Main():
             EdkLogger.error("GenDepex", OPTION_MISSING, "No expression string or file given")\r
 \r
         Dpx = DependencyExpression(DxsString, Option.ModuleType, Option.Optimize)\r
-        if Option.OutputFile != None:\r
-            Dpx.Generate(Option.OutputFile)\r
+        if Option.OutputFile is not None:\r
+            FileChangeFlag = Dpx.Generate(Option.OutputFile)\r
+            if not FileChangeFlag and DxsFile:\r
+                #\r
+                # Touch the output file if its time stamp is older than the original\r
+                # DXS file to avoid re-invoke this tool for the dependency check in build rule.\r
+                #\r
+                if os.stat(DxsFile)[8] > os.stat(Option.OutputFile)[8]:\r
+                    os.utime(Option.OutputFile, None)\r
         else:\r
             Dpx.Generate()\r
     except BaseException, X:\r
         EdkLogger.quiet("")\r
-        if Option != None and Option.debug != None:\r
+        if Option is not None and Option.debug is not None:\r
             EdkLogger.quiet(traceback.format_exc())\r
         else:\r
             EdkLogger.quiet(str(X))\r