mirror of https://github.com/acidanthera/audk.git
BaseTools: Replace StringIO.StringIO with io.BytesIO
Replace StringIO.StringIO with io.BytesIO to be compatible with python3. This commit also removes "import StringIO" from those python scripts that don't really use it. Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Gary Lin <glin@suse.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
parent
0d1f5b2b5d
commit
86379ac48b
|
@ -23,11 +23,6 @@ import codecs
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
|
||||||
from io import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from StringIO import StringIO
|
|
||||||
|
|
||||||
class ConvertOneArg:
|
class ConvertOneArg:
|
||||||
"""Converts utf-16 to utf-8 for one command line argument.
|
"""Converts utf-16 to utf-8 for one command line argument.
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import uuid
|
||||||
import GenC
|
import GenC
|
||||||
import GenMake
|
import GenMake
|
||||||
import GenDepex
|
import GenDepex
|
||||||
from StringIO import StringIO
|
from io import BytesIO
|
||||||
|
|
||||||
from StrGather import *
|
from StrGather import *
|
||||||
from BuildEngine import BuildRule
|
from BuildEngine import BuildRule
|
||||||
|
@ -3437,8 +3437,8 @@ class ModuleAutoGen(AutoGen):
|
||||||
def _GetAutoGenFileList(self):
|
def _GetAutoGenFileList(self):
|
||||||
UniStringAutoGenC = True
|
UniStringAutoGenC = True
|
||||||
IdfStringAutoGenC = True
|
IdfStringAutoGenC = True
|
||||||
UniStringBinBuffer = StringIO()
|
UniStringBinBuffer = BytesIO()
|
||||||
IdfGenBinBuffer = StringIO()
|
IdfGenBinBuffer = BytesIO()
|
||||||
if self.BuildType == 'UEFI_HII':
|
if self.BuildType == 'UEFI_HII':
|
||||||
UniStringAutoGenC = False
|
UniStringAutoGenC = False
|
||||||
IdfStringAutoGenC = False
|
IdfStringAutoGenC = False
|
||||||
|
@ -3713,8 +3713,8 @@ class ModuleAutoGen(AutoGen):
|
||||||
except:
|
except:
|
||||||
EdkLogger.error("build", FILE_OPEN_FAILURE, "File open failed for %s" % UniVfrOffsetFileName, None)
|
EdkLogger.error("build", FILE_OPEN_FAILURE, "File open failed for %s" % UniVfrOffsetFileName, None)
|
||||||
|
|
||||||
# Use a instance of StringIO to cache data
|
# Use a instance of BytesIO to cache data
|
||||||
fStringIO = StringIO('')
|
fStringIO = BytesIO('')
|
||||||
|
|
||||||
for Item in VfrUniOffsetList:
|
for Item in VfrUniOffsetList:
|
||||||
if (Item[0].find("Strings") != -1):
|
if (Item[0].find("Strings") != -1):
|
||||||
|
|
|
@ -17,7 +17,7 @@ import Common.LongFilePathOs as os
|
||||||
import re
|
import re
|
||||||
import traceback
|
import traceback
|
||||||
from Common.LongFilePathSupport import OpenLongFilePath as open
|
from Common.LongFilePathSupport import OpenLongFilePath as open
|
||||||
from StringIO import StringIO
|
from io import BytesIO
|
||||||
from struct import pack
|
from struct import pack
|
||||||
from Common.BuildToolError import *
|
from Common.BuildToolError import *
|
||||||
from Common.Misc import SaveFileOnChange
|
from Common.Misc import SaveFileOnChange
|
||||||
|
@ -345,7 +345,7 @@ class DependencyExpression:
|
||||||
# @retval False If file exists and is not changed.
|
# @retval False If file exists and is not changed.
|
||||||
#
|
#
|
||||||
def Generate(self, File=None):
|
def Generate(self, File=None):
|
||||||
Buffer = StringIO()
|
Buffer = BytesIO()
|
||||||
if len(self.PostfixNotation) == 0:
|
if len(self.PostfixNotation) == 0:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#
|
#
|
||||||
from StringIO import StringIO
|
from io import BytesIO
|
||||||
from Common.Misc import *
|
from Common.Misc import *
|
||||||
from Common.StringUtils import StringToArray
|
from Common.StringUtils import StringToArray
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
@ -888,7 +888,7 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH):
|
||||||
DbFileName = os.path.join(Info.PlatformInfo.BuildDir, TAB_FV_DIRECTORY, Phase + "PcdDataBase.raw")
|
DbFileName = os.path.join(Info.PlatformInfo.BuildDir, TAB_FV_DIRECTORY, Phase + "PcdDataBase.raw")
|
||||||
else:
|
else:
|
||||||
DbFileName = os.path.join(Info.OutputDir, Phase + "PcdDataBase.raw")
|
DbFileName = os.path.join(Info.OutputDir, Phase + "PcdDataBase.raw")
|
||||||
DbFile = StringIO()
|
DbFile = BytesIO()
|
||||||
DbFile.write(PcdDbBuffer)
|
DbFile.write(PcdDbBuffer)
|
||||||
Changed = SaveFileOnChange(DbFileName, DbFile.getvalue(), True)
|
Changed = SaveFileOnChange(DbFileName, DbFile.getvalue(), True)
|
||||||
def CreatePcdDataBase(PcdDBData):
|
def CreatePcdDataBase(PcdDBData):
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
# Import Modules
|
# Import Modules
|
||||||
#
|
#
|
||||||
import Common.EdkLogger as EdkLogger
|
import Common.EdkLogger as EdkLogger
|
||||||
import StringIO
|
|
||||||
from Common.BuildToolError import *
|
from Common.BuildToolError import *
|
||||||
from Common.StringUtils import GetLineNo
|
from Common.StringUtils import GetLineNo
|
||||||
from Common.Misc import PathClass
|
from Common.Misc import PathClass
|
||||||
|
|
|
@ -18,7 +18,7 @@ import re
|
||||||
import Common.EdkLogger as EdkLogger
|
import Common.EdkLogger as EdkLogger
|
||||||
from Common.BuildToolError import *
|
from Common.BuildToolError import *
|
||||||
from UniClassObject import *
|
from UniClassObject import *
|
||||||
from StringIO import StringIO
|
from io import BytesIO
|
||||||
from struct import pack, unpack
|
from struct import pack, unpack
|
||||||
from Common.LongFilePathSupport import OpenLongFilePath as open
|
from Common.LongFilePathSupport import OpenLongFilePath as open
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ def CreateCFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniBinBuffer,
|
||||||
if Language not in UniLanguageListFiltered:
|
if Language not in UniLanguageListFiltered:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
StringBuffer = StringIO()
|
StringBuffer = BytesIO()
|
||||||
StrStringValue = ''
|
StrStringValue = ''
|
||||||
ArrayLength = 0
|
ArrayLength = 0
|
||||||
NumberOfUseOtherLangDef = 0
|
NumberOfUseOtherLangDef = 0
|
||||||
|
|
|
@ -20,7 +20,7 @@ from __future__ import print_function
|
||||||
import Common.LongFilePathOs as os, codecs, re
|
import Common.LongFilePathOs as os, codecs, re
|
||||||
import distutils.util
|
import distutils.util
|
||||||
import Common.EdkLogger as EdkLogger
|
import Common.EdkLogger as EdkLogger
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
from Common.BuildToolError import *
|
from Common.BuildToolError import *
|
||||||
from Common.StringUtils import GetLineNo
|
from Common.StringUtils import GetLineNo
|
||||||
from Common.Misc import PathClass
|
from Common.Misc import PathClass
|
||||||
|
@ -320,7 +320,7 @@ class UniFileClassObject(object):
|
||||||
|
|
||||||
UniFileClassObject.VerifyUcs2Data(FileIn, FileName, Encoding)
|
UniFileClassObject.VerifyUcs2Data(FileIn, FileName, Encoding)
|
||||||
|
|
||||||
UniFile = StringIO.StringIO(FileIn)
|
UniFile = BytesIO(FileIn)
|
||||||
Info = codecs.lookup(Encoding)
|
Info = codecs.lookup(Encoding)
|
||||||
(Reader, Writer) = (Info.streamreader, Info.streamwriter)
|
(Reader, Writer) = (Info.streamreader, Info.streamwriter)
|
||||||
return codecs.StreamReaderWriter(UniFile, Reader, Writer)
|
return codecs.StreamReaderWriter(UniFile, Reader, Writer)
|
||||||
|
@ -335,7 +335,7 @@ class UniFileClassObject(object):
|
||||||
FileDecoded = codecs.decode(FileIn, Encoding)
|
FileDecoded = codecs.decode(FileIn, Encoding)
|
||||||
Ucs2Info.encode(FileDecoded)
|
Ucs2Info.encode(FileDecoded)
|
||||||
except:
|
except:
|
||||||
UniFile = StringIO.StringIO(FileIn)
|
UniFile = BytesIO(FileIn)
|
||||||
Info = codecs.lookup(Encoding)
|
Info = codecs.lookup(Encoding)
|
||||||
(Reader, Writer) = (Info.streamreader, Info.streamwriter)
|
(Reader, Writer) = (Info.streamreader, Info.streamwriter)
|
||||||
File = codecs.StreamReaderWriter(UniFile, Reader, Writer)
|
File = codecs.StreamReaderWriter(UniFile, Reader, Writer)
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
import os
|
import os
|
||||||
from Common.RangeExpression import RangeExpression
|
from Common.RangeExpression import RangeExpression
|
||||||
from Common.Misc import *
|
from Common.Misc import *
|
||||||
from StringIO import StringIO
|
from io import BytesIO
|
||||||
from struct import pack
|
from struct import pack
|
||||||
from Common.DataType import *
|
from Common.DataType import *
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object):
|
||||||
Buffer += b
|
Buffer += b
|
||||||
realLength += 1
|
realLength += 1
|
||||||
|
|
||||||
DbFile = StringIO()
|
DbFile = BytesIO()
|
||||||
if Phase == 'DXE' and os.path.exists(BinFilePath):
|
if Phase == 'DXE' and os.path.exists(BinFilePath):
|
||||||
BinFile = open(BinFilePath, "rb")
|
BinFile = open(BinFilePath, "rb")
|
||||||
BinBuffer = BinFile.read()
|
BinBuffer = BinFile.read()
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import Common.LongFilePathOs as os
|
import Common.LongFilePathOs as os
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
import StringTable as st
|
import StringTable as st
|
||||||
import array
|
import array
|
||||||
import re
|
import re
|
||||||
|
@ -673,8 +673,8 @@ class GenVPD :
|
||||||
# Open failed
|
# Open failed
|
||||||
EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" % self.MapFileName, None)
|
EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" % self.MapFileName, None)
|
||||||
|
|
||||||
# Use a instance of StringIO to cache data
|
# Use a instance of BytesIO to cache data
|
||||||
fStringIO = StringIO.StringIO('')
|
fStringIO = BytesIO('')
|
||||||
|
|
||||||
# Write the header of map file.
|
# Write the header of map file.
|
||||||
try :
|
try :
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#
|
#
|
||||||
from struct import *
|
from struct import *
|
||||||
import Common.LongFilePathOs as os
|
import Common.LongFilePathOs as os
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
import FfsFileStatement
|
import FfsFileStatement
|
||||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||||
from CommonDataClass.FdfClass import AprioriSectionClassObject
|
from CommonDataClass.FdfClass import AprioriSectionClassObject
|
||||||
|
@ -51,7 +51,7 @@ class AprioriSection (AprioriSectionClassObject):
|
||||||
def GenFfs (self, FvName, Dict = {}, IsMakefile = False):
|
def GenFfs (self, FvName, Dict = {}, IsMakefile = False):
|
||||||
DXE_GUID = "FC510EE7-FFDC-11D4-BD41-0080C73C8881"
|
DXE_GUID = "FC510EE7-FFDC-11D4-BD41-0080C73C8881"
|
||||||
PEI_GUID = "1B45CC0A-156A-428A-AF62-49864DA0E6E6"
|
PEI_GUID = "1B45CC0A-156A-428A-AF62-49864DA0E6E6"
|
||||||
Buffer = StringIO.StringIO('')
|
Buffer = BytesIO('')
|
||||||
AprioriFileGuid = DXE_GUID
|
AprioriFileGuid = DXE_GUID
|
||||||
if self.AprioriType == "PEI":
|
if self.AprioriType == "PEI":
|
||||||
AprioriFileGuid = PEI_GUID
|
AprioriFileGuid = PEI_GUID
|
||||||
|
|
|
@ -19,7 +19,7 @@ from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||||
from CommonDataClass.FdfClass import CapsuleClassObject
|
from CommonDataClass.FdfClass import CapsuleClassObject
|
||||||
import Common.LongFilePathOs as os
|
import Common.LongFilePathOs as os
|
||||||
import subprocess
|
import subprocess
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
from Common.Misc import SaveFileOnChange
|
from Common.Misc import SaveFileOnChange
|
||||||
from GenFds import GenFds
|
from GenFds import GenFds
|
||||||
from Common.Misc import PackRegistryFormatGuid
|
from Common.Misc import PackRegistryFormatGuid
|
||||||
|
@ -66,7 +66,7 @@ class Capsule (CapsuleClassObject) :
|
||||||
# UINT32 CapsuleImageSize;
|
# UINT32 CapsuleImageSize;
|
||||||
# } EFI_CAPSULE_HEADER;
|
# } EFI_CAPSULE_HEADER;
|
||||||
#
|
#
|
||||||
Header = StringIO.StringIO()
|
Header = BytesIO()
|
||||||
#
|
#
|
||||||
# Use FMP capsule GUID: 6DCBD5ED-E82D-4C44-BDA1-7194199AD92A
|
# Use FMP capsule GUID: 6DCBD5ED-E82D-4C44-BDA1-7194199AD92A
|
||||||
#
|
#
|
||||||
|
@ -97,7 +97,7 @@ class Capsule (CapsuleClassObject) :
|
||||||
# // UINT64 ItemOffsetList[];
|
# // UINT64 ItemOffsetList[];
|
||||||
# } EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER;
|
# } EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER;
|
||||||
#
|
#
|
||||||
FwMgrHdr = StringIO.StringIO()
|
FwMgrHdr = BytesIO()
|
||||||
if 'CAPSULE_HEADER_INIT_VERSION' in self.TokensDict:
|
if 'CAPSULE_HEADER_INIT_VERSION' in self.TokensDict:
|
||||||
FwMgrHdr.write(pack('=I', int(self.TokensDict['CAPSULE_HEADER_INIT_VERSION'], 16)))
|
FwMgrHdr.write(pack('=I', int(self.TokensDict['CAPSULE_HEADER_INIT_VERSION'], 16)))
|
||||||
else:
|
else:
|
||||||
|
@ -132,7 +132,7 @@ class Capsule (CapsuleClassObject) :
|
||||||
#
|
#
|
||||||
|
|
||||||
PreSize = FwMgrHdrSize
|
PreSize = FwMgrHdrSize
|
||||||
Content = StringIO.StringIO()
|
Content = BytesIO()
|
||||||
for driver in self.CapsuleDataList:
|
for driver in self.CapsuleDataList:
|
||||||
FileName = driver.GenCapsuleSubItem()
|
FileName = driver.GenCapsuleSubItem()
|
||||||
FwMgrHdr.write(pack('=Q', PreSize))
|
FwMgrHdr.write(pack('=Q', PreSize))
|
||||||
|
@ -247,7 +247,7 @@ class Capsule (CapsuleClassObject) :
|
||||||
def GenCapInf(self):
|
def GenCapInf(self):
|
||||||
self.CapInfFileName = os.path.join(GenFdsGlobalVariable.FvDir,
|
self.CapInfFileName = os.path.join(GenFdsGlobalVariable.FvDir,
|
||||||
self.UiCapsuleName + "_Cap" + '.inf')
|
self.UiCapsuleName + "_Cap" + '.inf')
|
||||||
CapInfFile = StringIO.StringIO() #open (self.CapInfFileName , 'w+')
|
CapInfFile = BytesIO() #open (self.CapInfFileName , 'w+')
|
||||||
|
|
||||||
CapInfFile.writelines("[options]" + T_CHAR_LF)
|
CapInfFile.writelines("[options]" + T_CHAR_LF)
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#
|
#
|
||||||
import Ffs
|
import Ffs
|
||||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
from struct import pack
|
from struct import pack
|
||||||
import os
|
import os
|
||||||
from Common.Misc import SaveFileOnChange
|
from Common.Misc import SaveFileOnChange
|
||||||
|
@ -82,7 +82,7 @@ class CapsuleFv (CapsuleData):
|
||||||
if self.FvName.find('.fv') == -1:
|
if self.FvName.find('.fv') == -1:
|
||||||
if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
|
if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
|
||||||
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[self.FvName.upper()]
|
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[self.FvName.upper()]
|
||||||
FdBuffer = StringIO.StringIO('')
|
FdBuffer = BytesIO('')
|
||||||
FvObj.CapsuleName = self.CapsuleName
|
FvObj.CapsuleName = self.CapsuleName
|
||||||
FvFile = FvObj.AddToBuffer(FdBuffer)
|
FvFile = FvObj.AddToBuffer(FdBuffer)
|
||||||
FvObj.CapsuleName = None
|
FvObj.CapsuleName = None
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
import Region
|
import Region
|
||||||
import Fv
|
import Fv
|
||||||
import Common.LongFilePathOs as os
|
import Common.LongFilePathOs as os
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
import sys
|
import sys
|
||||||
from struct import *
|
from struct import *
|
||||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||||
|
@ -75,7 +75,7 @@ class FD(FDClassObject):
|
||||||
HasCapsuleRegion = True
|
HasCapsuleRegion = True
|
||||||
break
|
break
|
||||||
if HasCapsuleRegion:
|
if HasCapsuleRegion:
|
||||||
TempFdBuffer = StringIO.StringIO('')
|
TempFdBuffer = BytesIO('')
|
||||||
PreviousRegionStart = -1
|
PreviousRegionStart = -1
|
||||||
PreviousRegionSize = 1
|
PreviousRegionSize = 1
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ class FD(FDClassObject):
|
||||||
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
|
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
|
||||||
RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
|
RegionObj.AddToBuffer (TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
|
||||||
|
|
||||||
FdBuffer = StringIO.StringIO('')
|
FdBuffer = BytesIO('')
|
||||||
PreviousRegionStart = -1
|
PreviousRegionStart = -1
|
||||||
PreviousRegionSize = 1
|
PreviousRegionSize = 1
|
||||||
for RegionObj in self.RegionList :
|
for RegionObj in self.RegionList :
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
import Ffs
|
import Ffs
|
||||||
import Rule
|
import Rule
|
||||||
import Common.LongFilePathOs as os
|
import Common.LongFilePathOs as os
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||||
|
@ -82,7 +82,7 @@ class FileStatement (FileStatementClassObject) :
|
||||||
Dict.update(self.DefineVarDict)
|
Dict.update(self.DefineVarDict)
|
||||||
SectionAlignments = None
|
SectionAlignments = None
|
||||||
if self.FvName is not None :
|
if self.FvName is not None :
|
||||||
Buffer = StringIO.StringIO('')
|
Buffer = BytesIO('')
|
||||||
if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
|
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))
|
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName))
|
||||||
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
|
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#
|
#
|
||||||
import Rule
|
import Rule
|
||||||
import Common.LongFilePathOs as os
|
import Common.LongFilePathOs as os
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
from struct import *
|
from struct import *
|
||||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||||
import Ffs
|
import Ffs
|
||||||
|
@ -1088,7 +1088,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||||
def __GenUniVfrOffsetFile(VfrUniOffsetList, UniVfrOffsetFileName):
|
def __GenUniVfrOffsetFile(VfrUniOffsetList, UniVfrOffsetFileName):
|
||||||
|
|
||||||
# Use a instance of StringIO to cache data
|
# Use a instance of StringIO to cache data
|
||||||
fStringIO = StringIO.StringIO('')
|
fStringIO = BytesIO('')
|
||||||
|
|
||||||
for Item in VfrUniOffsetList:
|
for Item in VfrUniOffsetList:
|
||||||
if (Item[0].find("Strings") != -1):
|
if (Item[0].find("Strings") != -1):
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#
|
#
|
||||||
import Common.LongFilePathOs as os
|
import Common.LongFilePathOs as os
|
||||||
import subprocess
|
import subprocess
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
from struct import *
|
from struct import *
|
||||||
|
|
||||||
import Ffs
|
import Ffs
|
||||||
|
@ -265,7 +265,7 @@ class FV (FvClassObject):
|
||||||
#
|
#
|
||||||
self.InfFileName = os.path.join(GenFdsGlobalVariable.FvDir,
|
self.InfFileName = os.path.join(GenFdsGlobalVariable.FvDir,
|
||||||
self.UiFvName + '.inf')
|
self.UiFvName + '.inf')
|
||||||
self.FvInfFile = StringIO.StringIO()
|
self.FvInfFile = BytesIO()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Add [Options]
|
# Add [Options]
|
||||||
|
@ -407,7 +407,7 @@ class FV (FvClassObject):
|
||||||
#
|
#
|
||||||
if TotalSize > 0:
|
if TotalSize > 0:
|
||||||
FvExtHeaderFileName = os.path.join(GenFdsGlobalVariable.FvDir, self.UiFvName + '.ext')
|
FvExtHeaderFileName = os.path.join(GenFdsGlobalVariable.FvDir, self.UiFvName + '.ext')
|
||||||
FvExtHeaderFile = StringIO.StringIO()
|
FvExtHeaderFile = BytesIO()
|
||||||
FvExtHeaderFile.write(Buffer)
|
FvExtHeaderFile.write(Buffer)
|
||||||
Changed = SaveFileOnChange(FvExtHeaderFileName, FvExtHeaderFile.getvalue(), True)
|
Changed = SaveFileOnChange(FvExtHeaderFileName, FvExtHeaderFile.getvalue(), True)
|
||||||
FvExtHeaderFile.close()
|
FvExtHeaderFile.close()
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
# Import Modules
|
# Import Modules
|
||||||
#
|
#
|
||||||
import Section
|
import Section
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
from Ffs import Ffs
|
from Ffs import Ffs
|
||||||
import subprocess
|
import subprocess
|
||||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||||
|
@ -98,7 +98,7 @@ class FvImageSection(FvImageSectionClassObject):
|
||||||
# Generate Fv
|
# Generate Fv
|
||||||
#
|
#
|
||||||
if self.FvName is not None:
|
if self.FvName is not None:
|
||||||
Buffer = StringIO.StringIO('')
|
Buffer = BytesIO('')
|
||||||
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName)
|
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName)
|
||||||
if Fv is not None:
|
if Fv is not None:
|
||||||
self.Fv = Fv
|
self.Fv = Fv
|
||||||
|
|
|
@ -27,7 +27,7 @@ from Workspace.WorkspaceDatabase import WorkspaceDatabase
|
||||||
from Workspace.BuildClassObject import PcdClassObject
|
from Workspace.BuildClassObject import PcdClassObject
|
||||||
import RuleComplexFile
|
import RuleComplexFile
|
||||||
from EfiSection import EfiSection
|
from EfiSection import EfiSection
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
import Common.TargetTxtClassObject as TargetTxtClassObject
|
import Common.TargetTxtClassObject as TargetTxtClassObject
|
||||||
import Common.ToolDefClassObject as ToolDefClassObject
|
import Common.ToolDefClassObject as ToolDefClassObject
|
||||||
from Common.DataType import *
|
from Common.DataType import *
|
||||||
|
@ -542,13 +542,13 @@ class GenFds :
|
||||||
if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
|
if GenFds.OnlyGenerateThisFv is not None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
|
||||||
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[GenFds.OnlyGenerateThisFv.upper()]
|
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[GenFds.OnlyGenerateThisFv.upper()]
|
||||||
if FvObj is not None:
|
if FvObj is not None:
|
||||||
Buffer = StringIO.StringIO()
|
Buffer = BytesIO()
|
||||||
FvObj.AddToBuffer(Buffer)
|
FvObj.AddToBuffer(Buffer)
|
||||||
Buffer.close()
|
Buffer.close()
|
||||||
return
|
return
|
||||||
elif GenFds.OnlyGenerateThisFv is None:
|
elif GenFds.OnlyGenerateThisFv is None:
|
||||||
for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values():
|
for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict.values():
|
||||||
Buffer = StringIO.StringIO('')
|
Buffer = BytesIO('')
|
||||||
FvObj.AddToBuffer(Buffer)
|
FvObj.AddToBuffer(Buffer)
|
||||||
Buffer.close()
|
Buffer.close()
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ class GenFds :
|
||||||
|
|
||||||
def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):
|
def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):
|
||||||
GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir, "Guid.xref")
|
GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir, "Guid.xref")
|
||||||
GuidXRefFile = StringIO.StringIO('')
|
GuidXRefFile = BytesIO('')
|
||||||
GuidDict = {}
|
GuidDict = {}
|
||||||
ModuleList = []
|
ModuleList = []
|
||||||
FileGuidList = []
|
FileGuidList = []
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#
|
#
|
||||||
import Common.LongFilePathOs as os
|
import Common.LongFilePathOs as os
|
||||||
import subprocess
|
import subprocess
|
||||||
import StringIO
|
|
||||||
|
|
||||||
import OptRomInfStatement
|
import OptRomInfStatement
|
||||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||||
|
@ -138,5 +137,3 @@ class OverrideAttribs:
|
||||||
self.PciDeviceId = None
|
self.PciDeviceId = None
|
||||||
self.PciRevision = None
|
self.PciRevision = None
|
||||||
self.NeedCompress = None
|
self.NeedCompress = None
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#
|
#
|
||||||
from struct import *
|
from struct import *
|
||||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
import string
|
import string
|
||||||
from CommonDataClass.FdfClass import RegionClassObject
|
from CommonDataClass.FdfClass import RegionClassObject
|
||||||
import Common.LongFilePathOs as os
|
import Common.LongFilePathOs as os
|
||||||
|
@ -127,7 +127,7 @@ class Region(RegionClassObject):
|
||||||
if self.FvAddress % FvAlignValue != 0:
|
if self.FvAddress % FvAlignValue != 0:
|
||||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||||
"FV (%s) is NOT %s Aligned!" % (FvObj.UiFvName, FvObj.FvAlignment))
|
"FV (%s) is NOT %s Aligned!" % (FvObj.UiFvName, FvObj.FvAlignment))
|
||||||
FvBuffer = StringIO.StringIO('')
|
FvBuffer = BytesIO('')
|
||||||
FvBaseAddress = '0x%X' % self.FvAddress
|
FvBaseAddress = '0x%X' % self.FvAddress
|
||||||
BlockSize = None
|
BlockSize = None
|
||||||
BlockNum = None
|
BlockNum = None
|
||||||
|
@ -135,7 +135,8 @@ class Region(RegionClassObject):
|
||||||
if Flag:
|
if Flag:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if FvBuffer.len > Size:
|
FvBufferLen = len(FvBuffer.getvalue())
|
||||||
|
if FvBufferLen > Size:
|
||||||
FvBuffer.close()
|
FvBuffer.close()
|
||||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||||
"Size of FV (%s) is larger than Region Size 0x%X specified." % (RegionData, Size))
|
"Size of FV (%s) is larger than Region Size 0x%X specified." % (RegionData, Size))
|
||||||
|
@ -144,8 +145,8 @@ class Region(RegionClassObject):
|
||||||
#
|
#
|
||||||
Buffer.write(FvBuffer.getvalue())
|
Buffer.write(FvBuffer.getvalue())
|
||||||
FvBuffer.close()
|
FvBuffer.close()
|
||||||
FvOffset = FvOffset + FvBuffer.len
|
FvOffset = FvOffset + FvBufferLen
|
||||||
Size = Size - FvBuffer.len
|
Size = Size - FvBufferLen
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (RegionData))
|
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (RegionData))
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
import Common.LongFilePathOs as os
|
import Common.LongFilePathOs as os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from optparse import make_option
|
from optparse import make_option
|
||||||
|
@ -455,8 +455,8 @@ def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile):
|
||||||
except:
|
except:
|
||||||
EdkLogger.error("Trim", FILE_OPEN_FAILURE, "File open failed for %s" %OutputFile, None)
|
EdkLogger.error("Trim", FILE_OPEN_FAILURE, "File open failed for %s" %OutputFile, None)
|
||||||
|
|
||||||
# Use a instance of StringIO to cache data
|
# Use a instance of BytesIO to cache data
|
||||||
fStringIO = StringIO.StringIO('')
|
fStringIO = BytesIO('')
|
||||||
|
|
||||||
for Item in VfrUniOffsetList:
|
for Item in VfrUniOffsetList:
|
||||||
if (Item[0].find("Strings") != -1):
|
if (Item[0].find("Strings") != -1):
|
||||||
|
|
|
@ -28,7 +28,7 @@ import hashlib
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from StringIO import StringIO
|
from io import BytesIO
|
||||||
from Common import EdkLogger
|
from Common import EdkLogger
|
||||||
from Common.Misc import SaveFileOnChange
|
from Common.Misc import SaveFileOnChange
|
||||||
from Common.Misc import GuidStructureByteArrayToGuidString
|
from Common.Misc import GuidStructureByteArrayToGuidString
|
||||||
|
@ -2169,7 +2169,7 @@ class BuildReport(object):
|
||||||
def GenerateReport(self, BuildDuration, AutoGenTime, MakeTime, GenFdsTime):
|
def GenerateReport(self, BuildDuration, AutoGenTime, MakeTime, GenFdsTime):
|
||||||
if self.ReportFile:
|
if self.ReportFile:
|
||||||
try:
|
try:
|
||||||
File = StringIO('')
|
File = BytesIO('')
|
||||||
for (Wa, MaList) in self.ReportList:
|
for (Wa, MaList) in self.ReportList:
|
||||||
PlatformReport(Wa, MaList, self.ReportType).GenerateReport(File, BuildDuration, AutoGenTime, MakeTime, GenFdsTime, self.ReportType)
|
PlatformReport(Wa, MaList, self.ReportType).GenerateReport(File, BuildDuration, AutoGenTime, MakeTime, GenFdsTime, self.ReportType)
|
||||||
Content = FileLinesSplit(File.getvalue(), gLineMaxLength)
|
Content = FileLinesSplit(File.getvalue(), gLineMaxLength)
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import Common.LongFilePathOs as os
|
import Common.LongFilePathOs as os
|
||||||
import re
|
import re
|
||||||
import StringIO
|
from io import BytesIO
|
||||||
import sys
|
import sys
|
||||||
import glob
|
import glob
|
||||||
import time
|
import time
|
||||||
|
@ -1782,7 +1782,7 @@ class Build():
|
||||||
if not Ma.IsLibrary:
|
if not Ma.IsLibrary:
|
||||||
ModuleList[Ma.Guid.upper()] = Ma
|
ModuleList[Ma.Guid.upper()] = Ma
|
||||||
|
|
||||||
MapBuffer = StringIO('')
|
MapBuffer = BytesIO('')
|
||||||
if self.LoadFixAddress != 0:
|
if self.LoadFixAddress != 0:
|
||||||
#
|
#
|
||||||
# Rebase module to the preferred memory address before GenFds
|
# Rebase module to the preferred memory address before GenFds
|
||||||
|
@ -1940,7 +1940,7 @@ class Build():
|
||||||
if not Ma.IsLibrary:
|
if not Ma.IsLibrary:
|
||||||
ModuleList[Ma.Guid.upper()] = Ma
|
ModuleList[Ma.Guid.upper()] = Ma
|
||||||
|
|
||||||
MapBuffer = StringIO('')
|
MapBuffer = BytesIO('')
|
||||||
if self.LoadFixAddress != 0:
|
if self.LoadFixAddress != 0:
|
||||||
#
|
#
|
||||||
# Rebase module to the preferred memory address before GenFds
|
# Rebase module to the preferred memory address before GenFds
|
||||||
|
@ -2127,7 +2127,7 @@ class Build():
|
||||||
#
|
#
|
||||||
# Rebase module to the preferred memory address before GenFds
|
# Rebase module to the preferred memory address before GenFds
|
||||||
#
|
#
|
||||||
MapBuffer = StringIO('')
|
MapBuffer = BytesIO('')
|
||||||
if self.LoadFixAddress != 0:
|
if self.LoadFixAddress != 0:
|
||||||
self._CollectModuleMapBuffer(MapBuffer, ModuleList)
|
self._CollectModuleMapBuffer(MapBuffer, ModuleList)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue