public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [v2 1/1] BaseTools: fix imports
       [not found] <cover.1547060381.git.jaben.carsey@intel.com>
@ 2019-01-09 19:00 ` Jaben Carsey
  2019-01-10  0:42   ` Feng, Bob C
  0 siblings, 1 reply; 2+ messages in thread
From: Jaben Carsey @ 2019-01-09 19:00 UTC (permalink / raw)
  To: edk2-devel; +Cc: Bob Feng, Liming Gao

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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py                      |  6 ++----
 BaseTools/Source/Python/AutoGen/GenC.py                         |  2 +-
 BaseTools/Source/Python/AutoGen/GenPcdDb.py                     |  3 +++
 BaseTools/Source/Python/Common/RangeExpression.py               |  3 ++-
 BaseTools/Source/Python/Common/ToolDefClassObject.py            |  4 ++--
 BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py |  4 ++--
 BaseTools/Source/Python/GenFds/FdfParser.py                     |  4 ++--
 BaseTools/Source/Python/GenFds/FfsInfStatement.py               |  3 ++-
 BaseTools/Source/Python/GenFds/GenFds.py                        |  2 +-
 BaseTools/Source/Python/GenFds/GuidSection.py                   |  1 -
 BaseTools/Source/Python/Workspace/DecBuildData.py               |  9 ++++++---
 BaseTools/Source/Python/Workspace/DscBuildData.py               |  4 ++--
 BaseTools/Source/Python/Workspace/MetaFileParser.py             |  9 +++++----
 BaseTools/Source/Python/build/build.py                          | 16 ++++++++--------
 14 files changed, 38 insertions(+), 32 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index d646cd50ce8e..acd34692b6c2 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 09626d0b9610..e224568db1ed 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 876fcf1efb8a..a9068d2d7a86 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 407dc06ccf0b..40958451d286 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 186d279840c1..0a78123e2c4b 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 52a78bcbb813..283789fd1ddd 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 de0b166030e7..d54e4bd0313f 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 d4c61c074963..4dda3cf787e1 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 447aa7f5ebc2..d32325e89433 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 25609e6f2ae1..52b97300ecac 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 cc00409fee01..13b653bd9872 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 7e82e8e934ab..3b0b23ca8fcb 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 032220813b41..02c8d7bbb58c 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 97271e634e6c..b992a4c1b303 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()
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [v2 1/1] BaseTools: fix imports
  2019-01-09 19:00 ` [v2 1/1] BaseTools: fix imports Jaben Carsey
@ 2019-01-10  0:42   ` Feng, Bob C
  0 siblings, 0 replies; 2+ messages in thread
From: Feng, Bob C @ 2019-01-10  0:42 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming

Reviewed-by: Bob Feng <bob.c.feng@intel.com> 

-----Original Message-----
From: Carsey, Jaben 
Sent: Thursday, January 10, 2019 3:01 AM
To: edk2-devel@lists.01.org
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [v2 1/1] 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>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py                      |  6 ++----
 BaseTools/Source/Python/AutoGen/GenC.py                         |  2 +-
 BaseTools/Source/Python/AutoGen/GenPcdDb.py                     |  3 +++
 BaseTools/Source/Python/Common/RangeExpression.py               |  3 ++-
 BaseTools/Source/Python/Common/ToolDefClassObject.py            |  4 ++--
 BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py |  4 ++--
 BaseTools/Source/Python/GenFds/FdfParser.py                     |  4 ++--
 BaseTools/Source/Python/GenFds/FfsInfStatement.py               |  3 ++-
 BaseTools/Source/Python/GenFds/GenFds.py                        |  2 +-
 BaseTools/Source/Python/GenFds/GuidSection.py                   |  1 -
 BaseTools/Source/Python/Workspace/DecBuildData.py               |  9 ++++++---
 BaseTools/Source/Python/Workspace/DscBuildData.py               |  4 ++--
 BaseTools/Source/Python/Workspace/MetaFileParser.py             |  9 +++++----
 BaseTools/Source/Python/build/build.py                          | 16 ++++++++--------
 14 files changed, 38 insertions(+), 32 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index d646cd50ce8e..acd34692b6c2 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 09626d0b9610..e224568db1ed 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 876fcf1efb8a..a9068d2d7a86 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 407dc06ccf0b..40958451d286 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 186d279840c1..0a78123e2c4b 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 52a78bcbb813..283789fd1ddd 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 de0b166030e7..d54e4bd0313f 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 d4c61c074963..4dda3cf787e1 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 447aa7f5ebc2..d32325e89433 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 25609e6f2ae1..52b97300ecac 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 cc00409fee01..13b653bd9872 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 7e82e8e934ab..3b0b23ca8fcb 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 032220813b41..02c8d7bbb58c 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 97271e634e6c..b992a4c1b303 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_THRE
+ AD_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()
--
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-10  0:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1547060381.git.jaben.carsey@intel.com>
2019-01-09 19:00 ` [v2 1/1] BaseTools: fix imports Jaben Carsey
2019-01-10  0:42   ` Feng, Bob C

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox