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