]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/DataSection.py
BaseTools: Use absolute import in GenFds
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / DataSection.py
index 78c0af4db1ab2c4e9e8a6782f5831ad4ef1e1a78..a6387b07c582b15fb06496276dca863b1b8d44ea 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process data section generation\r
 #\r
 ## @file\r
 # process data 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
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\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
 ##\r
 # Import Modules\r
 #\r
-import Section\r
-from GenFdsGlobalVariable import GenFdsGlobalVariable\r
+from __future__ import absolute_import\r
+from . import Section\r
+from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
 import subprocess\r
 import subprocess\r
-from Ffs import Ffs\r
+from .Ffs import Ffs\r
 import Common.LongFilePathOs as os\r
 from CommonDataClass.FdfClass import DataSectionClassObject\r
 from Common.Misc import PeImageClass\r
 from Common.LongFilePathSupport import CopyLongFilePath\r
 import Common.LongFilePathOs as os\r
 from CommonDataClass.FdfClass import DataSectionClassObject\r
 from Common.Misc import PeImageClass\r
 from Common.LongFilePathSupport import CopyLongFilePath\r
+from Common.DataType import *\r
 \r
 ## generate data section\r
 #\r
 \r
 ## generate data section\r
 #\r
@@ -48,11 +50,11 @@ class DataSection (DataSectionClassObject):
     #   @param  Dict        dictionary contains macro and its value\r
     #   @retval tuple       (Generated file name list, section alignment)\r
     #\r
     #   @param  Dict        dictionary contains macro and its value\r
     #   @retval tuple       (Generated file name list, section alignment)\r
     #\r
-    def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}):\r
+    def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}, IsMakefile = False):\r
         #\r
         # Prepare the parameter of GenSection\r
         #\r
         #\r
         # Prepare the parameter of GenSection\r
         #\r
-        if FfsFile != None:\r
+        if FfsFile is not None:\r
             self.SectFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.SectFileName)\r
             self.SectFileName = GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict, FfsFile.CurrentArch)\r
         else:\r
             self.SectFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.SectFileName)\r
             self.SectFileName = GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict, FfsFile.CurrentArch)\r
         else:\r
@@ -69,13 +71,19 @@ class DataSection (DataSectionClassObject):
         Filename = GenFdsGlobalVariable.MacroExtend(self.SectFileName)\r
         if Filename[(len(Filename)-4):] == '.efi':\r
             MapFile = Filename.replace('.efi', '.map')\r
         Filename = GenFdsGlobalVariable.MacroExtend(self.SectFileName)\r
         if Filename[(len(Filename)-4):] == '.efi':\r
             MapFile = Filename.replace('.efi', '.map')\r
-            if os.path.exists(MapFile):\r
-                CopyMapFile = os.path.join(OutputPath, ModuleName + '.map')\r
-                if not os.path.exists(CopyMapFile) or (os.path.getmtime(MapFile) > os.path.getmtime(CopyMapFile)):\r
-                    CopyLongFilePath(MapFile, CopyMapFile)\r
+            CopyMapFile = os.path.join(OutputPath, ModuleName + '.map')\r
+            if IsMakefile:\r
+                if GenFdsGlobalVariable.CopyList == []:\r
+                    GenFdsGlobalVariable.CopyList = [(MapFile, CopyMapFile)]\r
+                else:\r
+                    GenFdsGlobalVariable.CopyList.append((MapFile, CopyMapFile))\r
+            else:\r
+                if os.path.exists(MapFile):\r
+                    if not os.path.exists(CopyMapFile) or (os.path.getmtime(MapFile) > os.path.getmtime(CopyMapFile)):\r
+                        CopyLongFilePath(MapFile, CopyMapFile)\r
 \r
         #Get PE Section alignment when align is set to AUTO\r
 \r
         #Get PE Section alignment when align is set to AUTO\r
-        if self.Alignment == 'Auto' and self.SecType in ('TE', 'PE32'):\r
+        if self.Alignment == 'Auto' and self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):\r
             ImageObj = PeImageClass (Filename)\r
             if ImageObj.SectionAlignment < 0x400:\r
                 self.Alignment = str (ImageObj.SectionAlignment)\r
             ImageObj = PeImageClass (Filename)\r
             if ImageObj.SectionAlignment < 0x400:\r
                 self.Alignment = str (ImageObj.SectionAlignment)\r
@@ -85,8 +93,8 @@ class DataSection (DataSectionClassObject):
                 self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'\r
 \r
         NoStrip = True\r
                 self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M'\r
 \r
         NoStrip = True\r
-        if self.SecType in ('TE', 'PE32'):\r
-            if self.KeepReloc != None:\r
+        if self.SecType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):\r
+            if self.KeepReloc is not None:\r
                 NoStrip = self.KeepReloc\r
 \r
         if not NoStrip:\r
                 NoStrip = self.KeepReloc\r
 \r
         if not NoStrip:\r
@@ -96,24 +104,25 @@ class DataSection (DataSectionClassObject):
                 CopyLongFilePath(self.SectFileName, FileBeforeStrip)\r
             StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')\r
             GenFdsGlobalVariable.GenerateFirmwareImage(\r
                 CopyLongFilePath(self.SectFileName, FileBeforeStrip)\r
             StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')\r
             GenFdsGlobalVariable.GenerateFirmwareImage(\r
-                                    StrippedFile,\r
-                                    [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)],\r
-                                    Strip=True\r
-                                    )\r
+                    StrippedFile,\r
+                    [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)],\r
+                    Strip=True,\r
+                    IsMakefile = IsMakefile\r
+                )\r
             self.SectFileName = StrippedFile\r
 \r
             self.SectFileName = StrippedFile\r
 \r
-        if self.SecType == 'TE':\r
+        if self.SecType == BINARY_FILE_TYPE_TE:\r
             TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')\r
             GenFdsGlobalVariable.GenerateFirmwareImage(\r
             TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')\r
             GenFdsGlobalVariable.GenerateFirmwareImage(\r
-                                    TeFile,\r
-                                    [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)],\r
-                                    Type='te'\r
-                                    )\r
+                    TeFile,\r
+                    [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)],\r
+                    Type='te',\r
+                    IsMakefile = IsMakefile\r
+                )\r
             self.SectFileName = TeFile\r
 \r
             self.SectFileName = TeFile\r
 \r
-        OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get(self.SecType))\r
+        OutputFile = os.path.join (OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get(self.SecType))\r
         OutputFile = os.path.normpath(OutputFile)\r
         OutputFile = os.path.normpath(OutputFile)\r
-\r
-        GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileName], Section.Section.SectionType.get(self.SecType))\r
+        GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileName], Section.Section.SectionType.get(self.SecType), IsMakefile = IsMakefile)\r
         FileList = [OutputFile]\r
         return FileList, self.Alignment\r
         FileList = [OutputFile]\r
         return FileList, self.Alignment\r