]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/GuidSection.py
BaseTools: fix imports
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / GuidSection.py
index ea737bb9a7ea5c251cc05d2f8197b50f622c783a..52b97300ecac8ae105a8f4f50532ce3bfd1a8537 100644 (file)
@@ -1,7 +1,8 @@
 ## @file\r
 # process GUIDed section generation\r
 #\r
-#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.<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
 ##\r
 # Import Modules\r
 #\r
-import Section\r
+from __future__ import absolute_import\r
+from . import Section\r
 import subprocess\r
-from Ffs import Ffs\r
+from .Ffs import SectionSuffix\r
 import Common.LongFilePathOs as os\r
-from GenFdsGlobalVariable import GenFdsGlobalVariable\r
+from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
+from .GenFdsGlobalVariable import FindExtendTool\r
 from CommonDataClass.FdfClass import GuidSectionClassObject\r
-from Common import ToolDefClassObject\r
 import sys\r
 from Common import EdkLogger\r
 from Common.BuildToolError import *\r
-from FvImageSection import FvImageSection\r
+from .FvImageSection import FvImageSection\r
 from Common.LongFilePathSupport import OpenLongFilePath as open\r
-from GenFds import FindExtendTool\r
+from Common.DataType import *\r
 \r
 ## generate GUIDed section\r
 #\r
@@ -60,7 +62,7 @@ class GuidSection(GuidSectionClassObject) :
         #\r
         self.KeyStringList = KeyStringList\r
         self.CurrentArchList = GenFdsGlobalVariable.ArchList\r
-        if FfsInf != None:\r
+        if FfsInf is not None:\r
             self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)\r
             self.NameGuid = FfsInf.__ExtendMacro__(self.NameGuid)\r
             self.SectionType = FfsInf.__ExtendMacro__(self.SectionType)\r
@@ -74,12 +76,12 @@ class GuidSection(GuidSectionClassObject) :
             FvAddrIsSet = True\r
         else:\r
             FvAddrIsSet = False\r
-        \r
+\r
         if self.ProcessRequired in ("TRUE", "1"):\r
             if self.FvAddr != []:\r
                 #no use FvAddr when the image is processed.\r
                 self.FvAddr = []\r
-            if self.FvParentAddr != None:\r
+            if self.FvParentAddr is not None:\r
                 #no use Parent Addr when the image is processed.\r
                 self.FvParentAddr = None\r
 \r
@@ -99,20 +101,20 @@ class GuidSection(GuidSectionClassObject) :
                 if Sect.IncludeFvSection:\r
                     self.IncludeFvSection = Sect.IncludeFvSection\r
 \r
-            if align != None:\r
-                if MaxAlign == None:\r
+            if align is not None:\r
+                if MaxAlign is None:\r
                     MaxAlign = align\r
                 if GenFdsGlobalVariable.GetAlignment (align) > GenFdsGlobalVariable.GetAlignment (MaxAlign):\r
                     MaxAlign = align\r
             if ReturnSectList != []:\r
-                if align == None:\r
+                if align is None:\r
                     align = "1"\r
                 for file in ReturnSectList:\r
                     SectFile += (file,)\r
                     SectAlign.append(align)\r
 \r
-        if MaxAlign != None:\r
-            if self.Alignment == None:\r
+        if MaxAlign is not None:\r
+            if self.Alignment is None:\r
                 self.Alignment = MaxAlign\r
             else:\r
                 if GenFdsGlobalVariable.GetAlignment (MaxAlign) > GenFdsGlobalVariable.GetAlignment (self.Alignment):\r
@@ -121,28 +123,28 @@ class GuidSection(GuidSectionClassObject) :
         OutputFile = OutputPath + \\r
                      os.sep + \\r
                      ModuleName + \\r
-                     'SEC' + \\r
+                     SUP_MODULE_SEC + \\r
                      SecNum + \\r
-                     Ffs.SectionSuffix['GUIDED']\r
+                     SectionSuffix['GUIDED']\r
         OutputFile = os.path.normpath(OutputFile)\r
 \r
         ExternalTool = None\r
         ExternalOption = None\r
-        if self.NameGuid != None:\r
+        if self.NameGuid is not None:\r
             ExternalTool, ExternalOption = FindExtendTool(self.KeyStringList, self.CurrentArchList, self.NameGuid)\r
 \r
         #\r
         # If not have GUID , call default\r
         # GENCRC32 section\r
         #\r
