]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/OptionRom.py
BaseTools: Use absolute import in GenFds
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / OptionRom.py
index 7886a7cfe73e6b639d30b5d50c13aec4acc61620..bb7071fa7fca36df97b8eaca0ac8d915620193f4 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process OptionROM generation\r
 #\r
-#  Copyright (c) 2007 - 2016, 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
 ##\r
 # Import Modules\r
 #\r
+from __future__ import absolute_import\r
 import Common.LongFilePathOs as os\r
 import subprocess\r
-import StringIO\r
 \r
-import OptRomInfStatement\r
-from GenFdsGlobalVariable import GenFdsGlobalVariable\r
-from GenFds import GenFds\r
+from . import OptRomInfStatement\r
+from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
 from CommonDataClass.FdfClass import OptionRomClassObject\r
 from Common.Misc import SaveFileOnChange\r
 from Common import EdkLogger\r
@@ -29,7 +28,7 @@ from Common.BuildToolError import *
 \r
 T_CHAR_LF = '\n'\r
 \r
-## \r
+##\r
 #\r
 #\r
 class OPTIONROM (OptionRomClassObject):\r
@@ -49,21 +48,21 @@ class OPTIONROM (OptionRomClassObject):
     #   @param  Buffer      The buffer generated OptROM data will be put\r
     #   @retval string      Generated OptROM file path\r
     #\r
-    def AddToBuffer (self, Buffer) :\r
-\r
-        GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..." %self.DriverName)\r
+    def AddToBuffer (self, Buffer, Flag=False) :\r
+        if not Flag:\r
+            GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..." %self.DriverName)\r
 \r
         EfiFileList = []\r
         BinFileList = []\r
 \r
         # Process Modules in FfsList\r
         for FfsFile in self.FfsList :\r
-            \r
+\r
             if isinstance(FfsFile, OptRomInfStatement.OptRomInfStatement):\r
-                FilePathNameList = FfsFile.GenFfs()\r
+                FilePathNameList = FfsFile.GenFfs(IsMakefile=Flag)\r
                 if len(FilePathNameList) == 0:\r
                     EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s not produce .efi files, so NO file could be put into option ROM." % (FfsFile.InfFileName))\r
-                if FfsFile.OverrideAttribs == None:\r
+                if FfsFile.OverrideAttribs is None:\r
                     EfiFileList.extend(FilePathNameList)\r
                 else:\r
                     FileName = os.path.basename(FilePathNameList[0])\r
@@ -71,69 +70,70 @@ class OPTIONROM (OptionRomClassObject):
                     if not os.path.exists(TmpOutputDir) :\r
                         os.makedirs(TmpOutputDir)\r
                     TmpOutputFile = os.path.join(TmpOutputDir, FileName+'.tmp')\r
-                    \r
-                    GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile, \r
-                                                           FilePathNameList, \r
-                                                           [], \r
-                                                           FfsFile.OverrideAttribs.NeedCompress, \r
-                                                           FfsFile.OverrideAttribs.PciClassCode, \r
-                                                           FfsFile.OverrideAttribs.PciRevision, \r
-                                                           FfsFile.OverrideAttribs.PciDeviceId, \r
-                                                           FfsFile.OverrideAttribs.PciVendorId)\r
+\r
+                    GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile,\r
+                                                           FilePathNameList,\r
+                                                           [],\r
+                                                           FfsFile.OverrideAttribs.NeedCompress,\r
+                                                           FfsFile.OverrideAttribs.PciClassCode,\r
+                                                           FfsFile.OverrideAttribs.PciRevision,\r
+                                                           FfsFile.OverrideAttribs.PciDeviceId,\r
+                                                           FfsFile.OverrideAttribs.PciVendorId,\r
+                                                           IsMakefile = Flag)\r
                     BinFileList.append(TmpOutputFile)\r
             else:\r
-                FilePathName = FfsFile.GenFfs()\r
-                if FfsFile.OverrideAttribs != None:\r
+                FilePathName = FfsFile.GenFfs(IsMakefile=Flag)\r
+                if FfsFile.OverrideAttribs is not None:\r
                     FileName = os.path.basename(FilePathName)\r
                     TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName, FfsFile.CurrentArch)\r
                     if not os.path.exists(TmpOutputDir) :\r
                         os.makedirs(TmpOutputDir)\r
                     TmpOutputFile = os.path.join(TmpOutputDir, FileName+'.tmp')\r
-                    \r
-                    GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile, \r
-                                                           [FilePathName], \r
-                                                           [], \r
-                                                           FfsFile.OverrideAttribs.NeedCompress, \r
-                                                           FfsFile.OverrideAttribs.PciClassCode, \r
-                                                           FfsFile.OverrideAttribs.PciRevision, \r
-                                                           FfsFile.OverrideAttribs.PciDeviceId, \r
-                                                           FfsFile.OverrideAttribs.PciVendorId)\r
+\r
+                    GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile,\r
+                                                           [FilePathName],\r
+                                                           [],\r
+                                                           FfsFile.OverrideAttribs.NeedCompress,\r
+                                                           FfsFile.OverrideAttribs.PciClassCode,\r
+                                                           FfsFile.OverrideAttribs.PciRevision,\r
+                                                           FfsFile.OverrideAttribs.PciDeviceId,\r
+                                                           FfsFile.OverrideAttribs.PciVendorId,\r
+                                                           IsMakefile=Flag)\r
                     BinFileList.append(TmpOutputFile)\r
                 else:\r
                     if FfsFile.FileType == 'EFI':\r
                         EfiFileList.append(FilePathName)\r
                     else:\r
                         BinFileList.append(FilePathName)\r
-                        \r
+\r
         #\r
         # Call EfiRom tool\r
         #\r
         OutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)\r
         OutputFile = OutputFile + '.rom'\r
-        \r
+\r
         GenFdsGlobalVariable.GenerateOptionRom(\r
                                 OutputFile,\r
                                 EfiFileList,\r
-                                BinFileList\r
-                                )\r
+                                BinFileList,\r
+                                IsMakefile=Flag)\r
 \r
-        GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Successfully" %self.DriverName)\r
+        if not Flag:\r
+            GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Successfully" %self.DriverName)\r
         GenFdsGlobalVariable.SharpCounter = 0\r
-        \r
+\r
         return OutputFile\r
 \r
 class OverrideAttribs:\r
-        \r
+\r
     ## The constructor\r
     #\r
     #   @param  self        The object pointer\r
     #\r
     def __init__(self):\r
-        \r
+\r
         self.PciVendorId = None\r
         self.PciClassCode = None\r
         self.PciDeviceId = None\r
         self.PciRevision = None\r
         self.NeedCompress = None\r
-        \r
-        
\ No newline at end of file