]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
BaseTools: use set instead of list for a variable to be used with in
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / GenFdsGlobalVariable.py
index 371d5a8217f70ffcf3cbe8175d79ac2cc8b7a1a4..2f9d58f6bf37f58ffb0502eb1896c0e702c2057c 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Global variables for GenFds\r
 #\r
-#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -229,7 +229,7 @@ class GenFdsGlobalVariable:
                 Source = SourceList[Index]\r
                 Index = Index + 1\r
     \r
-                if File.IsBinary and File == Source and Inf.Binaries != None and File in Inf.Binaries:\r
+                if File.IsBinary and File == Source and Inf.Binaries is not None and File in Inf.Binaries:\r
                     # Skip all files that are not binary libraries\r
                     if not Inf.LibraryClass:\r
                         continue            \r
@@ -420,7 +420,7 @@ class GenFdsGlobalVariable:
         if not os.path.exists(Output):\r
             return True\r
         # always update "Output" if no "Input" given\r
-        if Input == None or len(Input) == 0:\r
+        if Input is None or len(Input) == 0:\r
             return True\r
 \r
         # if fdf file is changed after the 'Output" is generated, update the 'Output'\r
@@ -445,9 +445,9 @@ class GenFdsGlobalVariable:
             Cmd += ["-s", Type]\r
         if CompressionType not in [None, '']:\r
             Cmd += ["-c", CompressionType]\r
-        if Guid != None:\r
+        if Guid is not None:\r
             Cmd += ["-g", Guid]\r
-        if DummyFile != None:\r
+        if DummyFile is not None:\r
             Cmd += ["--dummy", DummyFile]\r
         if GuidHdrLen not in [None, '']:\r
             Cmd += ["-l", GuidHdrLen]\r
@@ -455,7 +455,7 @@ class GenFdsGlobalVariable:
             #Add each guided attribute\r
             for Attr in GuidAttr:\r
                 Cmd += ["-r", Attr]\r
-        if InputAlign != None:\r
+        if InputAlign is not None:\r
             #Section Align is only for dummy section without section type\r
             for SecAlign in InputAlign:\r
                 Cmd += ["--sectionalign", SecAlign]\r
@@ -464,9 +464,11 @@ class GenFdsGlobalVariable:
         if Ui not in [None, '']:\r
             #Cmd += ["-n", '"' + Ui + '"']\r
             if IsMakefile:\r
-                Cmd += ["-n", "$(MODULE_NAME)"]\r
+                if Ui == "$(MODULE_NAME)":\r
+                    Cmd += ['-n', Ui]\r
+                else:\r
+                    Cmd += ["-n", '"' + Ui + '"']\r
                 Cmd += ["-o", Output]\r
-                #SaveFileOnChange(CommandFile, ' '.join(Cmd), False)\r
                 if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
                     GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())\r
             else:\r
@@ -500,7 +502,7 @@ class GenFdsGlobalVariable:
             if IsMakefile:\r
                 if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
                     GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())\r
-            elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input)):\r
+            elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):\r
                 GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))\r
                 GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")\r
                 if (os.path.getsize(Output) >= GenFdsGlobalVariable.LARGE_FILE_SIZE and\r
@@ -509,7 +511,7 @@ class GenFdsGlobalVariable:
 \r
     @staticmethod\r
     def GetAlignment (AlignString):\r
-        if AlignString == None:\r
+        if AlignString is None:\r
             return 0\r
         if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K", "512K"):\r
             return int (AlignString.rstrip('K')) * 1024\r
@@ -552,7 +554,7 @@ class GenFdsGlobalVariable:
             GenFdsGlobalVariable.SecCmdList = []\r
             GenFdsGlobalVariable.CopyList = []\r
         else:\r
-            if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input)):\r
+            if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):\r
                 return\r
             GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FFS")\r
 \r
@@ -669,13 +671,13 @@ class GenFdsGlobalVariable:
             return\r
         GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, InputList))\r
                         \r
-        if ClassCode != None:\r
+        if ClassCode is not None:\r
             Cmd += ["-l", ClassCode]\r
-        if Revision != None:\r
+        if Revision is not None:\r
             Cmd += ["-r", Revision]\r
-        if DeviceId != None:\r
+        if DeviceId is not None:\r
             Cmd += ["-i", DeviceId]\r
-        if VendorId != None:\r
+        if VendorId is not None:\r
             Cmd += ["-f", VendorId]\r
 \r
         Cmd += ["-o", Output]\r
@@ -726,7 +728,7 @@ class GenFdsGlobalVariable:
             EdkLogger.error("GenFds", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))\r
         (out, error) = PopenObject.communicate()\r
 \r
-        while PopenObject.returncode == None :\r
+        while PopenObject.returncode is None :\r
             PopenObject.wait()\r
         if returnValue != [] and returnValue[0] != 0:\r
             #get command return value\r
@@ -758,7 +760,7 @@ class GenFdsGlobalVariable:
     #   @param  MacroDict     Dictionary that contains macro value pair\r
     #\r
     def MacroExtend (Str, MacroDict={}, Arch='COMMON'):\r
-        if Str == None :\r
+        if Str is None :\r
             return None\r
 \r
         Dict = {'$(WORKSPACE)'   : GenFdsGlobalVariable.WorkSpaceDir,\r
@@ -774,7 +776,7 @@ class GenFdsGlobalVariable:
 \r
         Dict['$(OUTPUT_DIRECTORY)'] = OutputDir\r
 \r
-        if MacroDict != None  and len (MacroDict) != 0:\r
+        if MacroDict is not None  and len (MacroDict) != 0:\r
             Dict.update(MacroDict)\r
 \r
         for key in Dict.keys():\r
@@ -794,7 +796,7 @@ class GenFdsGlobalVariable:
     #   @param  PcdPattern           pattern that labels a PCD.\r
     #\r
     def GetPcdValue (PcdPattern):\r
-        if PcdPattern == None :\r
+        if PcdPattern is None :\r
             return None\r
         PcdPair = PcdPattern.lstrip('PCD(').rstrip(')').strip().split('.')\r
         TokenSpace = PcdPair[0]\r