* [PATCH v2 00/16] BaseTools: Adopt absolute import
@ 2018-07-13 10:18 Gary Lin
2018-07-13 10:18 ` [PATCH v2 01/16] BaseTools: Treat GenFds.py as a python module Gary Lin
` (16 more replies)
0 siblings, 17 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
v2:
Treat BPDG and Ecc as python modules since they use the modules in
its own directory
This patch series is based on "libfuturize.fixes.fix_absolute_import"
to adopt abolute import since relative import is not allowed in python3.
The command is applied to BaseTools modules individually. Most of the
patches are straightforward except the GenFds patches. It's because
there are several circular imports in GenFds and circular import is not
compatible with absolute import. To make the patches bisectable, I delay
the import of some modules in the first GenFds patch and refactor the
code in the follow-up patches to remove circular import completely.
The patch set is also available in my github branch:
https://github.com/lcp/edk2/tree/python3-absolute-import-v2
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>
Gary Lin (16):
BaseTools: Treat GenFds.py as a python module
BaseTools: Use absolute import in GenFds
BaseTools: Move OverrideAttribs to OptRomInfStatement.py
BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py
BaseTools: Move ImageBinDict to GenFdsGlobalVariable.py
BaseTools: Use absolute import in AutoGen
BaseTools: Treat BPDG.py as a python module
BaseTools: Use absolute import in BPDG
BaseTools: Use absolute import in Common
BaseTools: Treat Ecc.py as a python module
BaseTools: Use absolute import in Ecc
BaseTools: Use absolute import in Eot
BaseTools: Use absolute import in Table
BaseTools: Use absolute import in UPT
BaseTools: Use absolute import in Workspace
BaseTools: Use absolute import in Scripts
BaseTools/BinWrappers/PosixLike/BPDG | 2 +-
BaseTools/BinWrappers/PosixLike/Ecc | 2 +-
BaseTools/BinWrappers/PosixLike/GenFds | 2 +-
BaseTools/BinWrappers/WindowsLike/BPDG.bat | 3 +-
BaseTools/BinWrappers/WindowsLike/Ecc.bat | 3 +-
BaseTools/BinWrappers/WindowsLike/GenFds.bat | 3 +-
.../plugins/EdkPlugins/basemodel/doxygen.py | 3 +-
.../plugins/EdkPlugins/basemodel/ini.py | 3 +-
BaseTools/Source/Python/AutoGen/AutoGen.py | 17 +--
BaseTools/Source/Python/AutoGen/GenC.py | 7 +-
BaseTools/Source/Python/AutoGen/GenMake.py | 3 +-
BaseTools/Source/Python/AutoGen/GenPcdDb.py | 7 +-
.../Source/Python/AutoGen/IdfClassObject.py | 3 +-
BaseTools/Source/Python/AutoGen/StrGather.py | 3 +-
BaseTools/Source/Python/BPDG/BPDG.py | 5 +-
BaseTools/Source/Python/BPDG/GenVpd.py | 3 +-
BaseTools/Source/Python/Common/Database.py | 8 +-
BaseTools/Source/Python/Common/EdkLogger.py | 3 +-
BaseTools/Source/Python/Common/Expression.py | 3 +-
.../Source/Python/Common/LongFilePathOs.py | 3 +-
BaseTools/Source/Python/Common/Misc.py | 9 +-
BaseTools/Source/Python/Common/Parsing.py | 5 +-
BaseTools/Source/Python/Common/StringUtils.py | 9 +-
.../Python/Common/TargetTxtClassObject.py | 9 +-
.../Python/Common/ToolDefClassObject.py | 9 +-
BaseTools/Source/Python/Ecc/CParser.py | 5 +-
BaseTools/Source/Python/Ecc/Check.py | 9 +-
.../Python/Ecc/CodeFragmentCollector.py | 13 ++-
BaseTools/Source/Python/Ecc/Database.py | 7 +-
BaseTools/Source/Python/Ecc/Ecc.py | 25 +++--
BaseTools/Source/Python/Ecc/Exception.py | 3 +-
BaseTools/Source/Python/Ecc/FileProfile.py | 5 +-
BaseTools/Source/Python/Ecc/MetaDataParser.py | 5 +-
.../Ecc/MetaFileWorkspace/MetaFileParser.py | 3 +-
.../Ecc/MetaFileWorkspace/MetaFileTable.py | 5 +-
BaseTools/Source/Python/Ecc/c.py | 13 ++-
BaseTools/Source/Python/Eot/CParser.py | 5 +-
.../Python/Eot/CodeFragmentCollector.py | 11 +-
BaseTools/Source/Python/Eot/Eot.py | 21 ++--
BaseTools/Source/Python/Eot/FileProfile.py | 3 +-
BaseTools/Source/Python/Eot/InfParserLite.py | 5 +-
BaseTools/Source/Python/Eot/Parser.py | 3 +-
BaseTools/Source/Python/Eot/Report.py | 3 +-
BaseTools/Source/Python/Eot/c.py | 9 +-
.../Source/Python/GenFds/AprioriSection.py | 5 +-
BaseTools/Source/Python/GenFds/Capsule.py | 12 +-
BaseTools/Source/Python/GenFds/CapsuleData.py | 5 +-
.../Source/Python/GenFds/CompressSection.py | 7 +-
BaseTools/Source/Python/GenFds/DataSection.py | 7 +-
.../Source/Python/GenFds/DepexSection.py | 7 +-
BaseTools/Source/Python/GenFds/EfiSection.py | 7 +-
BaseTools/Source/Python/GenFds/Fd.py | 22 ++--
BaseTools/Source/Python/GenFds/FdfParser.py | 57 +++++-----
.../Source/Python/GenFds/FfsFileStatement.py | 11 +-
.../Source/Python/GenFds/FfsInfStatement.py | 19 ++--
BaseTools/Source/Python/GenFds/Fv.py | 20 ++--
.../Source/Python/GenFds/FvImageSection.py | 7 +-
BaseTools/Source/Python/GenFds/GenFds.py | 105 +-----------------
.../Python/GenFds/GenFdsGlobalVariable.py | 97 +++++++++++++++-
BaseTools/Source/Python/GenFds/GuidSection.py | 11 +-
.../Python/GenFds/OptRomFileStatement.py | 3 +-
.../Python/GenFds/OptRomInfStatement.py | 27 +++--
BaseTools/Source/Python/GenFds/OptionRom.py | 6 +-
BaseTools/Source/Python/GenFds/Region.py | 3 +-
.../Source/Python/GenFds/RuleComplexFile.py | 3 +-
.../Source/Python/GenFds/RuleSimpleFile.py | 3 +-
BaseTools/Source/Python/GenFds/Section.py | 3 +-
BaseTools/Source/Python/GenFds/UiSection.py | 7 +-
BaseTools/Source/Python/GenFds/VerSection.py | 7 +-
BaseTools/Source/Python/GenFds/Vtf.py | 3 +-
.../Source/Python/Table/TableDataModel.py | 3 +-
BaseTools/Source/Python/Table/TableDec.py | 3 +-
BaseTools/Source/Python/Table/TableDsc.py | 3 +-
.../Source/Python/Table/TableEotReport.py | 3 +-
BaseTools/Source/Python/Table/TableFdf.py | 3 +-
BaseTools/Source/Python/Table/TableFile.py | 3 +-
.../Source/Python/Table/TableFunction.py | 3 +-
.../Source/Python/Table/TableIdentifier.py | 3 +-
BaseTools/Source/Python/Table/TableInf.py | 3 +-
BaseTools/Source/Python/Table/TablePcd.py | 3 +-
BaseTools/Source/Python/Table/TableQuery.py | 3 +-
BaseTools/Source/Python/Table/TableReport.py | 3 +-
.../Source/Python/UPT/Library/Parsing.py | 3 +-
.../Source/Python/Workspace/DscBuildData.py | 9 +-
.../Source/Python/Workspace/InfBuildData.py | 3 +-
.../Source/Python/Workspace/MetaFileParser.py | 5 +-
.../Source/Python/Workspace/MetaFileTable.py | 5 +-
.../Python/Workspace/WorkspaceCommon.py | 3 +-
.../Python/Workspace/WorkspaceDatabase.py | 7 +-
89 files changed, 452 insertions(+), 363 deletions(-)
--
2.18.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 01/16] BaseTools: Treat GenFds.py as a python module
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 02/16] BaseTools: Use absolute import in GenFds Gary Lin
` (15 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Since GenFds.py import modules from its own directory, add "-m" to the
python parameters so that they can import its own modules after adopting
absolute import.
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>
---
BaseTools/BinWrappers/PosixLike/GenFds | 2 +-
BaseTools/BinWrappers/WindowsLike/GenFds.bat | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/BaseTools/BinWrappers/PosixLike/GenFds b/BaseTools/BinWrappers/PosixLike/GenFds
index 01ae23ddeb4f..276c7ea20733 100755
--- a/BaseTools/BinWrappers/PosixLike/GenFds
+++ b/BaseTools/BinWrappers/PosixLike/GenFds
@@ -11,4 +11,4 @@ dir=$(dirname "$full_cmd")
cmd=${full_cmd##*/}
export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
-exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
+exec "${python_exe:-python}" -m $cmd.$cmd "$@"
diff --git a/BaseTools/BinWrappers/WindowsLike/GenFds.bat b/BaseTools/BinWrappers/WindowsLike/GenFds.bat
index 9fbb704a6eb0..98095cfbd439 100644
--- a/BaseTools/BinWrappers/WindowsLike/GenFds.bat
+++ b/BaseTools/BinWrappers/WindowsLike/GenFds.bat
@@ -1,3 +1,4 @@
@setlocal
@set ToolName=%~n0%
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
+@set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python
+@%PYTHON_HOME%\python.exe -m %ToolName%.%ToolName% %*
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 02/16] BaseTools: Use absolute import in GenFds
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
2018-07-13 10:18 ` [PATCH v2 01/16] BaseTools: Treat GenFds.py as a python module Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 03/16] BaseTools: Move OverrideAttribs to OptRomInfStatement.py Gary Lin
` (14 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Based on "futurize -f libfuturize.fixes.fix_absolute_import"
Since circular import is not allowed after adopting absolute import, the
following changes are applied to break the circles.
* BaseTools/Source/Python/GenFds/Capsule.py
- Delay "from .GenFds import GenFds" until GenCapsule()
- Delay "from .GenFds import FindExtendTool" until GenFmpCapsule()
To break the circle:
AutoGen.AutoGen => GenFds.FdfParser => GenFds.Capsule => GenFds.GenFds =>
GenFds.FdfParser
* BaseTools/Source/Python/GenFds/Fd.py
- Delay "from .GenFds import GenFds" until GenFd()
To break the circle:
AutoGen.AutoGen => GenFds.FdfParser => GenFds.Fd => GenFds.GenFds =>
GenFds.FdfParser
* BaseTools/Source/Python/GenFds/Fv.py
- Delay "from .GenFds import GenFds" until AddToBuffer()
To break the circle:
AutoGen.AutoGen => GenFds.FdfParser => GenFds.Fd => GenFds.Fv =>
GenFds.GenFds => GenFds.FdfParser
* BaseTools/Source/Python/GenFds/GuidSection.py
- Delay "from .GenFds import FindExtendTool" until GuidSection()
To break the circle:
AutoGen.AutoGen => GenFds.FdfParser => GenFds.Fd => GenFds.Fv =>
GenFds.AprioriSection => GenFds.FfsFileStatement => GenFds.GuidSection =>
GenFds.GenFds => GenFds.FdfParser
* BaseTools/Source/Python/GenFds/OptRomInfStatement.py
- Delay "from . import OptionRom" until __GetOptRomParams()
To break the circle:
AutoGen.AutoGen => GenFds.FdfParser => GenFds.OptionRom =>
GenFds.OptRomInfStatement => GenFds.OptionRom
* BaseTools/Source/Python/GenFds/OptionRom.py
- Remove the unused "from GenFds import GenFds"
To break the circle:
AutoGen.AutoGen => GenFds.FdfParser => GenFds.OptionRom =>
GenFds.GenFds => GenFds.FdfParser
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>
---
BaseTools/Source/Python/GenFds/AprioriSection.py | 5 +-
BaseTools/Source/Python/GenFds/Capsule.py | 7 +--
BaseTools/Source/Python/GenFds/CapsuleData.py | 5 +-
BaseTools/Source/Python/GenFds/CompressSection.py | 7 +--
BaseTools/Source/Python/GenFds/DataSection.py | 7 +--
BaseTools/Source/Python/GenFds/DepexSection.py | 7 +--
BaseTools/Source/Python/GenFds/EfiSection.py | 7 +--
BaseTools/Source/Python/GenFds/Fd.py | 9 ++--
BaseTools/Source/Python/GenFds/FdfParser.py | 55 ++++++++++----------
BaseTools/Source/Python/GenFds/FfsFileStatement.py | 11 ++--
BaseTools/Source/Python/GenFds/FfsInfStatement.py | 19 +++----
BaseTools/Source/Python/GenFds/Fv.py | 11 ++--
BaseTools/Source/Python/GenFds/FvImageSection.py | 7 +--
BaseTools/Source/Python/GenFds/GenFds.py | 11 ++--
BaseTools/Source/Python/GenFds/GuidSection.py | 11 ++--
BaseTools/Source/Python/GenFds/OptRomFileStatement.py | 3 +-
BaseTools/Source/Python/GenFds/OptRomInfStatement.py | 16 +++---
BaseTools/Source/Python/GenFds/OptionRom.py | 6 +--
BaseTools/Source/Python/GenFds/Region.py | 3 +-
BaseTools/Source/Python/GenFds/RuleComplexFile.py | 3 +-
BaseTools/Source/Python/GenFds/RuleSimpleFile.py | 3 +-
BaseTools/Source/Python/GenFds/Section.py | 3 +-
BaseTools/Source/Python/GenFds/UiSection.py | 7 +--
BaseTools/Source/Python/GenFds/VerSection.py | 7 +--
BaseTools/Source/Python/GenFds/Vtf.py | 3 +-
25 files changed, 127 insertions(+), 106 deletions(-)
diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/Source/Python/GenFds/AprioriSection.py
index b3e7b5fc64a3..7196f7f2c753 100644
--- a/BaseTools/Source/Python/GenFds/AprioriSection.py
+++ b/BaseTools/Source/Python/GenFds/AprioriSection.py
@@ -15,11 +15,12 @@
##
# Import Modules
#
+from __future__ import absolute_import
from struct import *
import Common.LongFilePathOs as os
from io import BytesIO
-import FfsFileStatement
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from . import FfsFileStatement
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from CommonDataClass.FdfClass import AprioriSectionClassObject
from Common.StringUtils import *
from Common.Misc import SaveFileOnChange, PathClass
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py
index 35a25bd38037..27932ef0020c 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -15,17 +15,16 @@
##
# Import Modules
#
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from __future__ import absolute_import
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from CommonDataClass.FdfClass import CapsuleClassObject
import Common.LongFilePathOs as os
import subprocess
from io import BytesIO
from Common.Misc import SaveFileOnChange
-from GenFds import GenFds
from Common.Misc import PackRegistryFormatGuid
import uuid
from struct import pack
-from GenFds import FindExtendTool
from Common import EdkLogger
from Common.BuildToolError import *
@@ -66,6 +65,7 @@ class Capsule (CapsuleClassObject) :
# UINT32 CapsuleImageSize;
# } EFI_CAPSULE_HEADER;
#
+ from .GenFds import FindExtendTool
Header = BytesIO()
#
# Use FMP capsule GUID: 6DCBD5ED-E82D-4C44-BDA1-7194199AD92A
@@ -201,6 +201,7 @@ class Capsule (CapsuleClassObject) :
# @retval string Generated Capsule file path
#
def GenCapsule(self):
+ from .GenFds import GenFds
if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict:
return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap']
diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/Python/GenFds/CapsuleData.py
index 9d17bf5afe28..0caba8983d2e 100644
--- a/BaseTools/Source/Python/GenFds/CapsuleData.py
+++ b/BaseTools/Source/Python/GenFds/CapsuleData.py
@@ -15,8 +15,9 @@
##
# Import Modules
#
-import Ffs
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from __future__ import absolute_import
+from . import Ffs
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from io import BytesIO
from struct import pack
import os
diff --git a/BaseTools/Source/Python/GenFds/CompressSection.py b/BaseTools/Source/Python/GenFds/CompressSection.py
index 4ae14f27b3e1..aaaabf84dca8 100644
--- a/BaseTools/Source/Python/GenFds/CompressSection.py
+++ b/BaseTools/Source/Python/GenFds/CompressSection.py
@@ -15,11 +15,12 @@
##
# Import Modules
#
-from Ffs import Ffs
-import Section
+from __future__ import absolute_import
+from .Ffs import Ffs
+from . import Section
import subprocess
import Common.LongFilePathOs as os
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from CommonDataClass.FdfClass import CompressSectionClassObject
from Common.DataType import *
diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py
index 29caa00c0d8d..a6387b07c582 100644
--- a/BaseTools/Source/Python/GenFds/DataSection.py
+++ b/BaseTools/Source/Python/GenFds/DataSection.py
@@ -15,10 +15,11 @@
##
# Import Modules
#
-import Section
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from __future__ import absolute_import
+from . import Section
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
import subprocess
-from Ffs import Ffs
+from .Ffs import Ffs
import Common.LongFilePathOs as os
from CommonDataClass.FdfClass import DataSectionClassObject
from Common.Misc import PeImageClass
diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Source/Python/GenFds/DepexSection.py
index f42162d5a27e..b2d123bfc045 100644
--- a/BaseTools/Source/Python/GenFds/DepexSection.py
+++ b/BaseTools/Source/Python/GenFds/DepexSection.py
@@ -15,10 +15,11 @@
##
# Import Modules
#
-import Section
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from __future__ import absolute_import
+from . import Section
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
import subprocess
-from Ffs import Ffs
+from .Ffs import Ffs
import Common.LongFilePathOs as os
from CommonDataClass.FdfClass import DepexSectionClassObject
from AutoGen.GenDepex import DependencyExpression
diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py
index 9223268749a1..623b77d27427 100644
--- a/BaseTools/Source/Python/GenFds/EfiSection.py
+++ b/BaseTools/Source/Python/GenFds/EfiSection.py
@@ -15,11 +15,12 @@
##
# Import Modules
#
+from __future__ import absolute_import
from struct import *
-import Section
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from . import Section
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
import subprocess
-from Ffs import Ffs
+from .Ffs import Ffs
import Common.LongFilePathOs as os
from CommonDataClass.FdfClass import EfiSectionClassObject
from Common import EdkLogger
diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py
index 552719fa3114..53318c9ea5c0 100644
--- a/BaseTools/Source/Python/GenFds/Fd.py
+++ b/BaseTools/Source/Python/GenFds/Fd.py
@@ -15,18 +15,18 @@
##
# Import Modules
#
-import Region
-import Fv
+from __future__ import absolute_import
+from . import Region
+from . import Fv
import Common.LongFilePathOs as os
from io import BytesIO
import sys
from struct import *
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from CommonDataClass.FdfClass import FDClassObject
from Common import EdkLogger
from Common.BuildToolError import *
from Common.Misc import SaveFileOnChange
-from GenFds import GenFds
from Common.DataType import BINARY_FILE_TYPE_FV
## generate FD
@@ -47,6 +47,7 @@ class FD(FDClassObject):
# @retval string Generated FD file name
#
def GenFd (self, Flag = False):
+ from .GenFds import GenFds
if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict:
return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd']
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 67217c3b89e3..c890f2d3afb6 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -17,35 +17,36 @@
# Import Modules
#
from __future__ import print_function
+from __future__ import absolute_import
import re
-import Fd
-import Region
-import Fv
-import AprioriSection
-import FfsInfStatement
-import FfsFileStatement
-import VerSection
-import UiSection
-import FvImageSection
-import DataSection
-import DepexSection
-import CompressSection
-import GuidSection
-import Capsule
-import CapsuleData
-import Rule
-import RuleComplexFile
-import RuleSimpleFile
-import EfiSection
-import Vtf
-import ComponentStatement
-import OptionRom
-import OptRomInfStatement
-import OptRomFileStatement
+from . import Fd
+from . import Region
+from . import Fv
+from . import AprioriSection
+from . import FfsInfStatement
+from . import FfsFileStatement
+from . import VerSection
+from . import UiSection
+from . import FvImageSection
+from . import DataSection
+from . import DepexSection
+from . import CompressSection
+from . import GuidSection
+from . import Capsule
+from . import CapsuleData
+from . import Rule
+from . import RuleComplexFile
+from . import RuleSimpleFile
+from . import EfiSection
+from . import Vtf
+from . import ComponentStatement
+from . import OptionRom
+from . import OptRomInfStatement
+from . import OptRomFileStatement
import string
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from Common.BuildToolError import *
from Common import EdkLogger
from Common.Misc import PathClass
@@ -60,8 +61,8 @@ from Common.Misc import tdict
from Common.MultipleWorkspace import MultipleWorkspace as mws
import Common.LongFilePathOs as os
from Common.LongFilePathSupport import OpenLongFilePath as open
-from Capsule import EFI_CERT_TYPE_PKCS7_GUID
-from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID
+from .Capsule import EFI_CERT_TYPE_PKCS7_GUID
+from .Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID
from Common.RangeExpression import RangeExpression
##define T_CHAR_SPACE ' '
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
index 5f31ac03fcf4..4c35aac76a00 100644
--- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
@@ -15,19 +15,20 @@
##
# Import Modules
#
-import Ffs
-import Rule
+from __future__ import absolute_import
+from . import Ffs
+from . import Rule
import Common.LongFilePathOs as os
from io import BytesIO
import subprocess
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from CommonDataClass.FdfClass import FileStatementClassObject
from Common import EdkLogger
from Common.BuildToolError import *
from Common.Misc import GuidStructureByteArrayToGuidString
-from GuidSection import GuidSection
-from FvImageSection import FvImageSection
+from .GuidSection import GuidSection
+from .FvImageSection import FvImageSection
from Common.Misc import SaveFileOnChange
from struct import *
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index adb9a95bebfa..56bb966698ad 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -16,17 +16,18 @@
##
# Import Modules
#
-import Rule
+from __future__ import absolute_import
+from . import Rule
import Common.LongFilePathOs as os
from io import BytesIO
from struct import *
-from GenFdsGlobalVariable import GenFdsGlobalVariable
-import Ffs
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
+from . import Ffs
import subprocess
import sys
-import Section
-import RuleSimpleFile
-import RuleComplexFile
+from . import Section
+from . import RuleSimpleFile
+from . import RuleComplexFile
from CommonDataClass.FdfClass import FfsInfStatementClassObject
from Common.MultipleWorkspace import MultipleWorkspace as mws
from Common.StringUtils import *
@@ -36,15 +37,15 @@ from Common.Misc import ProcessDuplicatedInf
from Common.Misc import GetVariableOffset
from Common import EdkLogger
from Common.BuildToolError import *
-from GuidSection import GuidSection
-from FvImageSection import FvImageSection
+from .GuidSection import GuidSection
+from .FvImageSection import FvImageSection
from Common.Misc import PeImageClass
from AutoGen.GenDepex import DependencyExpression
from PatchPcdValue.PatchPcdValue import PatchBinaryFile
from Common.LongFilePathSupport import CopyLongFilePath
from Common.LongFilePathSupport import OpenLongFilePath as open
import Common.GlobalData as GlobalData
-from DepexSection import DepexSection
+from .DepexSection import DepexSection
from Common.Misc import SaveFileOnChange
from Common.Expression import *
from Common.DataType import *
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index 798c20a0f4ee..097f51f39e27 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
## @file
# process FV generation
#
@@ -20,11 +21,10 @@ import subprocess
from io import BytesIO
from struct import *
-import Ffs
-import AprioriSection
-import FfsFileStatement
-from GenFdsGlobalVariable import GenFdsGlobalVariable
-from GenFds import GenFds
+from . import Ffs
+from . import AprioriSection
+from . import FfsFileStatement
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from CommonDataClass.FdfClass import FvClassObject
from Common.Misc import SaveFileOnChange, PackGUID
from Common.LongFilePathSupport import CopyLongFilePath
@@ -70,6 +70,7 @@ class FV (FvClassObject):
#
def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :
+ from .GenFds import GenFds
if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict:
return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv']
diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py
index b4f1f3340e99..04556fc87099 100644
--- a/BaseTools/Source/Python/GenFds/FvImageSection.py
+++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
@@ -15,11 +15,12 @@
##
# Import Modules
#
-import Section
+from __future__ import absolute_import
+from . import Section
from io import BytesIO
-from Ffs import Ffs
+from .Ffs import Ffs
import subprocess
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
import Common.LongFilePathOs as os
from CommonDataClass.FdfClass import FvImageSectionClassObject
from Common import EdkLogger
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index b90b50e53967..c0b60b9b3c1f 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -16,17 +16,18 @@
# Import Modules
#
from __future__ import print_function
+from __future__ import absolute_import
from optparse import OptionParser
import sys
import Common.LongFilePathOs as os
import linecache
-import FdfParser
+from . import FdfParser
import Common.BuildToolError as BuildToolError
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from Workspace.WorkspaceDatabase import WorkspaceDatabase
from Workspace.BuildClassObject import PcdClassObject
-import RuleComplexFile
-from EfiSection import EfiSection
+from . import RuleComplexFile
+from .EfiSection import EfiSection
from io import BytesIO
import Common.TargetTxtClassObject as TargetTxtClassObject
import Common.ToolDefClassObject as ToolDefClassObject
@@ -40,7 +41,7 @@ from Common.Misc import ClearDuplicatedInf
from Common.Misc import GuidStructureStringToGuidString
from Common.BuildVersion import gBUILD_VERSION
from Common.MultipleWorkspace import MultipleWorkspace as mws
-import FfsFileStatement
+from . import FfsFileStatement
import glob
from struct import unpack
diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Source/Python/GenFds/GuidSection.py
index c55fb34f2b74..e41c2fd31e6c 100644
--- a/BaseTools/Source/Python/GenFds/GuidSection.py
+++ b/BaseTools/Source/Python/GenFds/GuidSection.py
@@ -16,19 +16,19 @@
##
# Import Modules
#
-import Section
+from __future__ import absolute_import
+from . import Section
import subprocess
-from Ffs import Ffs
+from .Ffs import Ffs
import Common.LongFilePathOs as os
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from CommonDataClass.FdfClass import GuidSectionClassObject
from Common import ToolDefClassObject
import sys
from Common import EdkLogger
from Common.BuildToolError import *
-from FvImageSection import FvImageSection
+from .FvImageSection import FvImageSection
from Common.LongFilePathSupport import OpenLongFilePath as open
-from GenFds import FindExtendTool
from Common.DataType import *
## generate GUIDed section
@@ -131,6 +131,7 @@ class GuidSection(GuidSectionClassObject) :
ExternalTool = None
ExternalOption = None
if self.NameGuid is not None:
+ from .GenFds import FindExtendTool
ExternalTool, ExternalOption = FindExtendTool(self.KeyStringList, self.CurrentArchList, self.NameGuid)
#
diff --git a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py
index 8b6d2a1cb0bd..e56174ec3c86 100644
--- a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py
+++ b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py
@@ -15,9 +15,10 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
##
#
#
diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
index dff8235ef755..dfeba5d0b140 100644
--- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
@@ -15,16 +15,16 @@
##
# Import Modules
#
-import RuleSimpleFile
-import RuleComplexFile
-import Section
-import OptionRom
+from __future__ import absolute_import
+from . import RuleSimpleFile
+from . import RuleComplexFile
+from . import Section
import Common.GlobalData as GlobalData
from Common.DataType import *
from Common.StringUtils import *
-from FfsInfStatement import FfsInfStatement
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .FfsInfStatement import FfsInfStatement
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
##
#
@@ -45,7 +45,7 @@ class OptRomInfStatement (FfsInfStatement):
# @param self The object pointer
#
def __GetOptRomParams(self):
-
+ from . import OptionRom
if self.OverrideAttribs is None:
self.OverrideAttribs = OptionRom.OverrideAttribs()
@@ -150,5 +150,3 @@ class OptRomInfStatement (FfsInfStatement):
OutputFileList.extend(FileList)
return OutputFileList
-
-
diff --git a/BaseTools/Source/Python/GenFds/OptionRom.py b/BaseTools/Source/Python/GenFds/OptionRom.py
index 18f3fbd0d7a2..bb7071fa7fca 100644
--- a/BaseTools/Source/Python/GenFds/OptionRom.py
+++ b/BaseTools/Source/Python/GenFds/OptionRom.py
@@ -15,12 +15,12 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import subprocess
-import OptRomInfStatement
-from GenFdsGlobalVariable import GenFdsGlobalVariable
-from GenFds import GenFds
+from . import OptRomInfStatement
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from CommonDataClass.FdfClass import OptionRomClassObject
from Common.Misc import SaveFileOnChange
from Common import EdkLogger
diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/GenFds/Region.py
index 33e4ac8d3c37..7f94b3d66b55 100644
--- a/BaseTools/Source/Python/GenFds/Region.py
+++ b/BaseTools/Source/Python/GenFds/Region.py
@@ -15,8 +15,9 @@
##
# Import Modules
#
+from __future__ import absolute_import
from struct import *
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from io import BytesIO
import string
from CommonDataClass.FdfClass import RegionClassObject
diff --git a/BaseTools/Source/Python/GenFds/RuleComplexFile.py b/BaseTools/Source/Python/GenFds/RuleComplexFile.py
index 36c483fbb207..c357fedbd3be 100644
--- a/BaseTools/Source/Python/GenFds/RuleComplexFile.py
+++ b/BaseTools/Source/Python/GenFds/RuleComplexFile.py
@@ -15,7 +15,8 @@
##
# Import Modules
#
-import Rule
+from __future__ import absolute_import
+from . import Rule
from CommonDataClass.FdfClass import RuleComplexFileClassObject
## complex rule
diff --git a/BaseTools/Source/Python/GenFds/RuleSimpleFile.py b/BaseTools/Source/Python/GenFds/RuleSimpleFile.py
index 061f984e6af4..7aa184e7d8bb 100644
--- a/BaseTools/Source/Python/GenFds/RuleSimpleFile.py
+++ b/BaseTools/Source/Python/GenFds/RuleSimpleFile.py
@@ -15,7 +15,8 @@
##
# Import Modules
#
-import Rule
+from __future__ import absolute_import
+from . import Rule
from CommonDataClass.FdfClass import RuleSimpleFileClassObject
## simple rule
diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py
index ca4705a90c95..19a70009dcce 100644
--- a/BaseTools/Source/Python/GenFds/Section.py
+++ b/BaseTools/Source/Python/GenFds/Section.py
@@ -15,8 +15,9 @@
##
# Import Modules
#
+from __future__ import absolute_import
from CommonDataClass.FdfClass import SectionClassObject
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
import Common.LongFilePathOs as os, glob
from Common import EdkLogger
from Common.BuildToolError import *
diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source/Python/GenFds/UiSection.py
index 280500952b63..24f2f3ca938d 100644
--- a/BaseTools/Source/Python/GenFds/UiSection.py
+++ b/BaseTools/Source/Python/GenFds/UiSection.py
@@ -15,11 +15,12 @@
##
# Import Modules
#
-import Section
-from Ffs import Ffs
+from __future__ import absolute_import
+from . import Section
+from .Ffs import Ffs
import subprocess
import Common.LongFilePathOs as os
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from CommonDataClass.FdfClass import UiSectionClassObject
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.DataType import *
diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Source/Python/GenFds/VerSection.py
index 456a430079bb..db71fe9653d4 100644
--- a/BaseTools/Source/Python/GenFds/VerSection.py
+++ b/BaseTools/Source/Python/GenFds/VerSection.py
@@ -15,11 +15,12 @@
##
# Import Modules
#
-from Ffs import Ffs
-import Section
+from __future__ import absolute_import
+from .Ffs import Ffs
+from . import Section
import Common.LongFilePathOs as os
import subprocess
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
from CommonDataClass.FdfClass import VerSectionClassObject
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.DataType import SUP_MODULE_SEC
diff --git a/BaseTools/Source/Python/GenFds/Vtf.py b/BaseTools/Source/Python/GenFds/Vtf.py
index 83abc98f07c3..5cb2d4acfb1c 100644
--- a/BaseTools/Source/Python/GenFds/Vtf.py
+++ b/BaseTools/Source/Python/GenFds/Vtf.py
@@ -15,7 +15,8 @@
##
# Import Modules
#
-from GenFdsGlobalVariable import GenFdsGlobalVariable
+from __future__ import absolute_import
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
import Common.LongFilePathOs as os
from CommonDataClass.FdfClass import VtfClassObject
from Common.LongFilePathSupport import OpenLongFilePath as open
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 03/16] BaseTools: Move OverrideAttribs to OptRomInfStatement.py
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
2018-07-13 10:18 ` [PATCH v2 01/16] BaseTools: Treat GenFds.py as a python module Gary Lin
2018-07-13 10:18 ` [PATCH v2 02/16] BaseTools: Use absolute import in GenFds Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 04/16] BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py Gary Lin
` (13 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Move "class OverrideAttribs" to OptRomInfStatement.py to remove
"import OptionRom" which may form a circular import:
GenFds.OptionRom => GenFds.OptRomInfStatement => GenFds.OptionRom
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>
---
BaseTools/Source/Python/GenFds/FdfParser.py | 2 +-
BaseTools/Source/Python/GenFds/OptRomInfStatement.py | 17 +++++++++++++++--
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index c890f2d3afb6..8125ffaf32be 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -4440,7 +4440,7 @@ class FdfParser:
#
def __GetOptRomOverrides(self, Obj):
if self.__IsToken('{'):
- Overrides = OptionRom.OverrideAttribs()
+ Overrides = OptRomInfStatement.OverrideAttribs()
while True:
if self.__IsKeyword( "PCI_VENDOR_ID"):
if not self.__IsToken( "="):
diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
index dfeba5d0b140..e416b838d1e4 100644
--- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py
@@ -45,9 +45,8 @@ class OptRomInfStatement (FfsInfStatement):
# @param self The object pointer
#
def __GetOptRomParams(self):
- from . import OptionRom
if self.OverrideAttribs is None:
- self.OverrideAttribs = OptionRom.OverrideAttribs()
+ self.OverrideAttribs = OverrideAttribs()
if self.OverrideAttribs.NeedCompress is None:
self.OverrideAttribs.NeedCompress = self.OptRomDefs.get ('PCI_COMPRESS')
@@ -150,3 +149,17 @@ class OptRomInfStatement (FfsInfStatement):
OutputFileList.extend(FileList)
return OutputFileList
+
+class OverrideAttribs:
+
+ ## The constructor
+ #
+ # @param self The object pointer
+ #
+ def __init__(self):
+
+ self.PciVendorId = None
+ self.PciClassCode = None
+ self.PciDeviceId = None
+ self.PciRevision = None
+ self.NeedCompress = None
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 04/16] BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (2 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 03/16] BaseTools: Move OverrideAttribs to OptRomInfStatement.py Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 05/16] BaseTools: Move ImageBinDict " Gary Lin
` (12 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Importing "FindExtendTool" from GenFds.GenFds could create the following
circular imports:
* GenFds.FdfParser => GenFds.Capsule => GenFds.GenFds => GenFds.FdfParser
* GenFds.FdfParser => GenFds.Fd => GenFds.Fv => GenFds.AprioriSection =>
GenFds.FfsFileStatement => GenFds.GuidSection => GenFds.GenFds =>
GenFds.FdfParser
This commit moves "FindExtendTool" to GenFdsGlobalVariable.py to break
the circles. Besides, FindExtendTool is tweaked slightly with the
following changes:
ToolDefClassObject.ToolDefDict => ToolDefDict
TAB_GUID => DataType.TAB_GUID
TAB_TOD_DEFINES_TARGET => DataType.TAB_TOD_DEFINES_TARGET
TAB_TOD_DEFINES_TOOL_CHAIN_TAG => DataType.TAB_TOD_DEFINES_TOOL_CHAIN_TAG
TAB_TOD_DEFINES_TARGET_ARCH => DataType.TAB_TOD_DEFINES_TARGET_ARCH
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>
---
BaseTools/Source/Python/GenFds/Capsule.py | 2 +-
BaseTools/Source/Python/GenFds/GenFds.py | 92 -------------------
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 94 +++++++++++++++++++-
BaseTools/Source/Python/GenFds/GuidSection.py | 2 +-
4 files changed, 95 insertions(+), 95 deletions(-)
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py
index 27932ef0020c..8471cd5d0f7a 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -17,6 +17,7 @@
#
from __future__ import absolute_import
from .GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import FindExtendTool
from CommonDataClass.FdfClass import CapsuleClassObject
import Common.LongFilePathOs as os
import subprocess
@@ -65,7 +66,6 @@ class Capsule (CapsuleClassObject) :
# UINT32 CapsuleImageSize;
# } EFI_CAPSULE_HEADER;
#
- from .GenFds import FindExtendTool
Header = BytesIO()
#
# Use FMP capsule GUID: 6DCBD5ED-E82D-4C44-BDA1-7194199AD92A
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index c0b60b9b3c1f..865c5099d1eb 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -368,98 +368,6 @@ def SingleCheckCallback(option, opt_str, value, parser):
else:
parser.error("Option %s only allows one instance in command line!" % option)
-## FindExtendTool()
-#
-# Find location of tools to process data
-#
-# @param KeyStringList Filter for inputs of section generation
-# @param CurrentArchList Arch list
-# @param NameGuid The Guid name
-#
-def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
- ToolDb = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDatabase
- # if user not specify filter, try to deduce it from global data.
- if KeyStringList is None or KeyStringList == []:
- Target = GenFdsGlobalVariable.TargetName
- ToolChain = GenFdsGlobalVariable.ToolChainTag
- if ToolChain not in ToolDb['TOOL_CHAIN_TAG']:
- EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external tool because tool tag %s is not defined in tools_def.txt!" % ToolChain)
- KeyStringList = [Target + '_' + ToolChain + '_' + CurrentArchList[0]]
- for Arch in CurrentArchList:
- if Target + '_' + ToolChain + '_' + Arch not in KeyStringList:
- KeyStringList.append(Target + '_' + ToolChain + '_' + Arch)
-
- if GenFdsGlobalVariable.GuidToolDefinition:
- if NameGuid in GenFdsGlobalVariable.GuidToolDefinition:
- return GenFdsGlobalVariable.GuidToolDefinition[NameGuid]
-
- ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary
- ToolPathTmp = None
- ToolOption = None
- ToolPathKey = None
- ToolOptionKey = None
- KeyList = None
- for ToolDef in ToolDefinition.items():
- if NameGuid.lower() == ToolDef[1].lower() :
- KeyList = ToolDef[0].split('_')
- Key = KeyList[0] + \
- '_' + \
- KeyList[1] + \
- '_' + \
- KeyList[2]
- if Key in KeyStringList and KeyList[4] == TAB_GUID:
- ToolPathKey = Key + '_' + KeyList[3] + '_PATH'
- ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
- ToolPath = ToolDefinition.get(ToolPathKey)
- ToolOption = ToolDefinition.get(ToolOptionKey)
- if ToolPathTmp is None:
- ToolPathTmp = ToolPath
- else:
- if ToolPathTmp != ToolPath:
- EdkLogger.error("GenFds", GENFDS_ERROR, "Don't know which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath))
-
- BuildOption = {}
- for Arch in CurrentArchList:
- Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
- # key is (ToolChainFamily, ToolChain, CodeBase)
- for item in Platform.BuildOptions:
- if '_PATH' in item[1] or '_FLAGS' in item[1] or '_GUID' in item[1]:
- if not item[0] or (item[0] and GenFdsGlobalVariable.ToolChainFamily== item[0]):
- if item[1] not in BuildOption:
- BuildOption[item[1]] = Platform.BuildOptions[item]
- if BuildOption:
- ToolList = [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG, TAB_TOD_DEFINES_TARGET_ARCH]
- for Index in range(2, -1, -1):
- for Key in list(BuildOption.keys()):
- List = Key.split('_')
- if List[Index] == '*':
- for String in ToolDb[ToolList[Index]]:
- if String in [Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]:
- List[Index] = String
- NewKey = '%s_%s_%s_%s_%s' % tuple(List)
- if NewKey not in BuildOption:
- BuildOption[NewKey] = BuildOption[Key]
- continue
- del BuildOption[Key]
- elif List[Index] not in ToolDb[ToolList[Index]]:
- del BuildOption[Key]
- if BuildOption:
- if not KeyList:
- for Op in BuildOption:
- if NameGuid == BuildOption[Op]:
- KeyList = Op.split('_')
- Key = KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2]
- if Key in KeyStringList and KeyList[4] == TAB_GUID:
- ToolPathKey = Key + '_' + KeyList[3] + '_PATH'
- ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
- if ToolPathKey in BuildOption:
- ToolPathTmp = BuildOption[ToolPathKey]
- if ToolOptionKey in BuildOption:
- ToolOption = BuildOption[ToolOptionKey]
-
- GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption)
- return ToolPathTmp, ToolOption
-
## Parse command line options
#
# Using standard Python module optparse to parse command line option of this tool.
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index eeb3ec2197a8..52aa7a1538f7 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -27,7 +27,7 @@ from Common import EdkLogger
from Common.Misc import SaveFileOnChange
from Common.TargetTxtClassObject import TargetTxtClassObject
-from Common.ToolDefClassObject import ToolDefClassObject
+from Common.ToolDefClassObject import ToolDefClassObject, ToolDefDict
from AutoGen.BuildEngine import BuildRule
import Common.DataType as DataType
from Common.Misc import PathClass
@@ -843,3 +843,95 @@ class GenFdsGlobalVariable:
DebugLogger = staticmethod(DebugLogger)
MacroExtend = staticmethod (MacroExtend)
GetPcdValue = staticmethod(GetPcdValue)
+
+## FindExtendTool()
+#
+# Find location of tools to process data
+#
+# @param KeyStringList Filter for inputs of section generation
+# @param CurrentArchList Arch list
+# @param NameGuid The Guid name
+#
+def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
+ ToolDb = ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDatabase
+ # if user not specify filter, try to deduce it from global data.
+ if KeyStringList is None or KeyStringList == []:
+ Target = GenFdsGlobalVariable.TargetName
+ ToolChain = GenFdsGlobalVariable.ToolChainTag
+ if ToolChain not in ToolDb['TOOL_CHAIN_TAG']:
+ EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external tool because tool tag %s is not defined in tools_def.txt!" % ToolChain)
+ KeyStringList = [Target + '_' + ToolChain + '_' + CurrentArchList[0]]
+ for Arch in CurrentArchList:
+ if Target + '_' + ToolChain + '_' + Arch not in KeyStringList:
+ KeyStringList.append(Target + '_' + ToolChain + '_' + Arch)
+
+ if GenFdsGlobalVariable.GuidToolDefinition:
+ if NameGuid in GenFdsGlobalVariable.GuidToolDefinition:
+ return GenFdsGlobalVariable.GuidToolDefinition[NameGuid]
+
+ ToolDefinition = ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary
+ ToolPathTmp = None
+ ToolOption = None
+ ToolPathKey = None
+ ToolOptionKey = None
+ KeyList = None
+ for ToolDef in ToolDefinition.items():
+ if NameGuid.lower() == ToolDef[1].lower() :
+ KeyList = ToolDef[0].split('_')
+ Key = KeyList[0] + \
+ '_' + \
+ KeyList[1] + \
+ '_' + \
+ KeyList[2]
+ if Key in KeyStringList and KeyList[4] == DataType.TAB_GUID:
+ ToolPathKey = Key + '_' + KeyList[3] + '_PATH'
+ ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
+ ToolPath = ToolDefinition.get(ToolPathKey)
+ ToolOption = ToolDefinition.get(ToolOptionKey)
+ if ToolPathTmp is None:
+ ToolPathTmp = ToolPath
+ else:
+ if ToolPathTmp != ToolPath:
+ EdkLogger.error("GenFds", GENFDS_ERROR, "Don't know which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath))
+
+ BuildOption = {}
+ for Arch in CurrentArchList:
+ Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ # key is (ToolChainFamily, ToolChain, CodeBase)
+ for item in Platform.BuildOptions:
+ if '_PATH' in item[1] or '_FLAGS' in item[1] or '_GUID' in item[1]:
+ if not item[0] or (item[0] and GenFdsGlobalVariable.ToolChainFamily== item[0]):
+ if item[1] not in BuildOption:
+ BuildOption[item[1]] = Platform.BuildOptions[item]
+ if BuildOption:
+ ToolList = [DataType.TAB_TOD_DEFINES_TARGET, DataType.TAB_TOD_DEFINES_TOOL_CHAIN_TAG, DataType.TAB_TOD_DEFINES_TARGET_ARCH]
+ for Index in range(2, -1, -1):
+ for Key in list(BuildOption.keys()):
+ List = Key.split('_')
+ if List[Index] == '*':
+ for String in ToolDb[ToolList[Index]]:
+ if String in [Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]:
+ List[Index] = String
+ NewKey = '%s_%s_%s_%s_%s' % tuple(List)
+ if NewKey not in BuildOption:
+ BuildOption[NewKey] = BuildOption[Key]
+ continue
+ del BuildOption[Key]
+ elif List[Index] not in ToolDb[ToolList[Index]]:
+ del BuildOption[Key]
+ if BuildOption:
+ if not KeyList:
+ for Op in BuildOption:
+ if NameGuid == BuildOption[Op]:
+ KeyList = Op.split('_')
+ Key = KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2]
+ if Key in KeyStringList and KeyList[4] == DataType.TAB_GUID:
+ ToolPathKey = Key + '_' + KeyList[3] + '_PATH'
+ ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
+ if ToolPathKey in BuildOption:
+ ToolPathTmp = BuildOption[ToolPathKey]
+ if ToolOptionKey in BuildOption:
+ ToolOption = BuildOption[ToolOptionKey]
+
+ GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption)
+ return ToolPathTmp, ToolOption
diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Source/Python/GenFds/GuidSection.py
index e41c2fd31e6c..fd660737f421 100644
--- a/BaseTools/Source/Python/GenFds/GuidSection.py
+++ b/BaseTools/Source/Python/GenFds/GuidSection.py
@@ -22,6 +22,7 @@ import subprocess
from .Ffs import Ffs
import Common.LongFilePathOs as os
from .GenFdsGlobalVariable import GenFdsGlobalVariable
+from .GenFdsGlobalVariable import FindExtendTool
from CommonDataClass.FdfClass import GuidSectionClassObject
from Common import ToolDefClassObject
import sys
@@ -131,7 +132,6 @@ class GuidSection(GuidSectionClassObject) :
ExternalTool = None
ExternalOption = None
if self.NameGuid is not None:
- from .GenFds import FindExtendTool
ExternalTool, ExternalOption = FindExtendTool(self.KeyStringList, self.CurrentArchList, self.NameGuid)
#
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 05/16] BaseTools: Move ImageBinDict to GenFdsGlobalVariable.py
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (3 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 04/16] BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 06/16] BaseTools: Use absolute import in AutoGen Gary Lin
` (11 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Move "ImageBinDict" from GenFds.py to GenFdsGlobalVariable.py so that we
can remove the requirement to import GenFds.GenFds in Capsule.py, Fd.py and
Fv.py. This breaks the following circular imports:
* GenFds.FdfParser => GenFds.Capsule => GenFds.GenFds => GenFds.FdfParser
* GenFds.FdfParser => GenFds.Fd => GenFds.GenFds => GenFds.FdfParser
* GenFds.FdfParser => GenFds.Fd => GenFds.Fv => GenFds.GenFds =>
GenFds.FdfParser
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>
---
BaseTools/Source/Python/GenFds/Capsule.py | 7 +++----
BaseTools/Source/Python/GenFds/Fd.py | 15 +++++++--------
BaseTools/Source/Python/GenFds/Fv.py | 11 +++++------
BaseTools/Source/Python/GenFds/GenFds.py | 2 --
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 3 +++
5 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py
index 8471cd5d0f7a..baa6e1dfa2ab 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -201,9 +201,8 @@ class Capsule (CapsuleClassObject) :
# @retval string Generated Capsule file path
#
def GenCapsule(self):
- from .GenFds import GenFds
- if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict:
- return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap']
+ if self.UiCapsuleName.upper() + 'cap' in GenFdsGlobalVariable.ImageBinDict:
+ return GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.upper() + 'cap']
GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCapsuleName)
if ('CAPSULE_GUID' in self.TokensDict and
@@ -237,7 +236,7 @@ class Capsule (CapsuleClassObject) :
GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s Capsule Successfully" %self.UiCapsuleName)
GenFdsGlobalVariable.SharpCounter = 0
- GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] = CapOutputFile
+ GenFdsGlobalVariable.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] = CapOutputFile
return CapOutputFile
## Generate inf file for capsule
diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py
index 53318c9ea5c0..bfae1217984a 100644
--- a/BaseTools/Source/Python/GenFds/Fd.py
+++ b/BaseTools/Source/Python/GenFds/Fd.py
@@ -47,9 +47,8 @@ class FD(FDClassObject):
# @retval string Generated FD file name
#
def GenFd (self, Flag = False):
- from .GenFds import GenFds
- if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict:
- return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd']
+ if self.FdUiName.upper() + 'fd' in GenFdsGlobalVariable.ImageBinDict:
+ return GenFdsGlobalVariable.ImageBinDict[self.FdUiName.upper() + 'fd']
#
# Print Information
@@ -94,7 +93,7 @@ class FD(FDClassObject):
PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
PadRegion.Size = RegionObj.Offset - PadRegion.Offset
if not Flag:
- PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
+ PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
PreviousRegionStart = RegionObj.Offset
PreviousRegionSize = RegionObj.Size
#
@@ -103,7 +102,7 @@ class FD(FDClassObject):
if PreviousRegionSize > self.Size:
pass
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, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
FdBuffer = BytesIO('')
PreviousRegionStart = -1
@@ -124,7 +123,7 @@ class FD(FDClassObject):
PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
PadRegion.Size = RegionObj.Offset - PadRegion.Offset
if not Flag:
- PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
+ PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict)
PreviousRegionStart = RegionObj.Offset
PreviousRegionSize = RegionObj.Size
#
@@ -138,7 +137,7 @@ class FD(FDClassObject):
# Call each region's AddToBuffer function
#
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
- RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict, Flag=Flag)
+ RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFdsGlobalVariable.ImageBinDict, self.vtfRawDict, self.DefineVarDict, Flag=Flag)
#
# Write the buffer contents to Fd file
#
@@ -146,7 +145,7 @@ class FD(FDClassObject):
if not Flag:
SaveFileOnChange(FdFileName, FdBuffer.getvalue())
FdBuffer.close()
- GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] = FdFileName
+ GenFdsGlobalVariable.ImageBinDict[self.FdUiName.upper() + 'fd'] = FdFileName
return FdFileName
## generate VTF
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index 097f51f39e27..0d005ebf5bb6 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -70,9 +70,8 @@ class FV (FvClassObject):
#
def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :
- from .GenFds import GenFds
- if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict:
- return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv']
+ if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFdsGlobalVariable.ImageBinDict:
+ return GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv']
#
# Check whether FV in Capsule is in FD flash region.
@@ -85,7 +84,7 @@ class FV (FvClassObject):
for RegionData in RegionObj.RegionDataList:
if RegionData.endswith(".fv"):
continue
- elif RegionData.upper() + 'fv' in GenFds.ImageBinDict:
+ elif RegionData.upper() + 'fv' in GenFdsGlobalVariable.ImageBinDict:
continue
elif self.UiFvName.upper() == RegionData.upper():
GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))
@@ -140,7 +139,7 @@ class FV (FvClassObject):
FvOutputFile = self.CreateFileName
if Flag:
- GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile
+ GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile
return FvOutputFile
FvInfoFileName = os.path.join(GenFdsGlobalVariable.FfsDir, self.UiFvName + '.inf')
@@ -220,7 +219,7 @@ class FV (FvClassObject):
# FvAlignmentValue is less than 1K
self.FvAlignment = str (FvAlignmentValue)
FvFileObj.close()
- GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile
+ GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile
GenFdsGlobalVariable.LargeFileInFvFlags.pop()
else:
GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV file." %self.UiFvName)
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 865c5099d1eb..a7c1e6c85334 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -415,8 +415,6 @@ def myOptionParser():
#
class GenFds :
FdfParsef = None
- # FvName, FdName, CapName in FDF, Image file name
- ImageBinDict = {}
OnlyGenerateThisFd = None
OnlyGenerateThisFv = None
OnlyGenerateThisCap = None
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 52aa7a1538f7..9936498c5158 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -91,6 +91,9 @@ class GenFdsGlobalVariable:
SectionHeader = struct.Struct("3B 1B")
+ # FvName, FdName, CapName in FDF, Image file name
+ ImageBinDict = {}
+
## LoadBuildRule
#
@staticmethod
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 06/16] BaseTools: Use absolute import in AutoGen
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (4 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 05/16] BaseTools: Move ImageBinDict " Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 07/16] BaseTools: Treat BPDG.py as a python module Gary Lin
` (10 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Based on "futurize -f libfuturize.fixes.fix_absolute_import
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>
---
BaseTools/Source/Python/AutoGen/AutoGen.py | 17 +++++++++--------
BaseTools/Source/Python/AutoGen/GenC.py | 7 ++++---
BaseTools/Source/Python/AutoGen/GenMake.py | 3 ++-
BaseTools/Source/Python/AutoGen/GenPcdDb.py | 7 ++++---
BaseTools/Source/Python/AutoGen/IdfClassObject.py | 3 ++-
BaseTools/Source/Python/AutoGen/StrGather.py | 3 ++-
6 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 54c6b7330f53..c96673d2b4f3 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -16,19 +16,20 @@
## Import Modules
#
from __future__ import print_function
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import re
import os.path as path
import copy
import uuid
-import GenC
-import GenMake
-import GenDepex
+from . import GenC
+from . import GenMake
+from . import GenDepex
from io import BytesIO
-from StrGather import *
-from BuildEngine import BuildRule
+from .StrGather import *
+from .BuildEngine import BuildRule
from Common.LongFilePathSupport import CopyLongFilePath
from Common.BuildToolError import *
@@ -41,14 +42,14 @@ from CommonDataClass.CommonClass import SkuInfoClass
from Workspace.BuildClassObject import *
from GenPatchPcdTable.GenPatchPcdTable import parsePcdInfoFromMapFile
import Common.VpdInfoFile as VpdInfoFile
-from GenPcdDb import CreatePcdDatabaseCode
+from .GenPcdDb import CreatePcdDatabaseCode
from Workspace.MetaFileCommentParser import UsageList
from Workspace.WorkspaceCommon import GetModuleLibInstances
from Common.MultipleWorkspace import MultipleWorkspace as mws
-import InfSectionParser
+from . import InfSectionParser
import datetime
import hashlib
-from GenVar import VariableMgr, var_info
+from .GenVar import VariableMgr, var_info
from collections import OrderedDict
from collections import defaultdict
from Workspace.WorkspaceCommon import OrderedListDict
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index eac41ed9bf81..528be0f77e3d 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
@@ -22,9 +23,9 @@ from Common.BuildToolError import *
from Common.DataType import *
from Common.Misc import *
from Common.StringUtils import StringToArray
-from StrGather import *
-from GenPcdDb import CreatePcdDatabaseCode
-from IdfClassObject import *
+from .StrGather import *
+from .GenPcdDb import CreatePcdDatabaseCode
+from .IdfClassObject import *
## PCD type string
gItemTypeStringDatabase = {
diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 992de5490dff..f1dc14754154 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -13,6 +13,7 @@
## Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import sys
import string
@@ -23,7 +24,7 @@ from Common.MultipleWorkspace import MultipleWorkspace as mws
from Common.BuildToolError import *
from Common.Misc import *
from Common.StringUtils import *
-from BuildEngine import *
+from .BuildEngine import *
import Common.GlobalData as GlobalData
from collections import OrderedDict
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index c90b814e7dbd..2176bbefeb52 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -10,13 +10,14 @@
# 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 __future__ import absolute_import
from io import BytesIO
from Common.Misc import *
from Common.StringUtils import StringToArray
from struct import pack
-from ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER
-from ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB
-from ValidCheckingInfoObject import GetValidationObject
+from .ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER
+from .ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB
+from .ValidCheckingInfoObject import GetValidationObject
from Common.VariableAttributes import VariableAttributes
import copy
from struct import unpack
diff --git a/BaseTools/Source/Python/AutoGen/IdfClassObject.py b/BaseTools/Source/Python/AutoGen/IdfClassObject.py
index b656bd83e3ba..b227b10258da 100644
--- a/BaseTools/Source/Python/AutoGen/IdfClassObject.py
+++ b/BaseTools/Source/Python/AutoGen/IdfClassObject.py
@@ -13,6 +13,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.EdkLogger as EdkLogger
from Common.BuildToolError import *
from Common.StringUtils import GetLineNo
@@ -21,7 +22,7 @@ from Common.LongFilePathSupport import LongFilePath
import re
import os
from Common.GlobalData import gIdentifierPattern
-from UniClassObject import StripComments
+from .UniClassObject import StripComments
IMAGE_TOKEN = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)
diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py
index a702ef0dd583..361d49907685 100644
--- a/BaseTools/Source/Python/AutoGen/StrGather.py
+++ b/BaseTools/Source/Python/AutoGen/StrGather.py
@@ -14,10 +14,11 @@
##
# Import Modules
#
+from __future__ import absolute_import
import re
import Common.EdkLogger as EdkLogger
from Common.BuildToolError import *
-from UniClassObject import *
+from .UniClassObject import *
from io import BytesIO
from struct import pack, unpack
from Common.LongFilePathSupport import OpenLongFilePath as open
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 07/16] BaseTools: Treat BPDG.py as a python module
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (5 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 06/16] BaseTools: Use absolute import in AutoGen Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 08/16] BaseTools: Use absolute import in BPDG Gary Lin
` (9 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Since BPDG.py import modules from its own directory, add "-m" to the
python parameters so that they can import its own modules after adopting
absolute import.
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>
---
BaseTools/BinWrappers/PosixLike/BPDG | 2 +-
BaseTools/BinWrappers/WindowsLike/BPDG.bat | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/BaseTools/BinWrappers/PosixLike/BPDG b/BaseTools/BinWrappers/PosixLike/BPDG
index 01ae23ddeb4f..276c7ea20733 100755
--- a/BaseTools/BinWrappers/PosixLike/BPDG
+++ b/BaseTools/BinWrappers/PosixLike/BPDG
@@ -11,4 +11,4 @@ dir=$(dirname "$full_cmd")
cmd=${full_cmd##*/}
export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
-exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
+exec "${python_exe:-python}" -m $cmd.$cmd "$@"
diff --git a/BaseTools/BinWrappers/WindowsLike/BPDG.bat b/BaseTools/BinWrappers/WindowsLike/BPDG.bat
index 9fbb704a6eb0..98095cfbd439 100644
--- a/BaseTools/BinWrappers/WindowsLike/BPDG.bat
+++ b/BaseTools/BinWrappers/WindowsLike/BPDG.bat
@@ -1,3 +1,4 @@
@setlocal
@set ToolName=%~n0%
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
+@set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python
+@%PYTHON_HOME%\python.exe -m %ToolName%.%ToolName% %*
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 08/16] BaseTools: Use absolute import in BPDG
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (6 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 07/16] BaseTools: Treat BPDG.py as a python module Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 09/16] BaseTools: Use absolute import in Common Gary Lin
` (8 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Based on "futurize -f libfuturize.fixes.fix_absolute_import
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>
---
BaseTools/Source/Python/BPDG/BPDG.py | 5 +++--
BaseTools/Source/Python/BPDG/GenVpd.py | 3 ++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/BaseTools/Source/Python/BPDG/BPDG.py b/BaseTools/Source/Python/BPDG/BPDG.py
index 07cee8976208..2ec1516c0a08 100644
--- a/BaseTools/Source/Python/BPDG/BPDG.py
+++ b/BaseTools/Source/Python/BPDG/BPDG.py
@@ -21,6 +21,7 @@
# Import Modules
#
from __future__ import print_function
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import sys
import encodings.ascii
@@ -30,8 +31,8 @@ from Common import EdkLogger
from Common.BuildToolError import *
from Common.BuildVersion import gBUILD_VERSION
-import StringTable as st
-import GenVpd
+from . import StringTable as st
+from . import GenVpd
PROJECT_NAME = st.LBL_BPDG_LONG_UNI
VERSION = (st.LBL_BPDG_VERSION + " Build " + gBUILD_VERSION)
diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Python/BPDG/GenVpd.py
index 2eefcc24905f..cd272a2d9a79 100644
--- a/BaseTools/Source/Python/BPDG/GenVpd.py
+++ b/BaseTools/Source/Python/BPDG/GenVpd.py
@@ -13,9 +13,10 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
from io import BytesIO
-import StringTable as st
+from . import StringTable as st
import array
import re
from Common.LongFilePathSupport import OpenLongFilePath as open
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 09/16] BaseTools: Use absolute import in Common
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (7 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 08/16] BaseTools: Use absolute import in BPDG Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 10/16] BaseTools: Treat Ecc.py as a python module Gary Lin
` (7 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Based on "futurize -f libfuturize.fixes.fix_absolute_import
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>
---
BaseTools/Source/Python/Common/Database.py | 8 ++++----
BaseTools/Source/Python/Common/EdkLogger.py | 3 ++-
BaseTools/Source/Python/Common/Expression.py | 3 ++-
BaseTools/Source/Python/Common/LongFilePathOs.py | 3 ++-
BaseTools/Source/Python/Common/Misc.py | 9 +++++----
BaseTools/Source/Python/Common/Parsing.py | 5 +++--
BaseTools/Source/Python/Common/StringUtils.py | 9 +++++----
BaseTools/Source/Python/Common/TargetTxtClassObject.py | 9 +++++----
BaseTools/Source/Python/Common/ToolDefClassObject.py | 9 +++++----
9 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/BaseTools/Source/Python/Common/Database.py b/BaseTools/Source/Python/Common/Database.py
index 6abfa1f15e35..1c543aeb41b1 100644
--- a/BaseTools/Source/Python/Common/Database.py
+++ b/BaseTools/Source/Python/Common/Database.py
@@ -14,13 +14,14 @@
##
# Import Modules
#
+from __future__ import absolute_import
import sqlite3
import Common.LongFilePathOs as os
-import EdkLogger as EdkLogger
+from . import EdkLogger as EdkLogger
from CommonDataClass.DataClass import *
-from StringUtils import *
-from DataType import *
+from .StringUtils import *
+from .DataType import *
from Table.TableDataModel import TableDataModel
from Table.TableFile import TableFile
@@ -117,4 +118,3 @@ if __name__ == '__main__':
Db.QueryTable(Db.TblFile)
Db.QueryTable(Db.TblDsc)
Db.Close()
-
diff --git a/BaseTools/Source/Python/Common/EdkLogger.py b/BaseTools/Source/Python/Common/EdkLogger.py
index 3f462df49ada..19749066ecee 100644
--- a/BaseTools/Source/Python/Common/EdkLogger.py
+++ b/BaseTools/Source/Python/Common/EdkLogger.py
@@ -12,9 +12,10 @@
#
## Import modules
+from __future__ import absolute_import
import Common.LongFilePathOs as os, sys, logging
import traceback
-from BuildToolError import *
+from .BuildToolError import *
## Log level constants
DEBUG_0 = 1
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 51e8d2174a8f..ccc736846afa 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -13,10 +13,11 @@
## Import Modules
#
from __future__ import print_function
+from __future__ import absolute_import
from Common.GlobalData import *
from CommonDataClass.Exceptions import BadExpression
from CommonDataClass.Exceptions import WrnExpression
-from Misc import GuidStringToGuidStructureString, ParseFieldValue, IsFieldValueAnArray
+from .Misc import GuidStringToGuidStructureString, ParseFieldValue, IsFieldValueAnArray
import Common.EdkLogger as EdkLogger
import copy
from Common.DataType import *
diff --git a/BaseTools/Source/Python/Common/LongFilePathOs.py b/BaseTools/Source/Python/Common/LongFilePathOs.py
index 4939a8bc733c..53528546b782 100644
--- a/BaseTools/Source/Python/Common/LongFilePathOs.py
+++ b/BaseTools/Source/Python/Common/LongFilePathOs.py
@@ -11,8 +11,9 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
+from __future__ import absolute_import
import os
-import LongFilePathOsPath
+from . import LongFilePathOsPath
from Common.LongFilePathSupport import LongFilePath
from Common.LongFilePathSupport import UniToStr
import time
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index b56ddd532471..79d1ff28f50b 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import sys
import string
@@ -30,10 +31,10 @@ from UserList import UserList
from Common import EdkLogger as EdkLogger
from Common import GlobalData as GlobalData
-from DataType import *
-from BuildToolError import *
+from .DataType import *
+from .BuildToolError import *
from CommonDataClass.DataClass import *
-from Parsing import GetSplitValueList
+from .Parsing import GetSplitValueList
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
import uuid
@@ -474,7 +475,7 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True):
try:
if GlobalData.gIsWindows:
try:
- from PyUtility import SaveFileToDisk
+ from .PyUtility import SaveFileToDisk
if not SaveFileToDisk(File, Content):
EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData=File)
except:
diff --git a/BaseTools/Source/Python/Common/Parsing.py b/BaseTools/Source/Python/Common/Parsing.py
index 527852a50c09..889251b69935 100644
--- a/BaseTools/Source/Python/Common/Parsing.py
+++ b/BaseTools/Source/Python/Common/Parsing.py
@@ -14,9 +14,10 @@
##
# Import Modules
#
-from StringUtils import *
+from __future__ import absolute_import
+from .StringUtils import *
from CommonDataClass.DataClass import *
-from DataType import *
+from .DataType import *
## ParseDefineMacro
#
diff --git a/BaseTools/Source/Python/Common/StringUtils.py b/BaseTools/Source/Python/Common/StringUtils.py
index 723faac0f9f3..da2949dbadef 100644
--- a/BaseTools/Source/Python/Common/StringUtils.py
+++ b/BaseTools/Source/Python/Common/StringUtils.py
@@ -14,14 +14,15 @@
##
# Import Modules
#
+from __future__ import absolute_import
import re
-import DataType
+from . import DataType
import Common.LongFilePathOs as os
import string
-import EdkLogger as EdkLogger
+from . import EdkLogger as EdkLogger
-import GlobalData
-from BuildToolError import *
+from . import GlobalData
+from .BuildToolError import *
from CommonDataClass.Exceptions import *
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
index 8ba8dd31a8c5..55a2f564821e 100644
--- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py
+++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
@@ -15,11 +15,12 @@
# Import Modules
#
from __future__ import print_function
+from __future__ import absolute_import
import Common.LongFilePathOs as os
-import EdkLogger
-import DataType
-from BuildToolError import *
-import GlobalData
+from . import EdkLogger
+from . import DataType
+from .BuildToolError import *
+from . import GlobalData
from Common.LongFilePathSupport import OpenLongFilePath as open
gDefaultTargetTxtFile = "target.txt"
diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py
index 7cc7e22839e1..05a1ddfbcc89 100644
--- a/BaseTools/Source/Python/Common/ToolDefClassObject.py
+++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py
@@ -14,19 +14,20 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import re
-import EdkLogger
+from . import EdkLogger
-from BuildToolError import *
-from TargetTxtClassObject import *
+from .BuildToolError import *
+from .TargetTxtClassObject import *
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.Misc import PathClass
from Common.StringUtils import NormPath
import Common.GlobalData as GlobalData
from Common import GlobalData
from Common.MultipleWorkspace import MultipleWorkspace as mws
-from DataType import TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG,\
+from .DataType import TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG,\
TAB_TOD_DEFINES_TARGET_ARCH, TAB_TOD_DEFINES_COMMAND_TYPE\
, TAB_TOD_DEFINES_FAMILY, TAB_TOD_DEFINES_BUILDRULEFAMILY
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 10/16] BaseTools: Treat Ecc.py as a python module
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (8 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 09/16] BaseTools: Use absolute import in Common Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 11/16] BaseTools: Use absolute import in Ecc Gary Lin
` (6 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Since Ecc.py import modules from its own directory, add "-m" to the
python parameters so that they can import its own modules after adopting
absolute import.
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>
Signed-off-by: Gary Lin <glin@suse.com>
---
BaseTools/BinWrappers/PosixLike/Ecc | 2 +-
BaseTools/BinWrappers/WindowsLike/Ecc.bat | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/BaseTools/BinWrappers/PosixLike/Ecc b/BaseTools/BinWrappers/PosixLike/Ecc
index 01ae23ddeb4f..276c7ea20733 100755
--- a/BaseTools/BinWrappers/PosixLike/Ecc
+++ b/BaseTools/BinWrappers/PosixLike/Ecc
@@ -11,4 +11,4 @@ dir=$(dirname "$full_cmd")
cmd=${full_cmd##*/}
export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}"
-exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@"
+exec "${python_exe:-python}" -m $cmd.$cmd "$@"
diff --git a/BaseTools/BinWrappers/WindowsLike/Ecc.bat b/BaseTools/BinWrappers/WindowsLike/Ecc.bat
index 9fbb704a6eb0..98095cfbd439 100644
--- a/BaseTools/BinWrappers/WindowsLike/Ecc.bat
+++ b/BaseTools/BinWrappers/WindowsLike/Ecc.bat
@@ -1,3 +1,4 @@
@setlocal
@set ToolName=%~n0%
-@%PYTHON_HOME%\python.exe %BASE_TOOLS_PATH%\Source\Python\%ToolName%\%ToolName%.py %*
+@set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python
+@%PYTHON_HOME%\python.exe -m %ToolName%.%ToolName% %*
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 11/16] BaseTools: Use absolute import in Ecc
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (9 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 10/16] BaseTools: Treat Ecc.py as a python module Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 12/16] BaseTools: Use absolute import in Eot Gary Lin
` (5 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Based on "futurize -f libfuturize.fixes.fix_absolute_import
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>
---
BaseTools/Source/Python/Ecc/CParser.py | 5 ++--
BaseTools/Source/Python/Ecc/Check.py | 9 +++----
BaseTools/Source/Python/Ecc/CodeFragmentCollector.py | 13 +++++-----
BaseTools/Source/Python/Ecc/Database.py | 7 +++---
BaseTools/Source/Python/Ecc/Ecc.py | 25 ++++++++++----------
BaseTools/Source/Python/Ecc/Exception.py | 3 ++-
BaseTools/Source/Python/Ecc/FileProfile.py | 5 ++--
BaseTools/Source/Python/Ecc/MetaDataParser.py | 5 ++--
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 3 ++-
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py | 5 ++--
BaseTools/Source/Python/Ecc/c.py | 13 +++++-----
11 files changed, 51 insertions(+), 42 deletions(-)
diff --git a/BaseTools/Source/Python/Ecc/CParser.py b/BaseTools/Source/Python/Ecc/CParser.py
index b66ac2d8d545..0b74b53ae7a5 100644
--- a/BaseTools/Source/Python/Ecc/CParser.py
+++ b/BaseTools/Source/Python/Ecc/CParser.py
@@ -1,6 +1,7 @@
# $ANTLR 3.0.1 C.g 2010-02-23 09:58:53
from __future__ import print_function
+from __future__ import absolute_import
from antlr3 import *
from antlr3.compat import set, frozenset
@@ -23,8 +24,8 @@ from antlr3.compat import set, frozenset
#
##
-import CodeFragment
-import FileProfile
+from . import CodeFragment
+from . import FileProfile
diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py
index 540d9cb7edc7..0b81013d77e9 100644
--- a/BaseTools/Source/Python/Ecc/Check.py
+++ b/BaseTools/Source/Python/Ecc/Check.py
@@ -10,14 +10,15 @@
# 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 __future__ import absolute_import
import Common.LongFilePathOs as os
import re
from CommonDataClass.DataClass import *
import Common.DataType as DT
-from EccToolError import *
-from MetaDataParser import ParseHeaderCommentSection
-import EccGlobalData
-import c
+from .EccToolError import *
+from .MetaDataParser import ParseHeaderCommentSection
+from . import EccGlobalData
+from . import c
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
diff --git a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
index b4f421342f60..28b4e0196f50 100644
--- a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
+++ b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
@@ -17,18 +17,19 @@
#
from __future__ import print_function
+from __future__ import absolute_import
import re
import Common.LongFilePathOs as os
import sys
import antlr3
-from CLexer import CLexer
-from CParser import CParser
+from .CLexer import CLexer
+from .CParser import CParser
-import FileProfile
-from CodeFragment import Comment
-from CodeFragment import PP_Directive
-from ParserWarning import Warning
+from . import FileProfile
+from .CodeFragment import Comment
+from .CodeFragment import PP_Directive
+from .ParserWarning import Warning
##define T_CHAR_SPACE ' '
diff --git a/BaseTools/Source/Python/Ecc/Database.py b/BaseTools/Source/Python/Ecc/Database.py
index 204117512452..34f49f3cba8b 100644
--- a/BaseTools/Source/Python/Ecc/Database.py
+++ b/BaseTools/Source/Python/Ecc/Database.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
import sqlite3
import Common.LongFilePathOs as os, time
@@ -26,9 +27,9 @@ from Table.TableFunction import TableFunction
from Table.TablePcd import TablePcd
from Table.TableIdentifier import TableIdentifier
from Table.TableReport import TableReport
-from MetaFileWorkspace.MetaFileTable import ModuleTable
-from MetaFileWorkspace.MetaFileTable import PackageTable
-from MetaFileWorkspace.MetaFileTable import PlatformTable
+from .MetaFileWorkspace.MetaFileTable import ModuleTable
+from .MetaFileWorkspace.MetaFileTable import PackageTable
+from .MetaFileWorkspace.MetaFileTable import PlatformTable
from Table.TableFdf import TableFdf
##
diff --git a/BaseTools/Source/Python/Ecc/Ecc.py b/BaseTools/Source/Python/Ecc/Ecc.py
index ccd563a4660e..8f96bdf9778c 100644
--- a/BaseTools/Source/Python/Ecc/Ecc.py
+++ b/BaseTools/Source/Python/Ecc/Ecc.py
@@ -14,14 +14,15 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os, time, glob, sys
import Common.EdkLogger as EdkLogger
-import Database
-import EccGlobalData
-from MetaDataParser import *
+from . import Database
+from . import EccGlobalData
+from .MetaDataParser import *
from optparse import OptionParser
-from Configuration import Configuration
-from Check import Check
+from .Configuration import Configuration
+from .Check import Check
import Common.GlobalData as GlobalData
from Common.StringUtils import NormPath
@@ -29,14 +30,14 @@ from Common.BuildVersion import gBUILD_VERSION
from Common import BuildToolError
from Common.Misc import PathClass
from Common.Misc import DirCache
-from MetaFileWorkspace.MetaFileParser import DscParser
-from MetaFileWorkspace.MetaFileParser import DecParser
-from MetaFileWorkspace.MetaFileParser import InfParser
-from MetaFileWorkspace.MetaFileParser import Fdf
-from MetaFileWorkspace.MetaFileTable import MetaFileStorage
-import c
+from .MetaFileWorkspace.MetaFileParser import DscParser
+from .MetaFileWorkspace.MetaFileParser import DecParser
+from .MetaFileWorkspace.MetaFileParser import InfParser
+from .MetaFileWorkspace.MetaFileParser import Fdf
+from .MetaFileWorkspace.MetaFileTable import MetaFileStorage
+from . import c
import re, string
-from Exception import *
+from .Exception import *
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
diff --git a/BaseTools/Source/Python/Ecc/Exception.py b/BaseTools/Source/Python/Ecc/Exception.py
index 0498a503d774..340e0e975207 100644
--- a/BaseTools/Source/Python/Ecc/Exception.py
+++ b/BaseTools/Source/Python/Ecc/Exception.py
@@ -15,7 +15,8 @@
# Import Modules
#
from __future__ import print_function
-from Xml.XmlRoutines import *
+from __future__ import absolute_import
+from .Xml.XmlRoutines import *
import Common.LongFilePathOs as os
# ExceptionXml to parse Exception Node of XML file
diff --git a/BaseTools/Source/Python/Ecc/FileProfile.py b/BaseTools/Source/Python/Ecc/FileProfile.py
index a071fd020eb4..1d3fbf2d3b79 100644
--- a/BaseTools/Source/Python/Ecc/FileProfile.py
+++ b/BaseTools/Source/Python/Ecc/FileProfile.py
@@ -16,9 +16,10 @@
# Import Modules
#
+from __future__ import absolute_import
import re
import Common.LongFilePathOs as os
-from ParserWarning import Warning
+from .ParserWarning import Warning
from Common.LongFilePathSupport import OpenLongFilePath as open
CommentList = []
@@ -54,5 +55,3 @@ class FileProfile :
except IOError:
raise Warning("Error when opening file %s" % FileName)
-
-
diff --git a/BaseTools/Source/Python/Ecc/MetaDataParser.py b/BaseTools/Source/Python/Ecc/MetaDataParser.py
index 6060d67581be..e5744dd5cc48 100644
--- a/BaseTools/Source/Python/Ecc/MetaDataParser.py
+++ b/BaseTools/Source/Python/Ecc/MetaDataParser.py
@@ -11,11 +11,12 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
from CommonDataClass.DataClass import *
-from EccToolError import *
+from .EccToolError import *
from Common.MultipleWorkspace import MultipleWorkspace as mws
-import EccGlobalData
+from . import EccGlobalData
import re
## Get the inlcude path list for a source file
#
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
index 111a25ed9260..51669815b55f 100644
--- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import re
import time
@@ -31,7 +32,7 @@ from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClas
from Common.Expression import *
from CommonDataClass.Exceptions import *
-from MetaFileTable import MetaFileStorage
+from .MetaFileTable import MetaFileStorage
from GenFds.FdfParser import FdfParser
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.LongFilePathSupport import CodecOpenLongFilePath
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py
index ad3cf36a1cbd..7e0afd5d70d7 100644
--- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py
+++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py
@@ -14,13 +14,14 @@
##
# Import Modules
#
+from __future__ import absolute_import
import uuid
import Common.EdkLogger as EdkLogger
import EccGlobalData
-from MetaDataTable import Table
-from MetaDataTable import ConvertToSqlString
+from .MetaDataTable import Table
+from .MetaDataTable import ConvertToSqlString
from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE_INF, \
MODEL_FILE_OTHERS
diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py
index 12dbf664ba9b..5616c108533e 100644
--- a/BaseTools/Source/Python/Ecc/c.py
+++ b/BaseTools/Source/Python/Ecc/c.py
@@ -12,18 +12,19 @@
#
from __future__ import print_function
+from __future__ import absolute_import
import sys
import Common.LongFilePathOs as os
import re
import string
-import CodeFragmentCollector
-import FileProfile
+from . import CodeFragmentCollector
+from . import FileProfile
from CommonDataClass import DataClass
-import Database
+from . import Database
from Common import EdkLogger
-from EccToolError import *
-import EccGlobalData
-import MetaDataParser
+from .EccToolError import *
+from . import EccGlobalData
+from . import MetaDataParser
IncludeFileListDict = {}
AllIncludeFileListDict = {}
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 12/16] BaseTools: Use absolute import in Eot
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (10 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 11/16] BaseTools: Use absolute import in Ecc Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 13/16] BaseTools: Use absolute import in Table Gary Lin
` (4 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Based on "futurize -f libfuturize.fixes.fix_absolute_import
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>
---
BaseTools/Source/Python/Eot/CParser.py | 5 +++--
BaseTools/Source/Python/Eot/CodeFragmentCollector.py | 11 +++++-----
BaseTools/Source/Python/Eot/Eot.py | 21 ++++++++++----------
BaseTools/Source/Python/Eot/FileProfile.py | 3 ++-
BaseTools/Source/Python/Eot/InfParserLite.py | 5 +++--
BaseTools/Source/Python/Eot/Parser.py | 3 ++-
BaseTools/Source/Python/Eot/Report.py | 3 ++-
BaseTools/Source/Python/Eot/c.py | 9 +++++----
8 files changed, 34 insertions(+), 26 deletions(-)
diff --git a/BaseTools/Source/Python/Eot/CParser.py b/BaseTools/Source/Python/Eot/CParser.py
index b66ac2d8d545..0b74b53ae7a5 100644
--- a/BaseTools/Source/Python/Eot/CParser.py
+++ b/BaseTools/Source/Python/Eot/CParser.py
@@ -1,6 +1,7 @@
# $ANTLR 3.0.1 C.g 2010-02-23 09:58:53
from __future__ import print_function
+from __future__ import absolute_import
from antlr3 import *
from antlr3.compat import set, frozenset
@@ -23,8 +24,8 @@ from antlr3.compat import set, frozenset
#
##
-import CodeFragment
-import FileProfile
+from . import CodeFragment
+from . import FileProfile
diff --git a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
index 1e30e2ce62e2..8a5e5df17e5a 100644
--- a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
+++ b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
@@ -16,17 +16,18 @@
# Import Modules
#
from __future__ import print_function
+from __future__ import absolute_import
import re
import Common.LongFilePathOs as os
import sys
import antlr3
-from CLexer import CLexer
-from CParser import CParser
+from .CLexer import CLexer
+from .CParser import CParser
-import FileProfile
-from CodeFragment import PP_Directive
-from ParserWarning import Warning
+from . import FileProfile
+from .CodeFragment import PP_Directive
+from .ParserWarning import Warning
##define T_CHAR_SPACE ' '
diff --git a/BaseTools/Source/Python/Eot/Eot.py b/BaseTools/Source/Python/Eot/Eot.py
index 297847cdab91..6fb882642bff 100644
--- a/BaseTools/Source/Python/Eot/Eot.py
+++ b/BaseTools/Source/Python/Eot/Eot.py
@@ -14,20 +14,21 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os, time, glob
import Common.EdkLogger as EdkLogger
-import EotGlobalData
+from . import EotGlobalData
from optparse import OptionParser
from Common.StringUtils import NormPath
from Common import BuildToolError
from Common.Misc import GuidStructureStringToGuidString, sdict
-from InfParserLite import *
-import c
-import Database
+from .InfParserLite import *
+from . import c
+from . import Database
from array import array
-from Report import Report
+from .Report import Report
from Common.BuildVersion import gBUILD_VERSION
-from Parser import ConvertGuid
+from .Parser import ConvertGuid
from Common.LongFilePathSupport import OpenLongFilePath as open
import struct
import uuid
@@ -153,7 +154,7 @@ class CompressedImage(Image):
def _GetSections(m):
try:
- import EfiCompressor
+ from . import EfiCompressor
TmpData = EfiCompressor.FrameworkDecompress(
m[m._HEADER_SIZE_:],
len(m) - m._HEADER_SIZE_
@@ -161,7 +162,7 @@ class CompressedImage(Image):
DecData = array('B')
DecData.fromstring(TmpData)
except:
- import EfiCompressor
+ from . import EfiCompressor
TmpData = EfiCompressor.UefiDecompress(
m[m._HEADER_SIZE_:],
len(m) - m._HEADER_SIZE_
@@ -748,7 +749,7 @@ class GuidDefinedImage(Image):
SectionList.append(Sec)
elif Guid == m.TIANO_COMPRESS_GUID:
try:
- import EfiCompressor
+ from . import EfiCompressor
# skip the header
Offset = m.DataOffset - 4
TmpData = EfiCompressor.FrameworkDecompress(m[Offset:], len(m)-Offset)
@@ -769,7 +770,7 @@ class GuidDefinedImage(Image):
pass
elif Guid == m.LZMA_COMPRESS_GUID:
try:
- import LzmaCompressor
+ from . import LzmaCompressor
# skip the header
Offset = m.DataOffset - 4
TmpData = LzmaCompressor.LzmaDecompress(m[Offset:], len(m)-Offset)
diff --git a/BaseTools/Source/Python/Eot/FileProfile.py b/BaseTools/Source/Python/Eot/FileProfile.py
index 0544c0d55b44..3846279cad4c 100644
--- a/BaseTools/Source/Python/Eot/FileProfile.py
+++ b/BaseTools/Source/Python/Eot/FileProfile.py
@@ -16,9 +16,10 @@
# Import Modules
#
+from __future__ import absolute_import
import re
import Common.LongFilePathOs as os
-from ParserWarning import Warning
+from .ParserWarning import Warning
from Common.LongFilePathSupport import OpenLongFilePath as open
# Profile contents of a file
diff --git a/BaseTools/Source/Python/Eot/InfParserLite.py b/BaseTools/Source/Python/Eot/InfParserLite.py
index 24f0d50246e5..88d7e7d58e0b 100644
--- a/BaseTools/Source/Python/Eot/InfParserLite.py
+++ b/BaseTools/Source/Python/Eot/InfParserLite.py
@@ -15,14 +15,15 @@
# Import Modules
#
from __future__ import print_function
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import Common.EdkLogger as EdkLogger
from Common.DataType import *
from CommonDataClass.DataClass import *
from Common.Identification import *
from Common.StringUtils import *
-from Parser import *
-import Database
+from .Parser import *
+from . import Database
## EdkInfParser() class
#
diff --git a/BaseTools/Source/Python/Eot/Parser.py b/BaseTools/Source/Python/Eot/Parser.py
index 0b720d5b2187..e01a9770befb 100644
--- a/BaseTools/Source/Python/Eot/Parser.py
+++ b/BaseTools/Source/Python/Eot/Parser.py
@@ -15,12 +15,13 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os, re
import Common.EdkLogger as EdkLogger
from Common.DataType import *
from CommonDataClass.DataClass import *
from Common.StringUtils import CleanString, GetSplitValueList, ReplaceMacro
-import EotGlobalData
+from . import EotGlobalData
from Common.StringUtils import GetSplitList
from Common.LongFilePathSupport import OpenLongFilePath as open
diff --git a/BaseTools/Source/Python/Eot/Report.py b/BaseTools/Source/Python/Eot/Report.py
index e9716c988c8b..4ddddb103401 100644
--- a/BaseTools/Source/Python/Eot/Report.py
+++ b/BaseTools/Source/Python/Eot/Report.py
@@ -14,8 +14,9 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
-import EotGlobalData
+from . import EotGlobalData
from Common.LongFilePathSupport import OpenLongFilePath as open
## Report() class
diff --git a/BaseTools/Source/Python/Eot/c.py b/BaseTools/Source/Python/Eot/c.py
index ceefc952237f..4f0b58a52c79 100644
--- a/BaseTools/Source/Python/Eot/c.py
+++ b/BaseTools/Source/Python/Eot/c.py
@@ -16,15 +16,16 @@
# Import Modules
#
from __future__ import print_function
+from __future__ import absolute_import
import sys
import Common.LongFilePathOs as os
import re
-import CodeFragmentCollector
-import FileProfile
+from . import CodeFragmentCollector
+from . import FileProfile
from CommonDataClass import DataClass
from Common import EdkLogger
-from EotToolError import *
-import EotGlobalData
+from .EotToolError import *
+from . import EotGlobalData
# Global Dicts
IncludeFileListDict = {}
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 13/16] BaseTools: Use absolute import in Table
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (11 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 12/16] BaseTools: Use absolute import in Eot Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 14/16] BaseTools: Use absolute import in UPT Gary Lin
` (3 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Based on "futurize -f libfuturize.fixes.fix_absolute_import
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>
---
BaseTools/Source/Python/Table/TableDataModel.py | 3 ++-
BaseTools/Source/Python/Table/TableDec.py | 3 ++-
BaseTools/Source/Python/Table/TableDsc.py | 3 ++-
BaseTools/Source/Python/Table/TableEotReport.py | 3 ++-
BaseTools/Source/Python/Table/TableFdf.py | 3 ++-
BaseTools/Source/Python/Table/TableFile.py | 3 ++-
BaseTools/Source/Python/Table/TableFunction.py | 3 ++-
BaseTools/Source/Python/Table/TableIdentifier.py | 3 ++-
BaseTools/Source/Python/Table/TableInf.py | 3 ++-
BaseTools/Source/Python/Table/TablePcd.py | 3 ++-
BaseTools/Source/Python/Table/TableQuery.py | 3 ++-
BaseTools/Source/Python/Table/TableReport.py | 3 ++-
12 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/BaseTools/Source/Python/Table/TableDataModel.py b/BaseTools/Source/Python/Table/TableDataModel.py
index f167e433599a..ea0996f66332 100644
--- a/BaseTools/Source/Python/Table/TableDataModel.py
+++ b/BaseTools/Source/Python/Table/TableDataModel.py
@@ -14,9 +14,10 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.EdkLogger as EdkLogger
import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
from Common.StringUtils import ConvertToSqlString
## TableDataModel
diff --git a/BaseTools/Source/Python/Table/TableDec.py b/BaseTools/Source/Python/Table/TableDec.py
index faa18e309d72..bbae3e857e1a 100644
--- a/BaseTools/Source/Python/Table/TableDec.py
+++ b/BaseTools/Source/Python/Table/TableDec.py
@@ -14,9 +14,10 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.EdkLogger as EdkLogger
import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
from Common.StringUtils import ConvertToSqlString
## TableDec
diff --git a/BaseTools/Source/Python/Table/TableDsc.py b/BaseTools/Source/Python/Table/TableDsc.py
index 227748951841..6436973c4534 100644
--- a/BaseTools/Source/Python/Table/TableDsc.py
+++ b/BaseTools/Source/Python/Table/TableDsc.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
## @file
# This file is used to create/update/query/erase table for dsc datas
#
@@ -16,7 +17,7 @@
#
import Common.EdkLogger as EdkLogger
import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
from Common.StringUtils import ConvertToSqlString
## TableDsc
diff --git a/BaseTools/Source/Python/Table/TableEotReport.py b/BaseTools/Source/Python/Table/TableEotReport.py
index e8291b48d7c3..0a490161cda8 100644
--- a/BaseTools/Source/Python/Table/TableEotReport.py
+++ b/BaseTools/Source/Python/Table/TableEotReport.py
@@ -14,9 +14,10 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.EdkLogger as EdkLogger
import Common.LongFilePathOs as os, time
-from Table import Table
+from .Table import Table
from Common.StringUtils import ConvertToSqlString2
import Eot.EotToolError as EotToolError
import Eot.EotGlobalData as EotGlobalData
diff --git a/BaseTools/Source/Python/Table/TableFdf.py b/BaseTools/Source/Python/Table/TableFdf.py
index 872afc79ef44..80be9532cae1 100644
--- a/BaseTools/Source/Python/Table/TableFdf.py
+++ b/BaseTools/Source/Python/Table/TableFdf.py
@@ -14,9 +14,10 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.EdkLogger as EdkLogger
import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
from Common.StringUtils import ConvertToSqlString
## TableFdf
diff --git a/BaseTools/Source/Python/Table/TableFile.py b/BaseTools/Source/Python/Table/TableFile.py
index 34a0b47418dc..689264c2578a 100644
--- a/BaseTools/Source/Python/Table/TableFile.py
+++ b/BaseTools/Source/Python/Table/TableFile.py
@@ -14,8 +14,9 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.EdkLogger as EdkLogger
-from Table import Table
+from .Table import Table
from Common.StringUtils import ConvertToSqlString
import Common.LongFilePathOs as os
from CommonDataClass.DataClass import FileClass
diff --git a/BaseTools/Source/Python/Table/TableFunction.py b/BaseTools/Source/Python/Table/TableFunction.py
index bf301fd2620c..166718060600 100644
--- a/BaseTools/Source/Python/Table/TableFunction.py
+++ b/BaseTools/Source/Python/Table/TableFunction.py
@@ -14,8 +14,9 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.EdkLogger as EdkLogger
-from Table import Table
+from .Table import Table
from Common.StringUtils import ConvertToSqlString
## TableFunction
diff --git a/BaseTools/Source/Python/Table/TableIdentifier.py b/BaseTools/Source/Python/Table/TableIdentifier.py
index 5ce528b26a4c..8b4dd1d310ec 100644
--- a/BaseTools/Source/Python/Table/TableIdentifier.py
+++ b/BaseTools/Source/Python/Table/TableIdentifier.py
@@ -14,9 +14,10 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.EdkLogger as EdkLogger
from Common.StringUtils import ConvertToSqlString
-from Table import Table
+from .Table import Table
## TableIdentifier
#
diff --git a/BaseTools/Source/Python/Table/TableInf.py b/BaseTools/Source/Python/Table/TableInf.py
index c524256a0c5d..a00096ac303a 100644
--- a/BaseTools/Source/Python/Table/TableInf.py
+++ b/BaseTools/Source/Python/Table/TableInf.py
@@ -14,9 +14,10 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.EdkLogger as EdkLogger
import CommonDataClass.DataClass as DataClass
-from Table import Table
+from .Table import Table
from Common.StringUtils import ConvertToSqlString
## TableInf
diff --git a/BaseTools/Source/Python/Table/TablePcd.py b/BaseTools/Source/Python/Table/TablePcd.py
index 689ae22e8996..d58a3ef49e02 100644
--- a/BaseTools/Source/Python/Table/TablePcd.py
+++ b/BaseTools/Source/Python/Table/TablePcd.py
@@ -14,8 +14,9 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.EdkLogger as EdkLogger
-from Table import Table
+from .Table import Table
from Common.StringUtils import ConvertToSqlString
## TablePcd
diff --git a/BaseTools/Source/Python/Table/TableQuery.py b/BaseTools/Source/Python/Table/TableQuery.py
index f377b10561dc..a991e610dafd 100644
--- a/BaseTools/Source/Python/Table/TableQuery.py
+++ b/BaseTools/Source/Python/Table/TableQuery.py
@@ -14,9 +14,10 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.EdkLogger as EdkLogger
from Common.StringUtils import ConvertToSqlString
-from Table import Table
+from .Table import Table
## TableQuery
#
diff --git a/BaseTools/Source/Python/Table/TableReport.py b/BaseTools/Source/Python/Table/TableReport.py
index 1a039249ff26..c4a622953ece 100644
--- a/BaseTools/Source/Python/Table/TableReport.py
+++ b/BaseTools/Source/Python/Table/TableReport.py
@@ -14,9 +14,10 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.EdkLogger as EdkLogger
import Common.LongFilePathOs as os, time
-from Table import Table
+from .Table import Table
from Common.StringUtils import ConvertToSqlString2
import EccToolError as EccToolError
import EccGlobalData as EccGlobalData
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 14/16] BaseTools: Use absolute import in UPT
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (12 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 13/16] BaseTools: Use absolute import in Table Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 15/16] BaseTools: Use absolute import in Workspace Gary Lin
` (2 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Based on "futurize -f libfuturize.fixes.fix_absolute_import
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>
---
BaseTools/Source/Python/UPT/Library/Parsing.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/BaseTools/Source/Python/UPT/Library/Parsing.py b/BaseTools/Source/Python/UPT/Library/Parsing.py
index 5c4666399e29..81729d6cdbf7 100644
--- a/BaseTools/Source/Python/UPT/Library/Parsing.py
+++ b/BaseTools/Source/Python/UPT/Library/Parsing.py
@@ -16,6 +16,7 @@
'''
Parsing
'''
+from __future__ import absolute_import
##
# Import Modules
@@ -42,7 +43,7 @@ from Logger import StringTable as ST
import Logger.Log as Logger
from Parser.DecParser import Dec
-import GlobalData
+from . import GlobalData
gPKG_INFO_DICT = {}
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 15/16] BaseTools: Use absolute import in Workspace
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (13 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 14/16] BaseTools: Use absolute import in UPT Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 10:18 ` [PATCH v2 16/16] BaseTools: Use absolute import in Scripts Gary Lin
2018-07-13 15:07 ` [PATCH v2 00/16] BaseTools: Adopt absolute import Carsey, Jaben
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Based on "futurize -f libfuturize.fixes.fix_absolute_import
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>
---
BaseTools/Source/Python/Workspace/DscBuildData.py | 9 +++++----
BaseTools/Source/Python/Workspace/InfBuildData.py | 3 ++-
BaseTools/Source/Python/Workspace/MetaFileParser.py | 5 +++--
BaseTools/Source/Python/Workspace/MetaFileTable.py | 5 +++--
BaseTools/Source/Python/Workspace/WorkspaceCommon.py | 3 ++-
BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 7 ++++---
6 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 5cc814185eb9..65fc0882d8b4 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -18,6 +18,7 @@
# into PlatformBuildClassObject form for easier use for AutoGen.
#
from __future__ import print_function
+from __future__ import absolute_import
from Common.StringUtils import *
from Common.DataType import *
from Common.Misc import *
@@ -26,11 +27,11 @@ from Common.Expression import *
from CommonDataClass.CommonClass import SkuInfoClass
from Common.TargetTxtClassObject import *
from Common.ToolDefClassObject import *
-from MetaDataTable import *
-from MetaFileTable import *
-from MetaFileParser import *
+from .MetaDataTable import *
+from .MetaFileTable import *
+from .MetaFileParser import *
-from WorkspaceCommon import GetDeclaredPcd
+from .WorkspaceCommon import GetDeclaredPcd
from Common.Misc import AnalyzeDscPcd
from Common.Misc import ProcessDuplicatedInf
import re
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 165e03f78964..f79ffe28d804 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -12,11 +12,12 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
+from __future__ import absolute_import
from Common.StringUtils import *
from Common.DataType import *
from Common.Misc import *
from types import *
-from MetaFileParser import *
+from .MetaFileParser import *
from collections import OrderedDict
from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 0aa72d8302a0..fbfc182c8bff 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -16,6 +16,7 @@
# Import Modules
#
from __future__ import print_function
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import re
import time
@@ -33,8 +34,8 @@ from Common.Expression import *
from CommonDataClass.Exceptions import *
from Common.LongFilePathSupport import OpenLongFilePath as open
from collections import defaultdict
-from MetaFileTable import MetaFileStorage
-from MetaFileCommentParser import CheckInfComment
+from .MetaFileTable import MetaFileStorage
+from .MetaFileCommentParser import CheckInfComment
## RegEx for finding file versions
hexVersionPattern = re.compile(r'0[xX][\da-f-A-F]{5,8}')
diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py
index ee1c7fffca3b..e0a0b8d92351 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileTable.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py
@@ -14,13 +14,14 @@
##
# Import Modules
#
+from __future__ import absolute_import
import uuid
import Common.EdkLogger as EdkLogger
from Common.BuildToolError import FORMAT_INVALID
-from MetaDataTable import Table, TableFile
-from MetaDataTable import ConvertToSqlString
+from .MetaDataTable import Table, TableFile
+from .MetaDataTable import ConvertToSqlString
from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE_INF, \
MODEL_FILE_OTHERS
from Common.DataType import *
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
index e8f159b26204..d987bbf441ea 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
@@ -11,9 +11,10 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
+from __future__ import absolute_import
from collections import OrderedDict, defaultdict
from Common.DataType import SUP_MODULE_USER_DEFINED
-from BuildClassObject import LibraryClassObject
+from .BuildClassObject import LibraryClassObject
import Common.GlobalData as GlobalData
from Workspace.BuildClassObject import StructurePcd
from Common.BuildToolError import RESOURCE_NOT_AVAILABLE
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
index a40ab8fc8c88..e2f373745fc0 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
@@ -15,15 +15,16 @@
##
# Import Modules
#
+from __future__ import absolute_import
import sqlite3
from Common.StringUtils import *
from Common.DataType import *
from Common.Misc import *
from types import *
-from MetaDataTable import *
-from MetaFileTable import *
-from MetaFileParser import *
+from .MetaDataTable import *
+from .MetaFileTable import *
+from .MetaFileParser import *
from Workspace.DecBuildData import DecBuildData
from Workspace.DscBuildData import DscBuildData
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 16/16] BaseTools: Use absolute import in Scripts
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (14 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 15/16] BaseTools: Use absolute import in Workspace Gary Lin
@ 2018-07-13 10:18 ` Gary Lin
2018-07-13 15:07 ` [PATCH v2 00/16] BaseTools: Adopt absolute import Carsey, Jaben
16 siblings, 0 replies; 18+ messages in thread
From: Gary Lin @ 2018-07-13 10:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
Based on "futurize -f libfuturize.fixes.fix_absolute_import
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>
---
BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py | 3 ++-
BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
index b5ab213cd7f0..d1e21135cf05 100644
--- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
+++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
@@ -12,9 +12,10 @@
#
from __future__ import print_function
+from __future__ import absolute_import
import os
-from message import *
+from .message import *
class BaseDoxygeItem:
def __init__(self, name, tag=''):
diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
index ccfef6b6e280..6e6f3f4b9795 100644
--- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
+++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
@@ -11,7 +11,8 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
-from message import *
+from __future__ import absolute_import
+from .message import *
import re
import os
--
2.18.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 00/16] BaseTools: Adopt absolute import
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
` (15 preceding siblings ...)
2018-07-13 10:18 ` [PATCH v2 16/16] BaseTools: Use absolute import in Scripts Gary Lin
@ 2018-07-13 15:07 ` Carsey, Jaben
16 siblings, 0 replies; 18+ messages in thread
From: Carsey, Jaben @ 2018-07-13 15:07 UTC (permalink / raw)
To: Gary Lin, edk2-devel@lists.01.org; +Cc: Gao, Liming
Nice.
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Gary Lin
> Sent: Friday, July 13, 2018 3:19 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [PATCH v2 00/16] BaseTools: Adopt absolute import
>
> v2:
> Treat BPDG and Ecc as python modules since they use the modules in
> its own directory
>
> This patch series is based on "libfuturize.fixes.fix_absolute_import"
> to adopt abolute import since relative import is not allowed in python3.
>
> The command is applied to BaseTools modules individually. Most of the
> patches are straightforward except the GenFds patches. It's because
> there are several circular imports in GenFds and circular import is not
> compatible with absolute import. To make the patches bisectable, I delay
> the import of some modules in the first GenFds patch and refactor the
> code in the follow-up patches to remove circular import completely.
>
> The patch set is also available in my github branch:
>
> https://github.com/lcp/edk2/tree/python3-absolute-import-v2
>
> 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>
>
> Gary Lin (16):
> BaseTools: Treat GenFds.py as a python module
> BaseTools: Use absolute import in GenFds
> BaseTools: Move OverrideAttribs to OptRomInfStatement.py
> BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py
> BaseTools: Move ImageBinDict to GenFdsGlobalVariable.py
> BaseTools: Use absolute import in AutoGen
> BaseTools: Treat BPDG.py as a python module
> BaseTools: Use absolute import in BPDG
> BaseTools: Use absolute import in Common
> BaseTools: Treat Ecc.py as a python module
> BaseTools: Use absolute import in Ecc
> BaseTools: Use absolute import in Eot
> BaseTools: Use absolute import in Table
> BaseTools: Use absolute import in UPT
> BaseTools: Use absolute import in Workspace
> BaseTools: Use absolute import in Scripts
>
> BaseTools/BinWrappers/PosixLike/BPDG | 2 +-
> BaseTools/BinWrappers/PosixLike/Ecc | 2 +-
> BaseTools/BinWrappers/PosixLike/GenFds | 2 +-
> BaseTools/BinWrappers/WindowsLike/BPDG.bat | 3 +-
> BaseTools/BinWrappers/WindowsLike/Ecc.bat | 3 +-
> BaseTools/BinWrappers/WindowsLike/GenFds.bat | 3 +-
> .../plugins/EdkPlugins/basemodel/doxygen.py | 3 +-
> .../plugins/EdkPlugins/basemodel/ini.py | 3 +-
> BaseTools/Source/Python/AutoGen/AutoGen.py | 17 +--
> BaseTools/Source/Python/AutoGen/GenC.py | 7 +-
> BaseTools/Source/Python/AutoGen/GenMake.py | 3 +-
> BaseTools/Source/Python/AutoGen/GenPcdDb.py | 7 +-
> .../Source/Python/AutoGen/IdfClassObject.py | 3 +-
> BaseTools/Source/Python/AutoGen/StrGather.py | 3 +-
> BaseTools/Source/Python/BPDG/BPDG.py | 5 +-
> BaseTools/Source/Python/BPDG/GenVpd.py | 3 +-
> BaseTools/Source/Python/Common/Database.py | 8 +-
> BaseTools/Source/Python/Common/EdkLogger.py | 3 +-
> BaseTools/Source/Python/Common/Expression.py | 3 +-
> .../Source/Python/Common/LongFilePathOs.py | 3 +-
> BaseTools/Source/Python/Common/Misc.py | 9 +-
> BaseTools/Source/Python/Common/Parsing.py | 5 +-
> BaseTools/Source/Python/Common/StringUtils.py | 9 +-
> .../Python/Common/TargetTxtClassObject.py | 9 +-
> .../Python/Common/ToolDefClassObject.py | 9 +-
> BaseTools/Source/Python/Ecc/CParser.py | 5 +-
> BaseTools/Source/Python/Ecc/Check.py | 9 +-
> .../Python/Ecc/CodeFragmentCollector.py | 13 ++-
> BaseTools/Source/Python/Ecc/Database.py | 7 +-
> BaseTools/Source/Python/Ecc/Ecc.py | 25 +++--
> BaseTools/Source/Python/Ecc/Exception.py | 3 +-
> BaseTools/Source/Python/Ecc/FileProfile.py | 5 +-
> BaseTools/Source/Python/Ecc/MetaDataParser.py | 5 +-
> .../Ecc/MetaFileWorkspace/MetaFileParser.py | 3 +-
> .../Ecc/MetaFileWorkspace/MetaFileTable.py | 5 +-
> BaseTools/Source/Python/Ecc/c.py | 13 ++-
> BaseTools/Source/Python/Eot/CParser.py | 5 +-
> .../Python/Eot/CodeFragmentCollector.py | 11 +-
> BaseTools/Source/Python/Eot/Eot.py | 21 ++--
> BaseTools/Source/Python/Eot/FileProfile.py | 3 +-
> BaseTools/Source/Python/Eot/InfParserLite.py | 5 +-
> BaseTools/Source/Python/Eot/Parser.py | 3 +-
> BaseTools/Source/Python/Eot/Report.py | 3 +-
> BaseTools/Source/Python/Eot/c.py | 9 +-
> .../Source/Python/GenFds/AprioriSection.py | 5 +-
> BaseTools/Source/Python/GenFds/Capsule.py | 12 +-
> BaseTools/Source/Python/GenFds/CapsuleData.py | 5 +-
> .../Source/Python/GenFds/CompressSection.py | 7 +-
> BaseTools/Source/Python/GenFds/DataSection.py | 7 +-
> .../Source/Python/GenFds/DepexSection.py | 7 +-
> BaseTools/Source/Python/GenFds/EfiSection.py | 7 +-
> BaseTools/Source/Python/GenFds/Fd.py | 22 ++--
> BaseTools/Source/Python/GenFds/FdfParser.py | 57 +++++-----
> .../Source/Python/GenFds/FfsFileStatement.py | 11 +-
> .../Source/Python/GenFds/FfsInfStatement.py | 19 ++--
> BaseTools/Source/Python/GenFds/Fv.py | 20 ++--
> .../Source/Python/GenFds/FvImageSection.py | 7 +-
> BaseTools/Source/Python/GenFds/GenFds.py | 105 +-----------------
> .../Python/GenFds/GenFdsGlobalVariable.py | 97 +++++++++++++++-
> BaseTools/Source/Python/GenFds/GuidSection.py | 11 +-
> .../Python/GenFds/OptRomFileStatement.py | 3 +-
> .../Python/GenFds/OptRomInfStatement.py | 27 +++--
> BaseTools/Source/Python/GenFds/OptionRom.py | 6 +-
> BaseTools/Source/Python/GenFds/Region.py | 3 +-
> .../Source/Python/GenFds/RuleComplexFile.py | 3 +-
> .../Source/Python/GenFds/RuleSimpleFile.py | 3 +-
> BaseTools/Source/Python/GenFds/Section.py | 3 +-
> BaseTools/Source/Python/GenFds/UiSection.py | 7 +-
> BaseTools/Source/Python/GenFds/VerSection.py | 7 +-
> BaseTools/Source/Python/GenFds/Vtf.py | 3 +-
> .../Source/Python/Table/TableDataModel.py | 3 +-
> BaseTools/Source/Python/Table/TableDec.py | 3 +-
> BaseTools/Source/Python/Table/TableDsc.py | 3 +-
> .../Source/Python/Table/TableEotReport.py | 3 +-
> BaseTools/Source/Python/Table/TableFdf.py | 3 +-
> BaseTools/Source/Python/Table/TableFile.py | 3 +-
> .../Source/Python/Table/TableFunction.py | 3 +-
> .../Source/Python/Table/TableIdentifier.py | 3 +-
> BaseTools/Source/Python/Table/TableInf.py | 3 +-
> BaseTools/Source/Python/Table/TablePcd.py | 3 +-
> BaseTools/Source/Python/Table/TableQuery.py | 3 +-
> BaseTools/Source/Python/Table/TableReport.py | 3 +-
> .../Source/Python/UPT/Library/Parsing.py | 3 +-
> .../Source/Python/Workspace/DscBuildData.py | 9 +-
> .../Source/Python/Workspace/InfBuildData.py | 3 +-
> .../Source/Python/Workspace/MetaFileParser.py | 5 +-
> .../Source/Python/Workspace/MetaFileTable.py | 5 +-
> .../Python/Workspace/WorkspaceCommon.py | 3 +-
> .../Python/Workspace/WorkspaceDatabase.py | 7 +-
> 89 files changed, 452 insertions(+), 363 deletions(-)
>
> --
> 2.18.0
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2018-07-13 15:07 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
2018-07-13 10:18 ` [PATCH v2 01/16] BaseTools: Treat GenFds.py as a python module Gary Lin
2018-07-13 10:18 ` [PATCH v2 02/16] BaseTools: Use absolute import in GenFds Gary Lin
2018-07-13 10:18 ` [PATCH v2 03/16] BaseTools: Move OverrideAttribs to OptRomInfStatement.py Gary Lin
2018-07-13 10:18 ` [PATCH v2 04/16] BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py Gary Lin
2018-07-13 10:18 ` [PATCH v2 05/16] BaseTools: Move ImageBinDict " Gary Lin
2018-07-13 10:18 ` [PATCH v2 06/16] BaseTools: Use absolute import in AutoGen Gary Lin
2018-07-13 10:18 ` [PATCH v2 07/16] BaseTools: Treat BPDG.py as a python module Gary Lin
2018-07-13 10:18 ` [PATCH v2 08/16] BaseTools: Use absolute import in BPDG Gary Lin
2018-07-13 10:18 ` [PATCH v2 09/16] BaseTools: Use absolute import in Common Gary Lin
2018-07-13 10:18 ` [PATCH v2 10/16] BaseTools: Treat Ecc.py as a python module Gary Lin
2018-07-13 10:18 ` [PATCH v2 11/16] BaseTools: Use absolute import in Ecc Gary Lin
2018-07-13 10:18 ` [PATCH v2 12/16] BaseTools: Use absolute import in Eot Gary Lin
2018-07-13 10:18 ` [PATCH v2 13/16] BaseTools: Use absolute import in Table Gary Lin
2018-07-13 10:18 ` [PATCH v2 14/16] BaseTools: Use absolute import in UPT Gary Lin
2018-07-13 10:18 ` [PATCH v2 15/16] BaseTools: Use absolute import in Workspace Gary Lin
2018-07-13 10:18 ` [PATCH v2 16/16] BaseTools: Use absolute import in Scripts Gary Lin
2018-07-13 15:07 ` [PATCH v2 00/16] BaseTools: Adopt absolute import Carsey, Jaben
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox