Revert BaseTools: PYTHON3 migration
This reverts commit 6693f359b3c213513c5096a06c6f67244a44dc52..
678f851312
.
Python3 migration is the fundamental change. It requires every developer
to install Python3. Before this migration, the well communication and wide
verification must be done. But now, most people is not aware of this change,
and not try it. So, Python3 migration is reverted and be moved to edk2-staging
Python3 branch for the edk2 user evaluation.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
|
||||
## Import Modules
|
||||
#
|
||||
from __future__ import absolute_import
|
||||
import string
|
||||
import collections
|
||||
import struct
|
||||
@ -936,7 +937,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
if Info.IsLibrary:
|
||||
PcdList = Info.LibraryPcdList
|
||||
else:
|
||||
PcdList = list(Info.ModulePcdList) + list(Info.LibraryPcdList)
|
||||
PcdList = Info.ModulePcdList + Info.LibraryPcdList
|
||||
PcdExCNameTest = 0
|
||||
for PcdModule in PcdList:
|
||||
if PcdModule.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenCName == PcdModule.TokenCName:
|
||||
@ -970,7 +971,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
AutoGenH.Append('#define %s(Value) LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
elif Pcd.Type in PCD_DYNAMIC_TYPE_SET:
|
||||
PcdCNameTest = 0
|
||||
for PcdModule in list(Info.LibraryPcdList) + list(Info.ModulePcdList):
|
||||
for PcdModule in Info.LibraryPcdList + Info.ModulePcdList:
|
||||
if PcdModule.Type in PCD_DYNAMIC_TYPE_SET and Pcd.TokenCName == PcdModule.TokenCName:
|
||||
PcdCNameTest += 1
|
||||
# get out early once we found > 1...
|
||||
@ -1011,10 +1012,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
Value = Value[:-1]
|
||||
ValueNumber = int (Value, 0)
|
||||
except:
|
||||
try:
|
||||
ValueNumber = int(Value.lstrip('0'))
|
||||
except:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"PCD value is not valid dec or hex number for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
if ValueNumber < 0:
|
||||
@ -1053,7 +1051,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
else:
|
||||
NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ', '
|
||||
if Unicode:
|
||||
ArraySize = ArraySize // 2
|
||||
ArraySize = ArraySize / 2
|
||||
Value = NewValue + '0 }'
|
||||
if ArraySize < ValueSize:
|
||||
if Pcd.MaxSizeUserSet:
|
||||
@ -1063,7 +1061,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
else:
|
||||
ArraySize = Pcd.GetPcdSize()
|
||||
if Unicode:
|
||||
ArraySize = ArraySize // 2
|
||||
ArraySize = ArraySize / 2
|
||||
Array = '[%d]' % ArraySize
|
||||
#
|
||||
# skip casting for fixed at build since it breaks ARM assembly.
|
||||
@ -1798,7 +1796,7 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer):
|
||||
TempBuffer += Buffer
|
||||
elif File.Ext.upper() == '.JPG':
|
||||
ImageType, = struct.unpack('4s', Buffer[6:10])
|
||||
if ImageType != b'JFIF':
|
||||
if ImageType != 'JFIF':
|
||||
EdkLogger.error("build", FILE_TYPE_MISMATCH, "The file %s is not a standard JPG file." % File.Path)
|
||||
TempBuffer = pack('B', EFI_HII_IIBT_IMAGE_JPEG)
|
||||
TempBuffer += pack('I', len(Buffer))
|
||||
@ -1898,7 +1896,7 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer):
|
||||
|
||||
def BmpImageDecoder(File, Buffer, PaletteIndex, TransParent):
|
||||
ImageType, = struct.unpack('2s', Buffer[0:2])
|
||||
if ImageType!= b'BM': # BMP file type is 'BM'
|
||||
if ImageType!= 'BM': # BMP file type is 'BM'
|
||||
EdkLogger.error("build", FILE_TYPE_MISMATCH, "The file %s is not a standard BMP file." % File.Path)
|
||||
BMP_IMAGE_HEADER = collections.namedtuple('BMP_IMAGE_HEADER', ['bfSize', 'bfReserved1', 'bfReserved2', 'bfOffBits', 'biSize', 'biWidth', 'biHeight', 'biPlanes', 'biBitCount', 'biCompression', 'biSizeImage', 'biXPelsPerMeter', 'biYPelsPerMeter', 'biClrUsed', 'biClrImportant'])
|
||||
BMP_IMAGE_HEADER_STRUCT = struct.Struct('IHHIIIIHHIIIIII')
|
||||
@ -1922,7 +1920,7 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, TransParent):
|
||||
else:
|
||||
ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_1BIT)
|
||||
ImageBuffer += pack('B', PaletteIndex)
|
||||
Width = (BmpHeader.biWidth + 7)//8
|
||||
Width = (BmpHeader.biWidth + 7)/8
|
||||
if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2:
|
||||
PaletteBuffer = Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : BmpHeader.bfOffBits]
|
||||
elif BmpHeader.biBitCount == 4:
|
||||
@ -1931,7 +1929,7 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, TransParent):
|
||||
else:
|
||||
ImageBuffer = pack('B', EFI_HII_IIBT_IMAGE_4BIT)
|
||||
ImageBuffer += pack('B', PaletteIndex)
|
||||
Width = (BmpHeader.biWidth + 1)//2
|
||||
Width = (BmpHeader.biWidth + 1)/2
|
||||
if BmpHeader.bfOffBits > BMP_IMAGE_HEADER_STRUCT.size + 2:
|
||||
PaletteBuffer = Buffer[BMP_IMAGE_HEADER_STRUCT.size + 2 : BmpHeader.bfOffBits]
|
||||
elif BmpHeader.biBitCount == 8:
|
||||
@ -1970,7 +1968,7 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, TransParent):
|
||||
for Index in range(0, len(PaletteBuffer)):
|
||||
if Index % 4 == 3:
|
||||
continue
|
||||
PaletteTemp += bytes([PaletteBuffer[Index]])
|
||||
PaletteTemp += PaletteBuffer[Index]
|
||||
PaletteBuffer = PaletteTemp[1:]
|
||||
return ImageBuffer, PaletteBuffer
|
||||
|
||||
@ -2068,7 +2066,7 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBuffer,
|
||||
if Guid in Info.Module.GetGuidsUsedByPcd():
|
||||
continue
|
||||
GuidMacros.append('#define %s %s' % (Guid, Info.Module.Guids[Guid]))
|
||||
for Guid, Value in list(Info.Module.Protocols.items()) + list(Info.Module.Ppis.items()):
|
||||
for Guid, Value in Info.Module.Protocols.items() + Info.Module.Ppis.items():
|
||||
GuidMacros.append('#define %s %s' % (Guid, Value))
|
||||
# supports FixedAtBuild and FeaturePcd usage in VFR file
|
||||
if Info.VfrFileList and Info.ModulePcdList:
|
||||
|
Reference in New Issue
Block a user