From: Gary Lin <glin@suse.com>
To: edk2-devel@lists.01.org
Cc: Yonghong Zhu <yonghong.zhu@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [PATCH v2 02/16] BaseTools: Use absolute import in GenFds
Date: Fri, 13 Jul 2018 18:18:33 +0800 [thread overview]
Message-ID: <20180713101847.7485-3-glin@suse.com> (raw)
In-Reply-To: <20180713101847.7485-1-glin@suse.com>
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
next prev parent reply other threads:[~2018-07-13 10:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180713101847.7485-3-glin@suse.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox