X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FEfiSection.py;h=9223268749a11d917ead3c45350aa60da06742ff;hb=543f5ac30facfbb40eafb2b4908649a427784080;hp=7b3b71719147c9e7e61315a327bdd09638be230d;hpb=37de70b764200718cc39a21abc491c335e3da7b3;p=mirror_edk2.git
diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py
index 7b3b717191..9223268749 100644
--- a/BaseTools/Source/Python/GenFds/EfiSection.py
+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
@@ -1,7 +1,7 @@
## @file
# process rule 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
@@ -27,6 +27,7 @@ from Common.BuildToolError import *
from Common.Misc import PeImageClass
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.LongFilePathSupport import CopyLongFilePath
+from Common.DataType import *
## generate rule section
#
@@ -54,32 +55,33 @@ class EfiSection (EfiSectionClassObject):
# @retval tuple (Generated file name list, section alignment)
#
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False) :
-
- if self.FileName != None and self.FileName.startswith('PCD('):
+
+ if self.FileName is not None and self.FileName.startswith('PCD('):
self.FileName = GenFdsGlobalVariable.GetPcdValue(self.FileName)
"""Prepare the parameter of GenSection"""
- if FfsInf != None :
+ if FfsInf is not None :
InfFileName = FfsInf.InfFileName
SectionType = FfsInf.__ExtendMacro__(self.SectionType)
Filename = FfsInf.__ExtendMacro__(self.FileName)
BuildNum = FfsInf.__ExtendMacro__(self.BuildNum)
StringData = FfsInf.__ExtendMacro__(self.StringData)
+ ModuleNameStr = FfsInf.__ExtendMacro__('$(MODULE_NAME)')
NoStrip = True
- if FfsInf.ModuleType in ('SEC', 'PEI_CORE', 'PEIM') and SectionType in ('TE', 'PE32'):
- if FfsInf.KeepReloc != None:
+ if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM) and SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_PE32):
+ if FfsInf.KeepReloc is not None:
NoStrip = FfsInf.KeepReloc
- elif FfsInf.KeepRelocFromRule != None:
+ elif FfsInf.KeepRelocFromRule is not None:
NoStrip = FfsInf.KeepRelocFromRule
- elif self.KeepReloc != None:
+ elif self.KeepReloc is not None:
NoStrip = self.KeepReloc
- elif FfsInf.ShadowFromInfFile != None:
+ elif FfsInf.ShadowFromInfFile is not None:
NoStrip = FfsInf.ShadowFromInfFile
else:
EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s apply rule for None!" %ModuleName)
"""If the file name was pointed out, add it in FileList"""
FileList = []
- if Filename != None:
+ if Filename is not None:
Filename = GenFdsGlobalVariable.MacroExtend(Filename, Dict)
# check if the path is absolute or relative
if os.path.isabs(Filename):
@@ -91,10 +93,12 @@ class EfiSection (EfiSectionClassObject):
FileList.append(Filename)
elif os.path.exists(Filename):
FileList.append(Filename)
- elif '.depex' in FfsInf.FinalTargetSuffixMap or FfsInf.Depex:
- FileList.append(Filename)
+ elif IsMakefile:
+ SuffixMap = FfsInf.GetFinalTargetSuffixMap()
+ if '.depex' in SuffixMap:
+ FileList.append(Filename)
else:
- FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict)
+ FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict, IsMakefile=IsMakefile)
if IsSect :
return FileList, self.Alignment
@@ -106,20 +110,20 @@ class EfiSection (EfiSectionClassObject):
if SectionType == 'VERSION':
InfOverrideVerString = False
- if FfsInf.Version != None:
+ if FfsInf.Version is not None:
#StringData = FfsInf.Version
BuildNum = FfsInf.Version
InfOverrideVerString = True
if InfOverrideVerString:
#VerTuple = ('-n', '"' + StringData + '"')
- if BuildNum != None and BuildNum != '':
+ if BuildNum is not None and BuildNum != '':
BuildNumTuple = ('-j', BuildNum)
else:
BuildNumTuple = tuple()
Num = SecNum
- OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
+ OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))
GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',
#Ui=StringData,
Ver=BuildNum,
@@ -129,13 +133,13 @@ class EfiSection (EfiSectionClassObject):
elif FileList != []:
for File in FileList:
Index = Index + 1
- Num = '%s.%d' %(SecNum , Index)
- OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
+ Num = '%s.%d' %(SecNum, Index)
+ OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType))
f = open(File, 'r')
VerString = f.read()
f.close()
BuildNum = VerString
- if BuildNum != None and BuildNum != '':
+ if BuildNum is not None and BuildNum != '':
BuildNumTuple = ('-j', BuildNum)
GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',
#Ui=VerString,
@@ -145,13 +149,13 @@ class EfiSection (EfiSectionClassObject):
else:
BuildNum = StringData
- if BuildNum != None and BuildNum != '':
+ if BuildNum is not None and BuildNum != '':
BuildNumTuple = ('-j', BuildNum)
else:
BuildNumTuple = tuple()
BuildNumString = ' ' + ' '.join(BuildNumTuple)
- #if VerString == '' and
+ #if VerString == '' and
if BuildNumString == '':
if self.Optional == True :
GenFdsGlobalVariable.VerboseLogger( "Optional Section don't exist!")
@@ -159,7 +163,7 @@ class EfiSection (EfiSectionClassObject):
else:
EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s miss Version Section value" %InfFileName)
Num = SecNum
- OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
+ OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))
GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',
#Ui=VerString,
Ver=BuildNum,
@@ -167,18 +171,20 @@ class EfiSection (EfiSectionClassObject):
OutputFileList.append(OutputFile)
#
- # If Section Type is 'UI'
+ # If Section Type is BINARY_FILE_TYPE_UI
#
- elif SectionType == 'UI':
+ elif SectionType == BINARY_FILE_TYPE_UI:
InfOverrideUiString = False
- if FfsInf.Ui != None:
+ if FfsInf.Ui is not None:
StringData = FfsInf.Ui
InfOverrideUiString = True
if InfOverrideUiString:
Num = SecNum
- OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
+ if IsMakefile and StringData == ModuleNameStr:
+ StringData = "$(MODULE_NAME)"
+ OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))
GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
Ui=StringData, IsMakefile=IsMakefile)
OutputFileList.append(OutputFile)
@@ -186,16 +192,18 @@ class EfiSection (EfiSectionClassObject):
elif FileList != []:
for File in FileList:
Index = Index + 1
- Num = '%s.%d' %(SecNum , Index)
- OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
+ Num = '%s.%d' %(SecNum, Index)
+ OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType))
f = open(File, 'r')
UiString = f.read()
f.close()
+ if IsMakefile and UiString == ModuleNameStr:
+ UiString = "$(MODULE_NAME)"
GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
Ui=UiString, IsMakefile=IsMakefile)
OutputFileList.append(OutputFile)
else:
- if StringData != None and len(StringData) > 0:
+ if StringData is not None and len(StringData) > 0:
UiTuple = ('-n', '"' + StringData + '"')
else:
UiTuple = tuple()
@@ -207,7 +215,9 @@ class EfiSection (EfiSectionClassObject):
EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s miss UI Section value" %InfFileName)
Num = SecNum
- OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
+ if IsMakefile and StringData == ModuleNameStr:
+ StringData = "$(MODULE_NAME)"
+ OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + str(Num) + Ffs.SectionSuffix.get(SectionType))
GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
Ui=StringData, IsMakefile=IsMakefile)
OutputFileList.append(OutputFile)
@@ -227,12 +237,12 @@ class EfiSection (EfiSectionClassObject):
for File in FileList:
""" Copy Map file to FFS output path """
Index = Index + 1
- Num = '%s.%d' %(SecNum , Index)
- OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
+ Num = '%s.%d' %(SecNum, Index)
+ OutputFile = os.path.join( OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get(SectionType))
File = GenFdsGlobalVariable.MacroExtend(File, Dict)
-
+
#Get PE Section alignment when align is set to AUTO
- if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
+ if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):
ImageObj = PeImageClass (File)
if ImageObj.SectionAlignment < 0x400:
Align = str (ImageObj.SectionAlignment)
@@ -274,10 +284,10 @@ class EfiSection (EfiSectionClassObject):
IsMakefile = IsMakefile
)
File = StrippedFile
-
+
"""For TE Section call GenFw to generate TE image"""
- if SectionType == 'TE':
+ if SectionType == BINARY_FILE_TYPE_TE:
TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
GenFdsGlobalVariable.GenerateFirmwareImage(
TeFile,