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>
14 files changed:
## @file\r
# Generate AutoGen.h, AutoGen.c and *.depex files\r
#\r
## @file\r
# Generate AutoGen.h, AutoGen.c and *.depex files\r
#\r
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>\r
# Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.<BR>\r
#\r
# This program and the accompanying materials\r
# Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.<BR>\r
#\r
# This program and the accompanying materials\r
from collections import OrderedDict\r
from collections import defaultdict\r
from Workspace.WorkspaceCommon import OrderedListDict\r
from collections import OrderedDict\r
from collections import defaultdict\r
from Workspace.WorkspaceCommon import OrderedListDict\r
+from Common.ToolDefClassObject import gDefaultToolsDefFile\r
\r
from Common.caching import cached_property, cached_class_function\r
\r
\r
from Common.caching import cached_property, cached_class_function\r
\r
## Build rule configuration file\r
gDefaultBuildRuleFile = 'build_rule.txt'\r
\r
## Build rule configuration file\r
gDefaultBuildRuleFile = 'build_rule.txt'\r
\r
-## Tools definition configuration file\r
-gDefaultToolsDefFile = 'tools_def.txt'\r
-\r
## Build rule default version\r
AutoGenReqBuildRuleVerNum = "0.1"\r
\r
## Build rule default version\r
AutoGenReqBuildRuleVerNum = "0.1"\r
\r
import collections\r
import struct\r
from Common import EdkLogger\r
import collections\r
import struct\r
from Common import EdkLogger\r
+from Common import GlobalData\r
from Common.BuildToolError import *\r
from Common.DataType import *\r
from Common.Misc import *\r
from Common.BuildToolError import *\r
from Common.DataType import *\r
from Common.Misc import *\r
import copy\r
from struct import unpack\r
from Common.DataType import *\r
import copy\r
from struct import unpack\r
from Common.DataType import *\r
+from Common import GlobalData\r
+from Common import EdkLogger\r
+import Common.LongFilePathOs as os\r
\r
DATABASE_VERSION = 7\r
\r
\r
DATABASE_VERSION = 7\r
\r
import uuid\r
from Common.Expression import PcdPattern, BaseExpression\r
from Common.DataType import *\r
import uuid\r
from Common.Expression import PcdPattern, BaseExpression\r
from Common.DataType import *\r
+from re import compile\r
\r
ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].'\r
ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].'\r
\r
ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].'\r
ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].'\r
\r
NonLetterOpLst = ['+', '-', '&', '|', '^', '!', '=', '>', '<']\r
\r
\r
NonLetterOpLst = ['+', '-', '&', '|', '^', '!', '=', '>', '<']\r
\r
- RangePattern = re.compile(r'[0-9]+ - [0-9]+')\r
+ RangePattern = compile(r'[0-9]+ - [0-9]+')\r
\r
def preProcessRangeExpr(self, expr):\r
# convert hex to int\r
\r
def preProcessRangeExpr(self, expr):\r
# convert hex to int\r
## @file\r
# This file is used to define each component of tools_def.txt file\r
#\r
## @file\r
# This file is used to define each component of tools_def.txt file\r
#\r
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
from . import EdkLogger\r
\r
from .BuildToolError import *\r
from . import EdkLogger\r
\r
from .BuildToolError import *\r
-from .TargetTxtClassObject import *\r
+from Common.TargetTxtClassObject import TargetTxtDict\r
from Common.LongFilePathSupport import OpenLongFilePath as open\r
from Common.Misc import PathClass\r
from Common.StringUtils import NormPath\r
from Common.LongFilePathSupport import OpenLongFilePath as open\r
from Common.Misc import PathClass\r
from Common.StringUtils import NormPath\r
## A decorator used to parse macro definition\r
def ParseMacro(Parser):\r
def MacroParser(self):\r
## A decorator used to parse macro definition\r
def ParseMacro(Parser):\r
def MacroParser(self):\r
- Match = gMacroDefPattern.match(self._CurrentLine)\r
+ Match = GlobalData.gMacroDefPattern.match(self._CurrentLine)\r
if not Match:\r
# Not 'DEFINE/EDK_GLOBAL' statement, call decorated method\r
Parser(self)\r
if not Match:\r
# Not 'DEFINE/EDK_GLOBAL' statement, call decorated method\r
Parser(self)\r
EdkLogger.error('Parser', FORMAT_INVALID, "%s can only be defined via environment variable" % Name,\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1)\r
# Only upper case letters, digit and '_' are allowed\r
EdkLogger.error('Parser', FORMAT_INVALID, "%s can only be defined via environment variable" % Name,\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1)\r
# Only upper case letters, digit and '_' are allowed\r
- if not gMacroNamePattern.match(Name):\r
+ if not GlobalData.gMacroNamePattern.match(Name):\r
EdkLogger.error('Parser', FORMAT_INVALID, "The macro name must be in the pattern [A-Z][A-Z0-9_]*",\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1)\r
\r
EdkLogger.error('Parser', FORMAT_INVALID, "The macro name must be in the pattern [A-Z][A-Z0-9_]*",\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1)\r
\r
def _GetNextGuid(self):\r
if not self._GetNextToken():\r
return False\r
def _GetNextGuid(self):\r
if not self._GetNextToken():\r
return False\r
- if gGuidPattern.match(self._Token) is not None:\r
+ if GlobalData.gGuidPattern.match(self._Token) is not None:\r
return True\r
else:\r
self._UndoToken()\r
return True\r
else:\r
self._UndoToken()\r
def _GetNextHexNumber(self):\r
if not self._GetNextToken():\r
return False\r
def _GetNextHexNumber(self):\r
if not self._GetNextToken():\r
return False\r
- if gHexPatternAll.match(self._Token):\r
+ if GlobalData.gHexPatternAll.match(self._Token):\r
return True\r
else:\r
self._UndoToken()\r
return True\r
else:\r
self._UndoToken()\r
from . import RuleComplexFile\r
from CommonDataClass.FdfClass import FfsInfStatementClassObject\r
from Common.MultipleWorkspace import MultipleWorkspace as mws\r
from . import RuleComplexFile\r
from CommonDataClass.FdfClass import FfsInfStatementClassObject\r
from Common.MultipleWorkspace import MultipleWorkspace as mws\r
+from Common.DataType import SUP_MODULE_USER_DEFINED\r
from Common.StringUtils import *\r
from Common.Misc import PathClass\r
from Common.Misc import GuidStructureByteArrayToGuidString\r
from Common.StringUtils import *\r
from Common.Misc import PathClass\r
from Common.Misc import GuidStructureByteArrayToGuidString\r
ModuleType = self.InfModule.ModuleType\r
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
\r
ModuleType = self.InfModule.ModuleType\r
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
\r
- if ModuleType != DataType.SUP_MODULE_USER_DEFINED:\r
+ if ModuleType != SUP_MODULE_USER_DEFINED:\r
for LibraryClass in PlatformDataBase.LibraryClasses.GetKeys():\r
if LibraryClass.startswith("NULL") and PlatformDataBase.LibraryClasses[LibraryClass, ModuleType]:\r
self.InfModule.LibraryClasses[LibraryClass] = PlatformDataBase.LibraryClasses[LibraryClass, ModuleType]\r
for LibraryClass in PlatformDataBase.LibraryClasses.GetKeys():\r
if LibraryClass.startswith("NULL") and PlatformDataBase.LibraryClasses[LibraryClass, ModuleType]:\r
self.InfModule.LibraryClasses[LibraryClass] = PlatformDataBase.LibraryClasses[LibraryClass, ModuleType]\r
## @file\r
# generate flash image\r
#\r
## @file\r
# generate flash image\r
#\r
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
#\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
from .GenFdsGlobalVariable import FindExtendTool\r
from CommonDataClass.FdfClass import GuidSectionClassObject\r
from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
from .GenFdsGlobalVariable import FindExtendTool\r
from CommonDataClass.FdfClass import GuidSectionClassObject\r
-from Common import ToolDefClassObject\r
import sys\r
from Common import EdkLogger\r
from Common.BuildToolError import *\r
import sys\r
from Common import EdkLogger\r
from Common.BuildToolError import *\r
from Common.Misc import *\r
from types import *\r
from collections import OrderedDict\r
from Common.Misc import *\r
from types import *\r
from collections import OrderedDict\r
+from CommonDataClass.DataClass import *\r
from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject\r
from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject\r
+from Common.GlobalData import gGlobalDefines, gEcpSource\r
+from re import compile\r
\r
## Platform build information from DEC file\r
#\r
\r
## Platform build information from DEC file\r
#\r
@property\r
def _Macros(self):\r
if self._MacroDict is None:\r
@property\r
def _Macros(self):\r
if self._MacroDict is None:\r
- self._MacroDict = dict(GlobalData.gGlobalDefines)\r
+ self._MacroDict = dict(gGlobalDefines)\r
return self._MacroDict\r
\r
## Get architecture\r
return self._MacroDict\r
\r
## Get architecture\r
PublicInclues = []\r
RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch]\r
Macros = self._Macros\r
PublicInclues = []\r
RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch]\r
Macros = self._Macros\r
- Macros["EDK_SOURCE"] = GlobalData.gEcpSource\r
+ Macros["EDK_SOURCE"] = gEcpSource\r
for Record in RecordList:\r
File = PathClass(NormPath(Record[0], Macros), self._PackageDir, Arch=self._Arch)\r
LineNo = Record[-1]\r
for Record in RecordList:\r
File = PathClass(NormPath(Record[0], Macros), self._PackageDir, Arch=self._Arch)\r
LineNo = Record[-1]\r
StructurePcds = self.ProcessStructurePcd(StrPcdSet)\r
for pcd in StructurePcds:\r
Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd\r
StructurePcds = self.ProcessStructurePcd(StrPcdSet)\r
for pcd in StructurePcds:\r
Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd\r
+ StructPattern = compile(r'[_a-zA-Z][0-9A-Za-z_]*$')\r
for pcd in Pcds.values():\r
if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
if not pcd.IsAggregateDatumType():\r
for pcd in Pcds.values():\r
if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
if not pcd.IsAggregateDatumType():\r
from types import *\r
from Common.Expression import *\r
from CommonDataClass.CommonClass import SkuInfoClass\r
from types import *\r
from Common.Expression import *\r
from CommonDataClass.CommonClass import SkuInfoClass\r
-from Common.TargetTxtClassObject import *\r
-from Common.ToolDefClassObject import *\r
+from Common.TargetTxtClassObject import TargetTxtClassObject\r
+from Common.ToolDefClassObject import ToolDefClassObject\r
from .MetaDataTable import *\r
from .MetaFileTable import *\r
from .MetaFileParser import *\r
from .MetaDataTable import *\r
from .MetaFileTable import *\r
from .MetaFileParser import *\r
from collections import defaultdict\r
from .MetaFileTable import MetaFileStorage\r
from .MetaFileCommentParser import CheckInfComment\r
from collections import defaultdict\r
from .MetaFileTable import MetaFileStorage\r
from .MetaFileCommentParser import CheckInfComment\r
+from Common.DataType import TAB_COMMENT_EDK_START, TAB_COMMENT_EDK_END\r
\r
## RegEx for finding file versions\r
hexVersionPattern = re.compile(r'0[xX][\da-f-A-F]{5,8}')\r
\r
## RegEx for finding file versions\r
hexVersionPattern = re.compile(r'0[xX][\da-f-A-F]{5,8}')\r
## A decorator used to parse macro definition\r
def ParseMacro(Parser):\r
def MacroParser(self):\r
## A decorator used to parse macro definition\r
def ParseMacro(Parser):\r
def MacroParser(self):\r
- Match = gMacroDefPattern.match(self._CurrentLine)\r
+ Match = GlobalData.gMacroDefPattern.match(self._CurrentLine)\r
if not Match:\r
# Not 'DEFINE/EDK_GLOBAL' statement, call decorated method\r
Parser(self)\r
if not Match:\r
# Not 'DEFINE/EDK_GLOBAL' statement, call decorated method\r
Parser(self)\r
EdkLogger.error('Parser', FORMAT_INVALID, "%s can only be defined via environment variable" % Name,\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
# Only upper case letters, digit and '_' are allowed\r
EdkLogger.error('Parser', FORMAT_INVALID, "%s can only be defined via environment variable" % Name,\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
# Only upper case letters, digit and '_' are allowed\r
- if not gMacroNamePattern.match(Name):\r
+ if not GlobalData.gMacroNamePattern.match(Name):\r
EdkLogger.error('Parser', FORMAT_INVALID, "The macro name must be in the pattern [A-Z][A-Z0-9_]*",\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
\r
EdkLogger.error('Parser', FORMAT_INVALID, "The macro name must be in the pattern [A-Z][A-Z0-9_]*",\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
\r
SectionComments.extend(Comments)\r
Comments = []\r
continue\r
SectionComments.extend(Comments)\r
Comments = []\r
continue\r
- if Line.find(DataType.TAB_COMMENT_EDK_START) > -1:\r
+ if Line.find(TAB_COMMENT_EDK_START) > -1:\r
IsFindBlockComment = True\r
continue\r
IsFindBlockComment = True\r
continue\r
- if Line.find(DataType.TAB_COMMENT_EDK_END) > -1:\r
+ if Line.find(TAB_COMMENT_EDK_END) > -1:\r
IsFindBlockComment = False\r
continue\r
if IsFindBlockComment:\r
IsFindBlockComment = False\r
continue\r
if IsFindBlockComment:\r
from Common import Misc as Utils\r
\r
from Common.LongFilePathSupport import OpenLongFilePath as open\r
from Common import Misc as Utils\r
\r
from Common.LongFilePathSupport import OpenLongFilePath as open\r
-from Common.TargetTxtClassObject import *\r
-from Common.ToolDefClassObject import *\r
+from Common.TargetTxtClassObject import TargetTxtClassObject\r
+from Common.ToolDefClassObject import ToolDefClassObject\r
from Common.DataType import *\r
from Common.BuildVersion import gBUILD_VERSION\r
from AutoGen.AutoGen import *\r
from Common.DataType import *\r
from Common.BuildVersion import gBUILD_VERSION\r
from AutoGen.AutoGen import *\r
if os.path.isfile(BuildConfigurationFile) == True:\r
StatusCode = self.TargetTxt.LoadTargetTxtFile(BuildConfigurationFile)\r
\r
if os.path.isfile(BuildConfigurationFile) == True:\r
StatusCode = self.TargetTxt.LoadTargetTxtFile(BuildConfigurationFile)\r
\r
- ToolDefinitionFile = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]\r
+ ToolDefinitionFile = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_TOOL_CHAIN_CONF]\r
if ToolDefinitionFile == '':\r
ToolDefinitionFile = gToolsDefinition\r
ToolDefinitionFile = os.path.normpath(mws.join(self.WorkspaceDir, 'Conf', ToolDefinitionFile))\r
if ToolDefinitionFile == '':\r
ToolDefinitionFile = gToolsDefinition\r
ToolDefinitionFile = os.path.normpath(mws.join(self.WorkspaceDir, 'Conf', ToolDefinitionFile))\r
\r
# if no ARCH given in command line, get it from target.txt\r
if not self.ArchList:\r
\r
# if no ARCH given in command line, get it from target.txt\r
if not self.ArchList:\r
- self.ArchList = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET_ARCH]\r
+ self.ArchList = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_TARGET_ARCH]\r
self.ArchList = tuple(self.ArchList)\r
\r
# if no build target given in command line, get it from target.txt\r
if not self.BuildTargetList:\r
self.ArchList = tuple(self.ArchList)\r
\r
# if no build target given in command line, get it from target.txt\r
if not self.BuildTargetList:\r
- self.BuildTargetList = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET]\r
+ self.BuildTargetList = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_TARGET]\r
\r
# if no tool chain given in command line, get it from target.txt\r
if not self.ToolChainList:\r
\r
# if no tool chain given in command line, get it from target.txt\r
if not self.ToolChainList:\r
- self.ToolChainList = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG]\r
+ self.ToolChainList = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_TOOL_CHAIN_TAG]\r
if self.ToolChainList is None or len(self.ToolChainList) == 0:\r
EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, ExtraData="No toolchain given. Don't know how to build.\n")\r
\r
if self.ToolChainList is None or len(self.ToolChainList) == 0:\r
EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, ExtraData="No toolchain given. Don't know how to build.\n")\r
\r
self.ToolChainFamily = ToolChainFamily\r
\r
if self.ThreadNumber is None:\r
self.ToolChainFamily = ToolChainFamily\r
\r
if self.ThreadNumber is None:\r
- self.ThreadNumber = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER]\r
+ self.ThreadNumber = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER]\r
if self.ThreadNumber == '':\r
self.ThreadNumber = 0\r
else:\r
if self.ThreadNumber == '':\r
self.ThreadNumber = 0\r
else:\r
self.ThreadNumber = 1\r
\r
if not self.PlatformFile:\r
self.ThreadNumber = 1\r
\r
if not self.PlatformFile:\r
- PlatformFile = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM]\r
+ PlatformFile = self.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_ACTIVE_PLATFORM]\r
if not PlatformFile:\r
# Try to find one in current directory\r
WorkingDirectory = os.getcwd()\r
if not PlatformFile:\r
# Try to find one in current directory\r
WorkingDirectory = os.getcwd()\r