X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FFfsFileStatement.py;h=ba8e0465ef34721defca9355978dba5df7cc2691;hp=690826bcb999b672739cea3fdf13188f1b5b11ce;hb=92beb1e4c73a40a708c7c0cade5c7cee314b3887;hpb=cfaaf99bdd412139ca7b9724e678429b2f2fb45f
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
index 690826bcb9..ba8e0465ef 100644
--- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
@@ -1,7 +1,7 @@
## @file
# process FFS generation from FILE statement
#
-# Copyright (c) 2007 - 2016, 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
@@ -57,9 +57,9 @@ class FileStatement (FileStatementClassObject) :
# @param FvParentAddr Parent Fv base address
# @retval string Generated FFS file name
#
- def GenFfs(self, Dict = {}, FvChildAddr=[], FvParentAddr=None):
+ def GenFfs(self, Dict = {}, FvChildAddr=[], FvParentAddr=None, IsMakefile=False, FvName=None):
- if self.NameGuid != None and self.NameGuid.startswith('PCD('):
+ if self.NameGuid is not None and self.NameGuid.startswith('PCD('):
PcdValue = GenFdsGlobalVariable.GetPcdValue(self.NameGuid)
if len(PcdValue) == 0:
EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \
@@ -72,28 +72,31 @@ class FileStatement (FileStatementClassObject) :
% (self.NameGuid))
self.NameGuid = RegistryGuidStr
- OutputDir = os.path.join(GenFdsGlobalVariable.FfsDir, self.NameGuid)
+ Str = self.NameGuid
+ if FvName:
+ Str += FvName
+ OutputDir = os.path.join(GenFdsGlobalVariable.FfsDir, Str)
if not os.path.exists(OutputDir):
os.makedirs(OutputDir)
Dict.update(self.DefineVarDict)
SectionAlignments = None
- if self.FvName != None :
+ if self.FvName is not None :
Buffer = StringIO.StringIO('')
- if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
+ if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName))
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
FileName = Fv.AddToBuffer(Buffer)
SectionFiles = [FileName]
- elif self.FdName != None:
- if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
+ elif self.FdName is not None:
+ if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
EdkLogger.error("GenFds", GENFDS_ERROR, "FD (%s) is NOT described in FDF file!" % (self.FdName))
Fd = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper())
FileName = Fd.GenFd()
SectionFiles = [FileName]
- elif self.FileName != None:
+ elif self.FileName is not None:
if hasattr(self, 'FvFileType') and self.FvFileType == 'RAW':
if isinstance(self.FileName, list) and isinstance(self.SubAlignment, list) and len(self.FileName) == len(self.SubAlignment):
FileContent = ''
@@ -101,13 +104,13 @@ class FileStatement (FileStatementClassObject) :
MaxAlignValue = 1
for Index, File in enumerate(self.FileName):
try:
- f = open(File, 'r+b')
+ f = open(File, 'rb')
except:
GenFdsGlobalVariable.ErrorLogger("Error opening RAW file %s." % (File))
Content = f.read()
f.close()
AlignValue = 1
- if self.SubAlignment[Index] != None:
+ if self.SubAlignment[Index] is not None:
AlignValue = GenFdsGlobalVariable.GetAlignment(self.SubAlignment[Index])
if AlignValue > MaxAlignValue:
MaxAlignIndex = Index
@@ -148,7 +151,7 @@ class FileStatement (FileStatementClassObject) :
section.FvAddr = FvChildAddr.pop(0)
elif isinstance(section, GuidSection):
section.FvAddr = FvChildAddr
- if FvParentAddr != None and isinstance(section, GuidSection):
+ if FvParentAddr is not None and isinstance(section, GuidSection):
section.FvParentAddr = FvParentAddr
if self.KeepReloc == False: