summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsey, Jaben <jaben.carsey@intel.com>2019-01-10 03:00:41 +0800
committerBobCF <bob.c.feng@intel.com>2019-01-10 22:01:11 +0800
commit938cf4c33a0695ef1011b07e455a7ec2f87b5ad3 (patch)
tree54d533d009cb2e8952608eefe2baf6200971d2b1
parenta53a888de8f5fa8dbf75a381e28f25a5497572f1 (diff)
downloadedk2-938cf4c33a0695ef1011b07e455a7ec2f87b5ad3.tar.gz
edk2-938cf4c33a0695ef1011b07e455a7ec2f87b5ad3.tar.bz2
edk2-938cf4c33a0695ef1011b07e455a7ec2f87b5ad3.zip
BaseTools: fix imports
1 - Some of these imports are cascaded from another file. Import them locally. 2 - Some of these imports are not used. Remove them. 3 - Some of these were missing the namespace used to import them. These changes facilitate optimization of BaseTools: https://bugzilla.tianocore.org/show_bug.cgi?id=42 Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-rw-r--r--BaseTools/Source/Python/AutoGen/AutoGen.py6
-rw-r--r--BaseTools/Source/Python/AutoGen/GenC.py2
-rw-r--r--BaseTools/Source/Python/AutoGen/GenPcdDb.py3
-rw-r--r--BaseTools/Source/Python/Common/RangeExpression.py3
-rw-r--r--BaseTools/Source/Python/Common/ToolDefClassObject.py4
-rw-r--r--BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py4
-rw-r--r--BaseTools/Source/Python/GenFds/FdfParser.py4
-rw-r--r--BaseTools/Source/Python/GenFds/FfsInfStatement.py3
-rw-r--r--BaseTools/Source/Python/GenFds/GenFds.py2
-rw-r--r--BaseTools/Source/Python/GenFds/GuidSection.py1
-rw-r--r--BaseTools/Source/Python/Workspace/DecBuildData.py9
-rw-r--r--BaseTools/Source/Python/Workspace/DscBuildData.py4
-rw-r--r--BaseTools/Source/Python/Workspace/MetaFileParser.py9
-rw-r--r--BaseTools/Source/Python/build/build.py16
14 files changed, 38 insertions, 32 deletions
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index d646cd50ce..acd34692b6 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1,7 +1,7 @@
## @file
# Generate AutoGen.h, AutoGen.c and *.depex files
#
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.<BR>
#
# This program and the accompanying materials
@@ -52,6 +52,7 @@ from .GenVar import VariableMgr, var_info
from collections import OrderedDict
from collections import defaultdict
from Workspace.WorkspaceCommon import OrderedListDict
+from Common.ToolDefClassObject import gDefaultToolsDefFile
from Common.caching import cached_property, cached_class_function
@@ -85,9 +86,6 @@ gMakeTypeMap = {TAB_COMPILER_MSFT:"nmake", "GCC":"gmake"}
## Build rule configuration file
gDefaultBuildRuleFile = 'build_rule.txt'
-## Tools definition configuration file
-gDefaultToolsDefFile = 'tools_def.txt'
-
## Build rule default version
AutoGenReqBuildRuleVerNum = "0.1"
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 09626d0b96..e224568db1 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -18,7 +18,7 @@ import string
import collections
import struct
from Common import EdkLogger
-
+from Common import GlobalData
from Common.BuildToolError import *
from Common.DataType import *
from Common.Misc import *
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index 876fcf1efb..a9068d2d7a 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -22,6 +22,9 @@ from Common.VariableAttributes import VariableAttributes
import copy
from struct import unpack
from Common.DataType import *
+from Common import GlobalData
+from Common import EdkLogger
+import Common.LongFilePathOs as os
DATABASE_VERSION = 7
diff --git a/BaseTools/Source/Python/Common/RangeExpression.py b/BaseTools/Source/Python/Common/RangeExpression.py
index 407dc06ccf..40958451d2 100644
--- a/BaseTools/Source/Python/Common/RangeExpression.py
+++ b/BaseTools/Source/Python/Common/RangeExpression.py
@@ -19,6 +19,7 @@ from CommonDataClass.Exceptions import WrnExpression
import uuid
from Common.Expression import PcdPattern, BaseExpression
from Common.DataType import *
+from re import compile
ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].'
ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].'
@@ -202,7 +203,7 @@ class RangeExpression(BaseExpression):
NonLetterOpLst = ['+', '-', '&', '|', '^', '!', '=', '>', '<']
- RangePattern = re.compile(r'[0-9]+ - [0-9]+')
+ RangePattern = compile(r'[0-9]+ - [0-9]+')
def preProcessRangeExpr(self, expr):
# convert hex to int
diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py
index 186d279840..0a78123e2c 100644
--- a/BaseTools/Source/Python/Common/ToolDefClassObject.py
+++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py
@@ -1,7 +1,7 @@
## @file
# This file is used to define each component of tools_def.txt file
#
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -20,7 +20,7 @@ import re
from . import EdkLogger
from .BuildToolError import *
-from .TargetTxtClassObject import *
+from Common.TargetTxtClassObject import TargetTxtDict
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.Misc import PathClass
from Common.StringUtils import NormPath
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
index 52a78bcbb8..283789fd1d 100644
--- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
@@ -40,7 +40,7 @@ from Common.LongFilePathSupport import CodecOpenLongFilePath
## A decorator used to parse macro definition
def ParseMacro(Parser):
def MacroParser(self):
- Match = gMacroDefPattern.match(self._CurrentLine)
+ Match = GlobalData.gMacroDefPattern.match(self._CurrentLine)
if not Match:
# Not 'DEFINE/EDK_GLOBAL' statement, call decorated method
Parser(self)
@@ -61,7 +61,7 @@ def ParseMacro(Parser):
EdkLogger.error('Parser', FORMAT_INVALID, "%s can only be defined via environment variable" % Name,
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1)
# Only upper case letters, digit and '_' are allowed
- if not gMacroNamePattern.match(Name):
+ if not GlobalData.gMacroNamePattern.match(Name):
EdkLogger.error('Parser', FORMAT_INVALID, "The macro name must be in the pattern [A-Z][A-Z0-9_]*",
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1)
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index de0b166030..d54e4bd031 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1101,7 +1101,7 @@ class FdfParser:
def _GetNextGuid(self):
if not self._GetNextToken():
return False
- if gGuidPattern.match(self._Token) is not None:
+ if GlobalData.gGuidPattern.match(self._Token) is not None:
return True
else:
self._UndoToken()
@@ -1169,7 +1169,7 @@ class FdfParser:
def _GetNextHexNumber(self):
if not self._GetNextToken():
return False
- if gHexPatternAll.match(self._Token):
+ if GlobalData.gHexPatternAll.match(self._Token):
return True
else:
self._UndoToken()
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index d4c61c0749..4dda3cf787 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -30,6 +30,7 @@ from . import RuleSimpleFile
from . import RuleComplexFile
from CommonDataClass.FdfClass import FfsInfStatementClassObject
from Common.MultipleWorkspace import MultipleWorkspace as mws
+from Common.DataType import SUP_MODULE_USER_DEFINED
from Common.StringUtils import *
from Common.Misc import PathClass
from Common.Misc import GuidStructureByteArrayToGuidString
@@ -94,7 +95,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
ModuleType = self.InfModule.ModuleType
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
- if ModuleType != DataType.SUP_MODULE_USER_DEFINED:
+ if ModuleType != SUP_MODULE_USER_DEFINED:
for LibraryClass in PlatformDataBase.LibraryClasses.GetKeys():
if LibraryClass.startswith("NULL") and PlatformDataBase.LibraryClasses[LibraryClass, ModuleType]:
self.InfModule.LibraryClasses[LibraryClass] = PlatformDataBase.LibraryClasses[LibraryClass, ModuleType]
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index 447aa7f5eb..d32325e894 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -1,7 +1,7 @@
## @file
# generate flash image
#
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Source/Python/GenFds/GuidSection.py
index 25609e6f2a..52b97300ec 100644
--- a/BaseTools/Source/Python/GenFds/GuidSection.py
+++ b/BaseTools/Source/Python/GenFds/GuidSection.py
@@ -24,7 +24,6 @@ import Common.LongFilePathOs as os
from .GenFdsGlobalVariable import GenFdsGlobalVariable
from .GenFdsGlobalVariable import FindExtendTool
from CommonDataClass.FdfClass import GuidSectionClassObject
-from Common import ToolDefClassObject
import sys
from Common import EdkLogger
from Common.BuildToolError import *
diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py
index cc00409fee..13b653bd98 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -16,8 +16,10 @@ from Common.DataType import *
from Common.Misc import *
from types import *
from collections import OrderedDict
-
+from CommonDataClass.DataClass import *
from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject
+from Common.GlobalData import gGlobalDefines, gEcpSource
+from re import compile
## Platform build information from DEC file
#
@@ -109,7 +111,7 @@ class DecBuildData(PackageBuildClassObject):
@property
def _Macros(self):
if self._MacroDict is None:
- self._MacroDict = dict(GlobalData.gGlobalDefines)
+ self._MacroDict = dict(gGlobalDefines)
return self._MacroDict
## Get architecture
@@ -298,7 +300,7 @@ class DecBuildData(PackageBuildClassObject):
PublicInclues = []
RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch]
Macros = self._Macros
- Macros["EDK_SOURCE"] = GlobalData.gEcpSource
+ Macros["EDK_SOURCE"] = gEcpSource
for Record in RecordList:
File = PathClass(NormPath(Record[0], Macros), self._PackageDir, Arch=self._Arch)
LineNo = Record[-1]
@@ -464,6 +466,7 @@ class DecBuildData(PackageBuildClassObject):
StructurePcds = self.ProcessStructurePcd(StrPcdSet)
for pcd in StructurePcds:
Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd
+ StructPattern = compile(r'[_a-zA-Z][0-9A-Za-z_]*$')
for pcd in Pcds.values():
if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:
if not pcd.IsAggregateDatumType():
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 7e82e8e934..3b0b23ca8f 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -25,8 +25,8 @@ from Common.Misc import *
from types import *
from Common.Expression import *
from CommonDataClass.CommonClass import SkuInfoClass
-from Common.TargetTxtClassObject import *
-from Common.ToolDefClassObject import *
+from Common.TargetTxtClassObject import TargetTxtClassObject
+from Common.ToolDefClassObject import ToolDefClassObject
from .MetaDataTable import *
from .MetaFileTable import *
from .MetaFileParser import *
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 032220813b..02c8d7bbb5 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -36,6 +36,7 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
from collections import defaultdict
from .MetaFileTable import MetaFileStorage
from .MetaFileCommentParser import CheckInfComment
+from Common.DataType import TAB_COMMENT_EDK_START, TAB_COMMENT_EDK_END
## RegEx for finding file versions
hexVersionPattern = re.compile(r'0[xX][\da-f-A-F]{5,8}')
@@ -45,7 +46,7 @@ CODEPattern = re.compile(r"{CODE\([a-fA-F0-9Xx\{\},\s]*\)}")
## A decorator used to parse macro definition
def ParseMacro(Parser):
def MacroParser(self):
- Match = gMacroDefPattern.match(self._CurrentLine)
+ Match = GlobalData.gMacroDefPattern.match(self._CurrentLine)
if not Match:
# Not 'DEFINE/EDK_GLOBAL' statement, call decorated method
Parser(self)
@@ -66,7 +67,7 @@ def ParseMacro(Parser):
EdkLogger.error('Parser', FORMAT_INVALID, "%s can only be defined via environment variable" % Name,
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
# Only upper case letters, digit and '_' are allowed
- if not gMacroNamePattern.match(Name):
+ if not GlobalData.gMacroNamePattern.match(Name):
EdkLogger.error('Parser', FORMAT_INVALID, "The macro name must be in the pattern [A-Z][A-Z0-9_]*",
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
@@ -562,10 +563,10 @@ class InfParser(MetaFileParser):
SectionComments.extend(Comments)
Comments = []
continue
- if Line.find(DataType.TAB_COMMENT_EDK_START) > -1:
+ if Line.find(TAB_COMMENT_EDK_START) > -1:
IsFindBlockComment = True
continue
- if Line.find(DataType.TAB_COMMENT_EDK_END) > -1:
+ if Line.find(TAB_COMMENT_EDK_END) > -1:
IsFindBlockComment = False
continue
if IsFindBlockComment:
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 97271e634e..b992a4c1b3 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -37,8 +37,8 @@ from subprocess import *
from Common import Misc as Utils
from Common.LongFilePathSupport import OpenLongFilePath as open
-from Common.TargetTxtClassObject import *
-from Common.ToolDefClassObject import *
+from Common.TargetTxtClassObject import TargetTxtClassObject
+from Common.ToolDefClassObject import ToolDefClassObject
from Common.DataType import *
from Common.BuildVersion import gBUILD_VERSION
from AutoGen.AutoGen import *
@@ -884,7 +884,7 @@ class Build():
if os.path.isfile(BuildConfigurationFile) == True:
StatusCode = self.TargetTxt.LoadTargetTxtFile(BuildConfigurationFile)
- ToolDefinitionFile = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]
+ ToolDefinitionFile = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_TOOL_CHAIN_CONF]
if ToolDefinitionFile == '':
ToolDefinitionFile = gToolsDefinition
ToolDefinitionFile = os.path.normpath(mws.join(self.WorkspaceDir, 'Conf', ToolDefinitionFile))
@@ -897,16 +897,16 @@ class Build():
# if no ARCH given in command line, get it from target.txt
if not self.ArchList:
- self.ArchList = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET_ARCH]
+ self.ArchList = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_TARGET_ARCH]
self.ArchList = tuple(self.ArchList)
# if no build target given in command line, get it from target.txt
if not self.BuildTargetList:
- self.BuildTargetList = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET]
+ self.BuildTargetList = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_TARGET]
# if no tool chain given in command line, get it from target.txt
if not self.ToolChainList:
- self.ToolChainList = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG]
+ self.ToolChainList = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_TOOL_CHAIN_TAG]
if self.ToolChainList is None or len(self.ToolChainList) == 0:
EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, ExtraData="No toolchain given. Don't know how to build.\n")
@@ -936,7 +936,7 @@ class Build():
self.ToolChainFamily = ToolChainFamily
if self.ThreadNumber is None:
- self.ThreadNumber = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER]
+ self.ThreadNumber = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER]
if self.ThreadNumber == '':
self.ThreadNumber = 0
else:
@@ -949,7 +949,7 @@ class Build():
self.ThreadNumber = 1
if not self.PlatformFile:
- PlatformFile = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM]
+ PlatformFile = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_ACTIVE_PLATFORM]
if not PlatformFile:
# Try to find one in current directory
WorkingDirectory = os.getcwd()