X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FFfsFileStatement.py;h=f5de57d0ac8207798ba5bf745cbb7d087418c1eb;hb=86379ac48ba17c71d4623c57099b064b15118e21;hp=edb131266d98d1b6ac5e41872809a3293bb7f514;hpb=37de70b764200718cc39a21abc491c335e3da7b3;p=mirror_edk2.git
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
index edb131266d..f5de57d0ac 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 - 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
@@ -18,7 +18,7 @@
import Ffs
import Rule
import Common.LongFilePathOs as os
-import StringIO
+from io import BytesIO
import subprocess
from GenFdsGlobalVariable import GenFdsGlobalVariable
@@ -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, IsMakefile=False):
+ 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 :
- Buffer = StringIO.StringIO('')
- if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
+ if self.FvName is not None :
+ Buffer = BytesIO('')
+ 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 = ''
@@ -107,7 +110,7 @@ class FileStatement (FileStatementClassObject) :
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: