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:
Liming Gao
2018-10-15 08:27:53 +08:00
parent 678f851312
commit 1ccc4d895d
182 changed files with 48049 additions and 15099 deletions

View File

@@ -1,6 +1,6 @@
Prerequisite Tools:
1. Install Python 3.6.6 from https://www.python.org/downloads/release/python-366/
2. Install wxPython 4.0.3 from https://pypi.org/project/wxPython/#files
1. Install Python 2.7.3 from https://www.python.org/download/releases/2.7.3/
2. Install wxPython 2.8.12.1 from https://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/
generally the libraries will be installed at python's subfolder, for example in windows: c:\python27\Lib\site-packages\
3. Install DoxyGen 1.8.6 from https://sourceforge.net/projects/doxygen/files/rel-1.8.6/
4. (Windows only) Install Htmlhelp tool from https://msdn.microsoft.com/en-us/library/windows/desktop/ms669985(v=vs.85).aspx

View File

@@ -12,11 +12,12 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from __future__ import print_function
import os, sys, logging, traceback, subprocess
from optparse import OptionParser
from .plugins.EdkPlugins.edk2.model import baseobject
from .plugins.EdkPlugins.edk2.model import doxygengen
import plugins.EdkPlugins.edk2.model.baseobject as baseobject
import plugins.EdkPlugins.edk2.model.doxygengen as doxygengen
gArchMarcoDict = {'ALL' : 'MDE_CPU_IA32 MDE_CPU_X64 MDE_CPU_EBC MDE_CPU_IPF _MSC_EXTENSIONS __GNUC__ __INTEL_COMPILER',
'IA32_MSFT': 'MDE_CPU_IA32 _MSC_EXTENSIONS',
@@ -37,7 +38,7 @@ def parseCmdArgs():
help='Specify the absolute path of doxygen tools installation. For example: C:\\Program Files\\doxygen\bin\doxygen.exe')
parser.add_option('-o', '--output', action='store', dest='OutputPath',
help='Specify the document output path. For example: c:\\docoutput')
parser.add_option('-a', '--arch', action='store', dest='Arch', choices=list(gArchMarcoDict.keys()),
parser.add_option('-a', '--arch', action='store', dest='Arch', choices=gArchMarcoDict.keys(),
help='Specify the architecture used in preprocess package\'s source. For example: -a IA32_MSFT')
parser.add_option('-m', '--mode', action='store', dest='DocumentMode', choices=['CHM', 'HTML'],
help='Specify the document mode from : CHM or HTML')

View File

@@ -18,8 +18,8 @@ import os, sys, wx, logging
import wx.stc
import wx.lib.newevent
import wx.lib.agw.genericmessagedialog as GMD
from plugins.EdkPlugins.edk2.model import baseobject
from plugins.EdkPlugins.edk2.model import doxygengen
import plugins.EdkPlugins.edk2.model.baseobject as baseobject
import plugins.EdkPlugins.edk2.model.doxygengen as doxygengen
if hasattr(sys, "frozen"):
appPath = os.path.abspath(os.path.dirname(sys.executable))
@@ -42,7 +42,7 @@ class PackageDocApp(wx.App):
frame.Show(True)
self.Bind(EVT_APP_CALLBACK, self.OnAppCallBack)
EVT_APP_CALLBACK( self, self.OnAppCallBack)
return True
def GetLogger(self):
@@ -60,13 +60,13 @@ class PackageDocApp(wx.App):
class PackageDocMainFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title, size=(550, 350), style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU|wx.CAPTION|wx.CLOSE_BOX )
wx.Frame.__init__(self, parent, -1, title, size=(550, 290), style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU|wx.CAPTION|wx.CLOSE_BOX )
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
subsizer = wx.GridBagSizer(5, 10)
subsizer.AddGrowableCol(0)
subsizer.AddGrowableCol(1)
subsizer.Add(wx.StaticText(panel, -1, "Workspace Location : "), (0, 0), flag=wx.ALIGN_CENTER_VERTICAL)
self._workspacePathCtrl = wx.ComboBox(panel, -1)
list = self.GetConfigure("WorkspacePath")
@@ -76,9 +76,9 @@ class PackageDocMainFrame(wx.Frame):
self._workspacePathCtrl.SetValue(list[len(list) - 1])
subsizer.Add(self._workspacePathCtrl, (0, 1), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
self._workspacePathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN))
self._workspacePathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN))
subsizer.Add(self._workspacePathBt, (0, 2), flag=wx.ALIGN_CENTER_VERTICAL)
self.Bind(wx.EVT_BUTTON, self.OnBrowsePath, self._workspacePathBt)
wx.EVT_BUTTON(self._workspacePathBt, self._workspacePathBt.GetId(), self.OnBrowsePath)
subsizer.Add(wx.StaticText(panel, -1, "Package DEC Location : "), (1, 0), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
self._packagePathCtrl = wx.ComboBox(panel, -1)
@@ -88,9 +88,9 @@ class PackageDocMainFrame(wx.Frame):
self._packagePathCtrl.Append(item)
self._packagePathCtrl.SetValue(list[len(list) - 1])
subsizer.Add(self._packagePathCtrl, (1, 1), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
self._packagePathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN))
self._packagePathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN))
subsizer.Add(self._packagePathBt, (1, 2), flag=wx.ALIGN_CENTER_VERTICAL)
self.Bind(wx.EVT_BUTTON, self.OnBrowsePath, self._packagePathBt)
wx.EVT_BUTTON(self._packagePathBt, self._packagePathBt.GetId(), self.OnBrowsePath)
subsizer.Add(wx.StaticText(panel, -1, "Doxygen Tool Location : "), (2, 0), flag=wx.ALIGN_CENTER_VERTICAL)
self._doxygenPathCtrl = wx.TextCtrl(panel, -1)
@@ -103,10 +103,10 @@ class PackageDocMainFrame(wx.Frame):
else:
self._doxygenPathCtrl.SetValue('/usr/bin/doxygen')
self._doxygenPathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN))
self._doxygenPathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN))
subsizer.Add(self._doxygenPathCtrl, (2, 1), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
subsizer.Add(self._doxygenPathBt, (2, 2), flag=wx.ALIGN_CENTER_VERTICAL)
self.Bind(wx.EVT_BUTTON, self.OnBrowsePath, self._doxygenPathBt)
wx.EVT_BUTTON(self._doxygenPathBt, self._doxygenPathBt.GetId(), self.OnBrowsePath)
subsizer.Add(wx.StaticText(panel, -1, "CHM Tool Location : "), (3, 0), flag=wx.ALIGN_CENTER_VERTICAL)
self._chmPathCtrl = wx.TextCtrl(panel, -1)
@@ -116,10 +116,10 @@ class PackageDocMainFrame(wx.Frame):
else:
self._chmPathCtrl.SetValue('C:\\Program Files\\HTML Help Workshop\\hhc.exe')
self._chmPathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN))
self._chmPathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN))
subsizer.Add(self._chmPathCtrl, (3, 1), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
subsizer.Add(self._chmPathBt, (3, 2), flag=wx.ALIGN_CENTER_VERTICAL)
self.Bind(wx.EVT_BUTTON, self.OnBrowsePath, self._chmPathBt)
wx.EVT_BUTTON(self._chmPathBt, self._chmPathBt.GetId(), self.OnBrowsePath)
subsizer.Add(wx.StaticText(panel, -1, "Output Location : "), (4, 0), flag=wx.ALIGN_CENTER_VERTICAL)
self._outputPathCtrl = wx.ComboBox(panel, -1)
@@ -130,9 +130,9 @@ class PackageDocMainFrame(wx.Frame):
self._outputPathCtrl.SetValue(list[len(list) - 1])
subsizer.Add(self._outputPathCtrl, (4, 1), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
self._outputPathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN))
self._outputPathBt = wx.BitmapButton(panel, -1, bitmap=wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN))
subsizer.Add(self._outputPathBt, (4, 2), flag=wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
self.Bind(wx.EVT_BUTTON, self.OnBrowsePath, self._outputPathBt)
wx.EVT_BUTTON(self._outputPathBt, self._outputPathBt.GetId(), self.OnBrowsePath)
subsizer.Add(wx.StaticText(panel, -1, "Architecture Specified : "), (5, 0), flag=wx.ALIGN_CENTER_VERTICAL)
self._archCtrl = wx.ComboBox(panel, -1, value='ALL', choices=['ALL', 'IA32/MSFT', 'IA32/GNU', 'X64/INTEL', 'X64/GNU', 'IPF/MSFT', 'IPF/GNU', 'EBC/INTEL'],
@@ -164,7 +164,7 @@ class PackageDocMainFrame(wx.Frame):
def SaveConfigure(self, name, value):
if value ==None or len(value) == 0:
return
config = wx.ConfigBase.Get()
config = wx.ConfigBase_Get()
oldvalues = config.Read(name, '').split(';')
if len(oldvalues) >= 10:
oldvalues.remove(oldvalues[0])
@@ -177,7 +177,7 @@ class PackageDocMainFrame(wx.Frame):
config.Write(name, ';'.join(oldvalues))
def GetConfigure(self, name):
config = wx.ConfigBase.Get()
config = wx.ConfigBase_Get()
values = config.Read(name, '').split(';')
list = []
for item in values:
@@ -416,10 +416,10 @@ class ProgressDialog(wx.Dialog):
logging.getLogger('').addHandler(self._loghandle)
logging.getLogger('app').addHandler(self._loghandle)
self.Bind(wx.EVT_BUTTON, self.OnButtonClose, self._closeBt)
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateCloseButton)
self.Bind(wx.EVT_BUTTON, self.OnGotoOutput, self._gotoOuputBt)
self.Bind(EVT_LOG, self.OnPostLog)
wx.EVT_BUTTON(self._closeBt, self._closeBt.GetId(), self.OnButtonClose)
wx.EVT_UPDATE_UI(self, self._closeBt.GetId(), self.OnUpdateCloseButton)
wx.EVT_BUTTON(self._gotoOuputBt, self._gotoOuputBt.GetId(), self.OnGotoOutput)
EVT_LOG(self, self.OnPostLog)
self._process = None
self._pid = None
@@ -720,7 +720,7 @@ class ProgressDialog(wx.Dialog):
lines = f.readlines()
f.close()
bfound = False
for index in range(len(lines)):
for index in xrange(len(lines)):
if lines[index].find('<a class="el" href="files.html" target="basefrm">File List</a>') != -1:
lines[index] = "<!-- %s" % lines[index]
bfound = True
@@ -745,7 +745,7 @@ class ProgressDialog(wx.Dialog):
lines = f.readlines()
f.close()
bfound = False
for index in range(len(lines)):
for index in xrange(len(lines)):
if not bfound:
if lines[index].find('<param name="Local" value="files.html">') != -1:
lines[index] = '<!-- %s' % lines[index]
@@ -969,7 +969,7 @@ class ProgressDialog(wx.Dialog):
fd = open(path, 'r')
text = fd.read()
fd.close()
except Exception as e:
except Exception, e:
self.LogMessage (" <<<Fail to open file %s" % path)
return
text = text.replace ('.s.dox', '.s')
@@ -982,7 +982,7 @@ class ProgressDialog(wx.Dialog):
fd = open(path, 'w')
fd.write(text)
fd.close()
except Exception as e:
except Exception, e:
self.LogMessage (" <<<Fail to fixup file %s" % path)
return
self.LogMessage(' >>> Finish to fixup .dox postfix for file %s \n' % path)
@@ -993,7 +993,7 @@ class ProgressDialog(wx.Dialog):
fd = open(path, 'r')
lines = fd.readlines()
fd.close()
except Exception as e:
except Exception, e:
self.LogMessage (" <<<Fail to open file %s" % path)
return
for line in lines:
@@ -1004,7 +1004,7 @@ class ProgressDialog(wx.Dialog):
fd = open(path, 'w')
fd.write("".join(lines))
fd.close()
except Exception as e:
except Exception, e:
self.LogMessage (" <<<Fail to fixup file %s" % path)
return
self.LogMessage(' >>> Finish to fixup .decdoxygen postfix for file %s \n' % path)

View File

@@ -11,6 +11,8 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from __future__ import print_function
from __future__ import absolute_import
import os
from .message import *
@@ -65,7 +67,7 @@ class Page(BaseDoxygeItem):
def AddSection(self, section):
self.mSections.append(section)
self.mSections.sort(key=lambda x: x.mName.lower())
self.mSections.sort(cmp=lambda x, y: cmp(x.mName.lower(), y.mName.lower()))
def Generate(self):
if self.mIsMainPage:
@@ -78,7 +80,7 @@ class Page(BaseDoxygeItem):
self.mText.append(self.mDescription)
endIndex = len(self.mText)
self.mSections.sort(key=lambda x: x.mName.lower())
self.mSections.sort()
for sect in self.mSections:
self.mText += sect.Generate()
@@ -90,7 +92,7 @@ class Page(BaseDoxygeItem):
self.mText.insert(endIndex, '<ul>')
endIndex += 1
if self.mIsSort:
self.mSubPages.sort(key=lambda x: x.mName.lower())
self.mSubPages.sort(cmp=lambda x, y: cmp(x.mName.lower(), y.mName.lower()))
for page in self.mSubPages:
self.mText.insert(endIndex, '<li>\subpage %s \"%s\" </li>' % (page.mTag, page.mName))
endIndex += 1

View File

@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from __future__ import print_function
import array
import uuid
import re

View File

@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from __future__ import absolute_import
from .message import *
import re
import os
@@ -24,7 +25,7 @@ class BaseINIFile(object):
@return: instance of this class
"""
if len(args) == 0: return object.__new__(cls)
if len(args) == 0: return object.__new__(cls, *args, **kwargs)
filename = args[0]
parent = None
if len(args) > 1:
@@ -32,7 +33,7 @@ class BaseINIFile(object):
key = os.path.normpath(filename)
if key not in cls._objs.keys():
cls._objs[key] = object.__new__(cls)
cls._objs[key] = object.__new__(cls, *args, **kwargs)
if parent is not None:
cls._objs[key].AddParent(parent)

View File

@@ -10,12 +10,12 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
from ...basemodel import ini as ini
from ..model import dsc as dsc
from ..model import inf as inf
from ..model import dec as dec
import plugins.EdkPlugins.basemodel.ini as ini
import plugins.EdkPlugins.edk2.model.dsc as dsc
import plugins.EdkPlugins.edk2.model.inf as inf
import plugins.EdkPlugins.edk2.model.dec as dec
import os
from ...basemodel.message import *
from plugins.EdkPlugins.basemodel.message import *
class SurfaceObject(object):
_objs = {}
@@ -25,7 +25,7 @@ class SurfaceObject(object):
@return: instance of this class
"""
obj = object.__new__(cls)
obj = object.__new__(cls, *args, **kwargs)
if "None" not in cls._objs:
cls._objs["None"] = []
cls._objs["None"].append(obj)
@@ -846,7 +846,7 @@ class SurfaceItem(object):
ErrorMsg("%s item is duplicated defined in packages: %s and %s" %
(name, parent.GetFilename(), cls._objs[name].GetParent().GetFilename()))
return None
obj = object.__new__(cls)
obj = object.__new__(cls, *args, **kwargs)
cls._objs[name] = obj
return obj
elif issubclass(parent.__class__, Module):

View File

@@ -11,9 +11,9 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from ...basemodel import ini
import plugins.EdkPlugins.basemodel.ini as ini
import re, os
from ...basemodel.message import *
from plugins.EdkPlugins.basemodel.message import *
class DECFile(ini.BaseINIFile):

View File

@@ -16,7 +16,7 @@
"""This file produce action class to generate doxygen document for edk2 codebase.
The action classes are shared by GUI and command line tools.
"""
from ...basemodel import doxygen
import plugins.EdkPlugins.basemodel.doxygen as doxygen
import os
try:
import wx
@@ -24,9 +24,9 @@ try:
except:
gInGui = False
import re
from ..model import inf
from ..model import dec
from ...basemodel.message import *
import plugins.EdkPlugins.edk2.model.inf as inf
import plugins.EdkPlugins.edk2.model.dec as dec
from plugins.EdkPlugins.basemodel.message import *
_ignore_dir = ['.svn', '_svn', 'cvs']
_inf_key_description_mapping_table = {
@@ -386,7 +386,7 @@ class PackageDocumentAction(DoxygenAction):
configFile.AddFile(path)
no = 0
for no in range(len(lines)):
for no in xrange(len(lines)):
if len(lines[no].strip()) == 0:
continue
if lines[no].strip()[:2] in ['##', '//', '/*', '*/']:
@@ -1000,7 +1000,7 @@ class PackageDocumentAction(DoxygenAction):
#file = textfile.TextFile(path)
try:
file = open(path, 'r')
file = open(path, 'rb')
except (IOError, OSError) as msg:
return None

View File

@@ -13,7 +13,7 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
from ...basemodel import doxygen
import plugins.EdkPlugins.basemodel.doxygen as doxygen
import os
try:
import wx
@@ -21,9 +21,9 @@ try:
except:
gInGui = False
import re
from ..model import inf
from ..model import dec
from ...basemodel.message import *
import plugins.EdkPlugins.edk2.model.inf as inf
import plugins.EdkPlugins.edk2.model.dec as dec
from plugins.EdkPlugins.basemodel.message import *
_ignore_dir = ['.svn', '_svn', 'cvs']
_inf_key_description_mapping_table = {
@@ -388,7 +388,7 @@ class PackageDocumentAction(DoxygenAction):
configFile.AddFile(path)
return
no = 0
for no in range(len(lines)):
for no in xrange(len(lines)):
if len(lines[no].strip()) == 0:
continue
if lines[no].strip()[:2] in ['##', '//', '/*', '*/']:
@@ -1003,7 +1003,7 @@ class PackageDocumentAction(DoxygenAction):
#file = textfile.TextFile(path)
try:
file = open(path, 'r')
file = open(path, 'rb')
except (IOError, OSError) as msg:
return None

View File

@@ -11,9 +11,9 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from ...basemodel import ini
import plugins.EdkPlugins.basemodel.ini as ini
import re, os
from ...basemodel.message import *
from plugins.EdkPlugins.basemodel.message import *
class DSCFile(ini.BaseINIFile):
def GetSectionInstance(self, parent, name, isCombined=False):

View File

@@ -11,9 +11,9 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
from ...basemodel import ini
import plugins.EdkPlugins.basemodel.ini as ini
import re, os
from ...basemodel.message import *
from plugins.EdkPlugins.basemodel.message import *
class INFFile(ini.BaseINIFile):
_libobjs = {}