-        if self.NameGuid == None :\r
+        if self.NameGuid is None :\r
             GenFdsGlobalVariable.VerboseLogger("Use GenSection function Generate CRC32 Section")\r
             GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Section.Section.SectionType[self.SectionType], InputAlign=SectAlign, IsMakefile=IsMakefile)\r
             OutputFileList = []\r
             OutputFileList.append(OutputFile)\r
             return OutputFileList, self.Alignment\r
         #or GUID not in External Tool List\r
-        elif ExternalTool == None:\r
+        elif ExternalTool is None:\r
             EdkLogger.error("GenFds", GENFDS_ERROR, "No tool found with GUID %s" % self.NameGuid)\r
         else:\r
             DummyFile = OutputFile + ".dummy"\r
@@ -156,7 +158,7 @@ class GuidSection(GuidSectionClassObject) :
             TempFile = OutputPath + \\r
                        os.sep + \\r
                        ModuleName + \\r
-                       'SEC' + \\r
+                       SUP_MODULE_SEC + \\r
                        SecNum + \\r
                        '.tmp'\r
             TempFile = os.path.normpath(TempFile)\r
@@ -170,10 +172,10 @@ class GuidSection(GuidSectionClassObject) :
 \r
             FirstCall = False\r
             CmdOption = '-e'\r
-            if ExternalOption != None:\r
+            if ExternalOption is not None:\r
                 CmdOption = CmdOption + ' ' + ExternalOption\r
             if not GenFdsGlobalVariable.EnableGenfdsMultiThread:\r
-                if self.ProcessRequired not in ("TRUE", "1") and self.IncludeFvSection and not FvAddrIsSet and self.FvParentAddr != None:\r
+                if self.ProcessRequired not in ("TRUE", "1") and self.IncludeFvSection and not FvAddrIsSet and self.FvParentAddr is not None:\r
                     #FirstCall is only set for the encapsulated flash FV image without process required attribute.\r
                     FirstCall = True\r
                 #\r
@@ -213,7 +215,7 @@ class GuidSection(GuidSectionClassObject) :
                 if self.ExtraHeaderSize != -1:\r
                     HeaderLength = str(self.ExtraHeaderSize)\r
 \r
-                if self.ProcessRequired == "NONE" and HeaderLength == None:\r
+                if self.ProcessRequired == "NONE" and HeaderLength is None:\r
                     if TempFileSize > InputFileSize:\r
                         FileHandleIn.seek(0)\r
                         BufferIn = FileHandleIn.read()\r
@@ -222,7 +224,7 @@ class GuidSection(GuidSectionClassObject) :
                         if BufferIn == BufferOut[TempFileSize - InputFileSize:]:\r
                             HeaderLength = str(TempFileSize - InputFileSize)\r
                     #auto sec guided attribute with process required\r
-                    if HeaderLength == None:\r
+                    if HeaderLength is None:\r
                         Attribute.append('PROCESSING_REQUIRED')\r
 \r
                 FileHandleIn.close()\r
@@ -253,7 +255,7 @@ class GuidSection(GuidSectionClassObject) :
                     HeaderLength = str(self.ExtraHeaderSize)\r
                 if self.AuthStatusValid in ("TRUE", "1"):\r
                     Attribute.append('AUTH_STATUS_VALID')\r
-                if self.ProcessRequired == "NONE" and HeaderLength == None:\r
+                if self.ProcessRequired == "NONE" and HeaderLength is None:\r
                     GenFdsGlobalVariable.GenerateSection(OutputFile, [TempFile], Section.Section.SectionType['GUIDED'],\r
                                                          Guid=self.NameGuid, GuidAttr=Attribute,\r
                                                          GuidHdrLen=HeaderLength, DummyFile=DummyFile, IsMakefile=IsMakefile)\r
@@ -272,6 +274,8 @@ class GuidSection(GuidSectionClassObject) :
                 self.Alignment = None\r
                 self.IncludeFvSection = False\r
                 self.ProcessRequired = "TRUE"\r
+            if IsMakefile and self.Alignment is not None and self.Alignment.strip() == '0':\r
+                self.Alignment = '1'\r
             return OutputFileList, self.Alignment\r
 \r
 \r