From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 52943820EA for ; Wed, 15 Feb 2017 17:27:01 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Feb 2017 17:27:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,167,1484035200"; d="scan'208";a="1108340127" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 15 Feb 2017 17:27:00 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 15 Feb 2017 17:27:00 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.204]) with mapi id 14.03.0248.002; Thu, 16 Feb 2017 09:26:56 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [Patch V2] BaseTools: Fix bug for GUIDED tool path override by DSC [BuildOptions] Thread-Index: AQHSh52J5F0BGUIaD0iReiTQr4TRz6Fq2EUA Date: Thu, 16 Feb 2017 01:26:55 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D6DC7B8@shsmsx102.ccr.corp.intel.com> References: <1487171278-35476-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1487171278-35476-1-git-send-email-yonghong.zhu@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 V2] BaseTools: Fix bug for GUIDED tool path override by DSC [BuildOptions] X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Feb 2017 01:27:01 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao -----Original Message----- From: Zhu, Yonghong=20 Sent: Wednesday, February 15, 2017 11:08 PM To: edk2-devel@lists.01.org Cc: Gao, Liming Subject: [Patch V2] BaseTools: Fix bug for GUIDED tool path override by DSC= [BuildOptions] Current the GUIDED tool path can't be override to the different path in the [BuildOptions] of DSC file. This patch fix the bug. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=3D283 Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu --- BaseTools/Source/Python/AutoGen/AutoGen.py | 24 ++++++++--- BaseTools/Source/Python/GenFds/GenFds.py | 66 ++++++++++++++++++++++----= ---- 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index c35f0b2..06e674a 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1716,11 +1716,14 @@ class PlatformAutoGen(AutoGen): if Tool in self.BuildOption and Attr in self.BuildOpti= on[Tool]: # check if override is indicated if self.BuildOption[Tool][Attr].startswith('=3D'): Value =3D self.BuildOption[Tool][Attr][1:] else: - Value +=3D " " + self.BuildOption[Tool][Attr] + if Attr !=3D 'PATH': + Value +=3D " " + self.BuildOption[Tool][At= tr] + else: + Value =3D self.BuildOption[Tool][Attr] =20 if Attr =3D=3D "PATH": # Don't put MAKE definition in the file if Tool =3D=3D "MAKE": MakePath =3D Value @@ -2379,12 +2382,15 @@ class PlatformAutoGen(AutoGen): if Tool not in BuildOptions: BuildOptions[Tool] =3D {} if Attr !=3D "FLAGS" or Attr not in BuildOptions[T= ool] or Options[Key].startswith('=3D'): BuildOptions[Tool][Attr] =3D Options[Key] else: - # append options for the same tool - BuildOptions[Tool][Attr] +=3D " " + Options[Ke= y] + # append options for the same tool except PATH + if Attr !=3D 'PATH': + BuildOptions[Tool][Attr] +=3D " " + Option= s[Key] + else: + BuildOptions[Tool][Attr] =3D Options[Key] # Build Option Family has been checked, which need't to be checked= again for family. if FamilyMatch or FamilyIsNull: return BuildOptions =20 for Key in Options: @@ -2411,12 +2417,15 @@ class PlatformAutoGen(AutoGen): if Tool not in BuildOptions: BuildOptions[Tool] =3D {} if Attr !=3D "FLAGS" or Attr not in BuildOptions[T= ool] or Options[Key].startswith('=3D'): BuildOptions[Tool][Attr] =3D Options[Key] else: - # append options for the same tool - BuildOptions[Tool][Attr] +=3D " " + Options[Ke= y] + # append options for the same tool except PATH + if Attr !=3D 'PATH': + BuildOptions[Tool][Attr] +=3D " " + Option= s[Key] + else: + BuildOptions[Tool][Attr] =3D Options[Key] return BuildOptions =20 ## Append build options in platform to a module # # @param Module The module to which the build options will be appe= ned @@ -2471,11 +2480,14 @@ class PlatformAutoGen(AutoGen): ToolPath =3D Value[1:] ToolPath =3D mws.handleWsMacro(ToolPath) BuildOptions[Tool][Attr] =3D ToolPath else: Value =3D mws.handleWsMacro(Value) - BuildOptions[Tool][Attr] +=3D " " + Value + if Attr !=3D 'PATH': + BuildOptions[Tool][Attr] +=3D " " + Value + else: + BuildOptions[Tool][Attr] =3D Value if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag != =3D None: # # Override UNI flag only for EDK module. # if 'BUILD' not in BuildOptions: diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index c2e9418..a8a68da 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -1,9 +1,9 @@ ## @file # generate flash image # -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -28,11 +28,11 @@ from Workspace.BuildClassObject import ModuleBuildClass= Object import RuleComplexFile from EfiSection import EfiSection import StringIO import Common.TargetTxtClassObject as TargetTxtClassObject import Common.ToolDefClassObject as ToolDefClassObject -import Common.DataType +from Common.DataType import * import Common.GlobalData as GlobalData from Common import EdkLogger from Common.String import * from Common.Misc import DirCache, PathClass from Common.Misc import SaveFileOnChange @@ -43,11 +43,11 @@ from Common.BuildVersion import gBUILD_VERSION from Common.MultipleWorkspace import MultipleWorkspace as mws =20 ## Version and Copyright versionNumber =3D "1.0" + ' ' + gBUILD_VERSION __version__ =3D "%prog Version " + versionNumber -__copyright__ =3D "Copyright (c) 2007 - 2016, Intel Corporation All right= s reserved." +__copyright__ =3D "Copyright (c) 2007 - 2017, Intel Corporation All right= s reserved." =20 ## Tool entrance method # # This method mainly dispatch specific methods per the command line option= s. # If no error found, return zero value so the caller of this tool can know @@ -422,15 +422,15 @@ def BuildOptionPcdValueFormat(TokenSpaceGuidCName, To= kenCName, PcdDatumType, Val # @param KeyStringList Filter for inputs of section generation # @param CurrentArchList Arch list # @param NameGuid The Guid name # def FindExtendTool(KeyStringList, CurrentArchList, NameGuid): + ToolDb =3D ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir= ).ToolsDefTxtDatabase # if user not specify filter, try to deduce it from global data. if KeyStringList =3D=3D None or KeyStringList =3D=3D []: Target =3D GenFdsGlobalVariable.TargetName ToolChain =3D GenFdsGlobalVariable.ToolChainTag - ToolDb =3D ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.Con= fDir).ToolsDefTxtDatabase if ToolChain not in ToolDb['TOOL_CHAIN_TAG']: EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external= tool because tool tag %s is not defined in tools_def.txt!" % ToolChain) KeyStringList =3D [Target + '_' + ToolChain + '_' + CurrentArchLis= t[0]] for Arch in CurrentArchList: if Target + '_' + ToolChain + '_' + Arch not in KeyStringList: @@ -441,37 +441,71 @@ def FindExtendTool(KeyStringList, CurrentArchList, Na= meGuid): return GenFdsGlobalVariable.GuidToolDefinition[NameGuid] =20 ToolDefinition =3D ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable= .ConfDir).ToolsDefTxtDictionary ToolPathTmp =3D None ToolOption =3D None + ToolPathKey =3D None + ToolOptionKey =3D None + KeyList =3D None for ToolDef in ToolDefinition.items(): if NameGuid =3D=3D ToolDef[1]: KeyList =3D ToolDef[0].split('_') Key =3D KeyList[0] + \ '_' + \ KeyList[1] + \ '_' + \ KeyList[2] if Key in KeyStringList and KeyList[4] =3D=3D 'GUID': - - ToolPath =3D ToolDefinition.get(Key + \ - '_' + \ - KeyList[3] + \ - '_' + \ - 'PATH') - - ToolOption =3D ToolDefinition.get(Key + \ - '_' + \ - KeyList[3] + \ - '_' + \ - 'FLAGS') + ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' + ToolOptionKey =3D Key + '_' + KeyList[3] + '_FLAGS' + ToolPath =3D ToolDefinition.get(ToolPathKey) + ToolOption =3D ToolDefinition.get(ToolOptionKey) if ToolPathTmp =3D=3D None: ToolPathTmp =3D ToolPath else: if ToolPathTmp !=3D ToolPath: EdkLogger.error("GenFds", GENFDS_ERROR, "Don't kno= w which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath)) =20 + BuildOption =3D {} + for Arch in CurrentArchList: + Platform =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlob= alVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlo= balVariable.ToolChainTag] + # key is (ToolChainFamily, ToolChain, CodeBase) + for item in Platform.BuildOptions: + if '_PATH' in item[1] or '_FLAGS' in item[1] or '_GUID' in ite= m[1]: + if not item[0] or (item[0] and GenFdsGlobalVariable.ToolCh= ainFamily=3D=3D item[0]): + if item[1] not in BuildOption: + BuildOption[item[1]] =3D Platform.BuildOptions[ite= m] + if BuildOption: + ToolList =3D [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHA= IN_TAG, TAB_TOD_DEFINES_TARGET_ARCH] + for Index in range(2, -1, -1): + for Key in dict(BuildOption): + List =3D Key.split('_') + if List[Index] =3D=3D '*': + for String in ToolDb[ToolList[Index]]: + if String in [Arch, GenFdsGlobalVariable.Targe= tName, GenFdsGlobalVariable.ToolChainTag]: + List[Index] =3D String + NewKey =3D '%s_%s_%s_%s_%s' % tuple(List) + if NewKey not in BuildOption: + BuildOption[NewKey] =3D BuildOption[Ke= y] + continue + del BuildOption[Key] + elif List[Index] not in ToolDb[ToolList[Index]]: + del BuildOption[Key] + if BuildOption: + if not KeyList: + for Op in BuildOption: + if NameGuid =3D=3D BuildOption[Op]: + KeyList =3D Op.split('_') + Key =3D KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2= ] + if Key in KeyStringList and KeyList[4] =3D=3D 'GUID': + ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' + ToolOptionKey =3D Key + '_' + KeyList[3] + '_FLAGS= ' + if ToolPathKey in BuildOption.keys(): + ToolPathTmp =3D BuildOption.get(ToolPathKey) + if ToolOptionKey in BuildOption.keys(): + ToolOption =3D BuildOption.get(ToolOptionKey) + GenFdsGlobalVariable.GuidToolDefinition[NameGuid] =3D (ToolPathTmp, To= olOption) return ToolPathTmp, ToolOption =20 ## Parse command line options # --=20 2.6.1.windows.1