summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/AutoGen/GenC.py
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2018-10-15 08:27:53 +0800
committerLiming Gao <liming.gao@intel.com>2018-10-15 08:29:14 +0800
commit1ccc4d895dd8d659d016efcd6ef8a48749aba1d0 (patch)
tree0d5f58643cc72275887d3bb322813609906a9334 /BaseTools/Source/Python/AutoGen/GenC.py
parent678f85131238622e576705117e299d81cff755c9 (diff)
downloadedk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.tar.gz
edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.tar.bz2
edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.zip
Revert BaseTools: PYTHON3 migration
This reverts commit 6693f359b3c213513c5096a06c6f67244a44dc52.. 678f85131238622e576705117e299d81cff755c9. 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>
Diffstat (limited to 'BaseTools/Source/Python/AutoGen/GenC.py')
-rw-r--r--BaseTools/Source/Python/AutoGen/GenC.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 4db5330e51..09626d0b96 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -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: