From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 74D58210F93C6 for ; Wed, 29 Aug 2018 00:30:26 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Aug 2018 00:30:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,301,1531810800"; d="scan'208";a="69951482" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga006.jf.intel.com with ESMTP; 29 Aug 2018 00:30:10 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 29 Aug 2018 00:30:10 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 29 Aug 2018 00:30:09 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.240]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.150]) with mapi id 14.03.0319.002; Wed, 29 Aug 2018 15:30:07 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Feng, Bob C" , "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v1 1/1] BaseTools: Create and use a shared value for 'MSFT' from DataType Thread-Index: AQHUO8m96jTRAUx7qUCR+uYTm8FshKTWXIPA Date: Wed, 29 Aug 2018 07:30:06 +0000 Message-ID: References: <758bf9c0d1ccac8582454a812331368e7c7b8b9c.1535128260.git.jaben.carsey@intel.com> In-Reply-To: <758bf9c0d1ccac8582454a812331368e7c7b8b9c.1535128260.git.jaben.carsey@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v1 1/1] BaseTools: Create and use a shared value for 'MSFT' from DataType X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Aug 2018 07:30:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben=20 Sent: Saturday, August 25, 2018 12:33 AM To: edk2-devel@lists.01.org Cc: Feng, Bob C ; Zhu, Yonghong ; Gao, Liming Subject: [PATCH v1 1/1] BaseTools: Create and use a shared value for 'MSFT'= from DataType I see lots of 'MSFT' throughout code and this can reduce them. Cc: Bob Feng Cc: Yonghong Zhu Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/AutoGen/AutoGen.py | 8 ++++-= --- BaseTools/Source/Python/AutoGen/BuildEngine.py | 8 ++++-= --- BaseTools/Source/Python/AutoGen/GenMake.py | 3 ++- BaseTools/Source/Python/Common/DataType.py | 2 ++ BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 2 +- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 4 ++-- BaseTools/Source/Python/Workspace/DscBuildData.py | 4 ++-- BaseTools/Source/Python/Workspace/InfBuildData.py | 14 +++++= ++------- BaseTools/Source/Python/build/build.py | 2 +- 9 files changed, 25 insertions(+), 22 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index eb1b28388967..cb302189d2a3 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -80,7 +80,7 @@ gEfiVarStoreNamePattern =3D re.compile("\s*name\s*=3D\s*(= \w+)") gEfiVarStoreGuidPattern =3D re.compile("\s*guid\s*=3D\s*({.*?{.*?}\= s*})") =20 ## Mapping Makefile type -gMakeTypeMap =3D {"MSFT":"nmake", "GCC":"gmake"} +gMakeTypeMap =3D {TAB_COMPILER_MSFT:"nmake", "GCC":"gmake"} =20 =20 ## Build rule configuration file @@ -1843,7 +1843,7 @@ class PlatformAutoGen(AutoGen): or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][self.ToolChai= n]: EdkLogger.verbose("No tool chain family found in configura= tion for %s. Default to MSFT." \ % self.ToolChain) - self._ToolChainFamily =3D "MSFT" + self._ToolChainFamily =3D TAB_COMPILER_MSFT else: self._ToolChainFamily =3D ToolDefinition[TAB_TOD_DEFINES_F= AMILY][self.ToolChain] return self._ToolChainFamily @@ -1856,7 +1856,7 @@ class PlatformAutoGen(AutoGen): or not ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY][self= .ToolChain]: EdkLogger.verbose("No tool chain family found in configura= tion for %s. Default to MSFT." \ % self.ToolChain) - self._BuildRuleFamily =3D "MSFT" + self._BuildRuleFamily =3D TAB_COMPILER_MSFT else: self._BuildRuleFamily =3D ToolDefinition[TAB_TOD_DEFINES_B= UILDRULEFAMILY][self.ToolChain] return self._BuildRuleFamily @@ -2978,7 +2978,7 @@ class ModuleAutoGen(AutoGen): # Regular expression for finding Include Directories, the differen= ce between MSFT and INTEL/GCC/RVCT # is the former use /I , the Latter used -I to specify include dir= ectories # - if self.PlatformInfo.ToolChainFamily in ('MSFT'): + if self.PlatformInfo.ToolChainFamily in (TAB_COMPILER_MSFT): BuildOptIncludeRegEx =3D gBuildOptIncludePatternMsft elif self.PlatformInfo.ToolChainFamily in ('INTEL', 'GCC', 'RVCT')= : BuildOptIncludeRegEx =3D gBuildOptIncludePatternOther diff --g= it a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Source/Pyth= on/AutoGen/BuildEngine.py index 4291da9001b8..ac7a6687552c 100644 --- a/BaseTools/Source/Python/AutoGen/BuildEngine.py +++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py @@ -318,7 +318,7 @@ class BuildRule: # @param LineIndex The line number from which the parsing= will begin # @param SupportedFamily The list of supported tool chain famil= ies # - def __init__(self, File=3DNone, Content=3DNone, LineIndex=3D0, Support= edFamily=3D["MSFT", "INTEL", "GCC", "RVCT"]): + def __init__(self, File=3DNone, Content=3DNone, LineIndex=3D0, Support= edFamily=3D[TAB_COMPILER_MSFT, "INTEL", "GCC", "RVCT"]): self.RuleFile =3D File # Read build rules from file if it's not none if File is not None: @@ -596,17 +596,17 @@ if __name__ =3D=3D '__main__': EdkLogger.Initialize() if len(sys.argv) > 1: Br =3D BuildRule(sys.argv[1]) - print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "MSFT"][1])) + print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32",=20 + TAB_COMPILER_MSFT][1])) print() print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "INTEL"][1])) print() print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "GCC"][1])) print() - print(str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])) + print(str(Br[".ac", "ACPI_TABLE", "IA32",=20 + TAB_COMPILER_MSFT][1])) print() print(str(Br[".h", "ACPI_TABLE", "IA32", "INTEL"][1])) print() - print(str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])) + print(str(Br[".ac", "ACPI_TABLE", "IA32",=20 + TAB_COMPILER_MSFT][1])) print() print(str(Br[".s", SUP_MODULE_SEC, "IPF", "COMMON"][1])) print() diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/= Python/AutoGen/GenMake.py index 55081acbd822..35ee98c82bb1 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -27,6 +27,7 @@ from Common.StringUtils import * from .BuildEngine impor= t * import Common.GlobalData as GlobalData from collections import Ordere= dDict +from Common.DataType import TAB_COMPILER_MSFT =20 ## Regular expression for finding header file inclusions gIncludePattern = =3D re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*= )*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | = re.UNICODE | re.IGNORECASE) @@ -166,7 +167,7 @@ class BuildFile(object): "gmake" : "include" } =20 - _INC_FLAG_ =3D {"MSFT" : "/I", "GCC" : "-I", "INTEL" : "-I", "RVCT" : = "-I"} + _INC_FLAG_ =3D {TAB_COMPILER_MSFT : "/I", "GCC" : "-I", "INTEL" :=20 + "-I", "RVCT" : "-I"} =20 ## Constructor of BuildFile # diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/= Python/Common/DataType.py index 473fb7473a5a..8f9a50732547 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -554,3 +554,5 @@ PACK_CODE_BY_SIZE =3D {8:'=3DQ', 1:'=3DB', 0:'=3DB', 16:""} + +TAB_COMPILER_MSFT =3D 'MSFT' \ No newline at end of file diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.p= y b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index a2cd30d3d910..52a78bcbb813 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -1111,7 +1111,7 @@ class DscParser(MetaFileParser): =20 ## Override parent's method since we'll do all macro replacements in p= arser def _GetMacros(self): - Macros =3D dict( [('ARCH', 'IA32'), ('FAMILY', 'MSFT'), ('TOOL_CHA= IN_TAG', 'VS2008x86'), ('TARGET', 'DEBUG')]) + Macros =3D dict( [('ARCH', 'IA32'), ('FAMILY',=20 + TAB_COMPILER_MSFT), ('TOOL_CHAIN_TAG', 'VS2008x86'), ('TARGET',=20 + 'DEBUG')]) Macros.update(self._FileLocalMacros) Macros.update(self._GetApplicableSectionMacro()) Macros.update(GlobalData.gEdkGlobal) diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/Source/Python/GenFds/GenFdsGlobalVariable.py index 9936498c5158..eb106b574420 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -66,8 +66,8 @@ class GenFdsGlobalVariable: FixedLoadAddress =3D False PlatformName =3D '' =20 - BuildRuleFamily =3D "MSFT" - ToolChainFamily =3D "MSFT" + BuildRuleFamily =3D DataType.TAB_COMPILER_MSFT + ToolChainFamily =3D DataType.TAB_COMPILER_MSFT __BuildRuleDatabase =3D None GuidToolDefinition =3D {} FfsCmdDict =3D {} diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index a4ad53ee1558..aafdd0ab93b7 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -2784,7 +2784,7 @@ class DscBuildData(PlatformBuildClassObject): self.Modules.append(Module) =20 def _GetToolChainFamily(self): - self._ToolChainFamily =3D "MSFT" + self._ToolChainFamily =3D TAB_COMPILER_MSFT BuildConfigurationFile =3D os.path.normpath(os.path.join(GlobalDat= a.gConfDirectory, "target.txt")) if os.path.isfile(BuildConfigurationFile) =3D=3D True: TargetTxt =3D TargetTxtClassObject() @@ -2800,7 +2800,7 @@ class DscBuildData(PlatformBuildClassObject): if TAB_TOD_DEFINES_FAMILY not in ToolDefinition \ or self._Toolchain not in ToolDefinition[TAB_TOD_DEFINE= S_FAMILY] \ or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][self._Too= lchain]: - self._ToolChainFamily =3D "MSFT" + self._ToolChainFamily =3D TAB_COMPILER_MSFT else: self._ToolChainFamily =3D ToolDefinition[TAB_TOD_DEFIN= ES_FAMILY][self._Toolchain] return self._ToolChainFamily diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/= Source/Python/Workspace/InfBuildData.py index 7c3d712efe63..1325b4f0295a 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -252,10 +252,10 @@ class InfBuildData(ModuleBuildClassObject): if self._CustomMakefile is None: self._CustomMakefile =3D {} if len(TokenList) < 2: - self._CustomMakefile['MSFT'] =3D TokenList[0] + self._CustomMakefile[TAB_COMPILER_MSFT] =3D=20 + TokenList[0] self._CustomMakefile['GCC'] =3D TokenList[0] else: - if TokenList[0] not in ['MSFT', 'GCC']: + if TokenList[0] not in [TAB_COMPILER_MSFT, 'GCC']: EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "No supported family [%s]" % Token= List[0], File=3Dself.MetaFile, Line=3DRecor= d[-1]) @@ -353,7 +353,7 @@ class InfBuildData(ModuleBuildClassObject): else: Tool =3D ToolList[0] ToolChain =3D "*_*_*_%s_FLAGS" % Tool - ToolChainFamily =3D 'MSFT' # Edk.x only support M= SFT tool chain + # Edk.x only support MSFT tool chain # ignore not replaced macros in value ValueList =3D GetSplitList(' ' + Value, '/D') Dummy =3D ValueList[0] @@ -362,11 +362,11 @@ class= InfBuildData(ModuleBuildClassObject): continue Dummy =3D Dummy + ' /D ' + ValueList[Index] Value =3D Dummy.strip() - if (ToolChainFamily, ToolChain) not in self._Build= Options: - self._BuildOptions[ToolChainFamily, ToolChain]= =3D Value + if (TAB_COMPILER_MSFT, ToolChain) not in self._Bui= ldOptions: + self._BuildOptions[TAB_COMPILER_MSFT,=20 + ToolChain] =3D Value else: - OptionString =3D self._BuildOptions[ToolChainF= amily, ToolChain] - self._BuildOptions[ToolChainFamily, ToolChain]= =3D OptionString + " " + Value + OptionString =3D self._BuildOptions[TAB_COMPIL= ER_MSFT, ToolChain] + self._BuildOptions[TAB_COMPILER_MSFT,=20 + ToolChain] =3D OptionString + " " + Value # set _Header to non-None in order to avoid database re-querying self._Header_ =3D 'DUMMY' =20 diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/build/build.py index 6ad0e389687c..e6a9c6ef7199 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -933,7 +933,7 @@ class Build(): if TAB_TOD_DEFINES_FAMILY not in ToolDefinition or Tool not in= ToolDefinition[TAB_TOD_DEFINES_FAMILY] \ or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][Tool]: EdkLogger.warn("build", "No tool chain family found in con= figuration for %s. Default to MSFT." % Tool) - ToolChainFamily.append("MSFT") + ToolChainFamily.append(TAB_COMPILER_MSFT) else: ToolChainFamily.append(ToolDefinition[TAB_TOD_DEFINES_FAMI= LY][Tool]) self.ToolChainFamily =3D ToolChainFamily -- 2.16.2.windows.1