From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web12.3156.1619679142990397801 for ; Wed, 28 Apr 2021 23:52:23 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=mtQvX10S; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: bob.c.feng@intel.com) IronPort-SDR: 7mbMODRcFKlg+ewBDsZAqN45Om4Epa6IHdp1YHTLd/iDOoOlljIN0HtV781neGk1lYdvOnZjW+ GFz8+0E1sylw== X-IronPort-AV: E=McAfee;i="6200,9189,9968"; a="177049308" X-IronPort-AV: E=Sophos;i="5.82,258,1613462400"; d="scan'208";a="177049308" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2021 23:52:21 -0700 IronPort-SDR: l6VmLl1skkIiOncg9fK0O+Vgq2R0mvugSCq192cehUsqntPyy+s6ES2g2ldsdwJG4AfBYocDbv BeOauxHgfYEA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,258,1613462400"; d="scan'208";a="466234903" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga001.jf.intel.com with ESMTP; 28 Apr 2021 23:52:21 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 28 Apr 2021 23:52:20 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 28 Apr 2021 23:52:20 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Wed, 28 Apr 2021 23:52:20 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Wed, 28 Apr 2021 23:52:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jk9JVJn1Bv2/pyQx4FRTucSXnEc/GK6fZnCt5y+cOVA57uw2jIIs7mg9M9fiaFIiKlmJRbia7ngx/M9z4A5917b1DG/mQtyZJpBtEwCBG5IL8vWVX746UoUbGZ4susplYGSn1frwul1GCHIFQvrvqB2iN6nzTV8NtGnsaZ+dGvD9nwDuyZLJyYxLLSDfpSWa6F72UWdPOixEyi1VFYyjcQtHXywzztbBSm6ZMFSVVCsGlvEk/m29uQWcw5QYkAzC9lGITto1/+RsUMlOBAqiSbirvKiM7AKAA1yFXQPYbqRngFJVmH+/2zFrFhosPmwOGMgFQuW/Q3BqdF8veyEyPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HUjdO16Q0fF/Y2zwSsgACX+hgGsCmGxQEmtEvMGHXQU=; b=Ag4pjaWGTPyZoW/NyGZzy8n6I+zAC91B4EQ+KdIju65HkMjePYgnRqOFojXBDvBfLKi4qLmvo3fw68oiaL5vHOxUE8u/e79mhYMoepr31rIafXLdm9D/V4bet7eJRtqeQ6+uzgicHZex1dlMMJfpZLTqp67+037QX0cPJ8KewOvFMbDZ+EBvTEunxx/Peqtm26TSvLCWRuoD/E6rOPflvT4OKIkp8SGKXrdSkC8aOMoi68AMJPSTu9AigOOQ9NoovJ0aBTqakFUN7aOc51pFe3dq7q80poSHi1ASkWS4rLXZeDr9g4CJnb3AmvgWLeyKWmcj2m/vIroKKcfqk6WvsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HUjdO16Q0fF/Y2zwSsgACX+hgGsCmGxQEmtEvMGHXQU=; b=mtQvX10SJSUDqIJXUj9MGvpnmbS7txKGP+0gx34r7sAn3hW9alSThTvCiO6WiSpP5hLKoxLnX6LO27r6Plxp/nQkX73x6hLvQN9fm3c4ymhlwnYf3+c3apO1h8r8bUjkmESeqpInCKl/Gf004lUip6ww4SLQUbbA/4RBs01fB3g= Received: from DM6PR11MB4073.namprd11.prod.outlook.com (2603:10b6:5:19f::22) by DM5PR1101MB2268.namprd11.prod.outlook.com (2603:10b6:4:53::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.23; Thu, 29 Apr 2021 06:52:18 +0000 Received: from DM6PR11MB4073.namprd11.prod.outlook.com ([fe80::cc64:a87c:5cf:5f18]) by DM6PR11MB4073.namprd11.prod.outlook.com ([fe80::cc64:a87c:5cf:5f18%3]) with mapi id 15.20.4065.027; Thu, 29 Apr 2021 06:52:18 +0000 From: "Bob Feng" To: "Kinney, Michael D" , "devel@edk2.groups.io" CC: Liming Gao , "Chen, Christine" Subject: Re: [Patch V3 1/1] BaseTools/Source/Python: New Target/ToolChain/Arch in DSC [BuildOptions] Thread-Topic: [Patch V3 1/1] BaseTools/Source/Python: New Target/ToolChain/Arch in DSC [BuildOptions] Thread-Index: AQHXPL+0DyJDFbqG/UiuAYi88hgMdarLDseg Date: Thu, 29 Apr 2021 06:52:18 +0000 Message-ID: References: <20210429061954.5-1-michael.d.kinney@intel.com> In-Reply-To: <20210429061954.5-1-michael.d.kinney@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.53] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: af873bb4-c544-42f2-51af-08d90adb54c8 x-ms-traffictypediagnostic: DM5PR1101MB2268: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:655; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: QdxKjKw9IGWi5VDx8q1QHP7AkONRd3fIDvXjnt0ZibBdm7Wf4Ocm3UrH301DwgKVdslPiC28aj4FHfWXBtjkEUo/HT2MBrxhaNvft/I5FntbpjteGAdZjd37HlJ+qtfrs3XqrC5MtsC9Xdz+iLftyfG2USjmO4a783YE8jpsqMXoOzxBz0v6FsAL0+4CQTbeLC2LFqDOdeBKwRDj7x2T2FqsxmnlkK26mHvkvK7+cX1Xd9NXcAJZTzrP7hxy+vBZe3WSHdGmW29HfBejSAtdHQ/G53oJNuypM6rJjYWW1TlMz4SK/Btn7lchL16Yjl2Pcrxi6iqqmBRlGtgAWMCw6qB9W5ljjlBSlUbFQe64Fbr7zZ2E7P4CVyOP381A+eYbLqcfYwsl0LdrDwulxJs5Ms9NLP4ceG6r6XSbdWxomwuNON77kBqh0P3PqAEz8D3mRW8FxNcnvZSaYKkcrHrKNjCD3karwmHuoDdtGSNgjng6om3u5I23MV41+jKAdDD81KNrHe+lSDYiBe8udjrRMR4F//fI15hv9aWZjCCYIB9y7HkMWVIyboUy+fyggGvwohICI7438QXZRXeCuz4draH0o91zb8tjEEvIDohXJ4a9iwrR3IQnVDIuIbbSCokeT1lOPh/h7TweUi3FEroamrpifH8MMg940ZCocjTTkCw7ag6bX4mr3k6a3drrqb8H x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB4073.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(396003)(39860400002)(136003)(346002)(376002)(186003)(478600001)(66446008)(7696005)(6506007)(86362001)(66476007)(33656002)(55016002)(2906002)(26005)(76116006)(8676002)(8936002)(107886003)(5660300002)(54906003)(30864003)(122000001)(110136005)(966005)(53546011)(83380400001)(64756008)(52536014)(38100700002)(316002)(66556008)(71200400001)(66946007)(9686003)(4326008)(559001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?dRYPdcBQeoSGbLOfHdFHDBMH74lPIssw/tQcZ0X7KWMO0VT0shlwLhEp2aHE?= =?us-ascii?Q?yxM/Xoru83xC1nYoafs+X6rvrxNv+KhjzepUqtm0Z5syS/+vRwMZZQ42vJYr?= =?us-ascii?Q?dTVQuZ7S/EHQECIEtarmQ/rnQ0cAuFrCcMmtmOiMQxyAhQXreMEV38+/SAuP?= =?us-ascii?Q?+xq1T1psf6aEKfGngMREGQianYK3btun0UsjwGQ4lfpdY3IhQG1RnaA8Wksc?= =?us-ascii?Q?4G0ZG1mA8wFiAIEcuDc/84pUgwZrTFJHWN0V4xyCX07Kt17/0CwUlMNDY5Gp?= =?us-ascii?Q?1QPvNNd17GzcpptiQaYJSu6iUb9slMQWzZ5wLxXv5+/d+Z2NzCgMWWKtvpNx?= =?us-ascii?Q?O251kzVCDEgTSHxgNtLThx36If4TrUT0c6XSxRhbnkFqzIhjaU6JHXqH7zBV?= =?us-ascii?Q?pv1JK/urjf6RBB1zfL6DDNgioRZDopsJjbmkOece5iRYUA1LmWtd6iKeelgI?= =?us-ascii?Q?IW2jnuIeZfELLBD0Xvn3CPehirTWRNfgnsQ2+/riGLIATM2TdSjw/Ueo11w3?= =?us-ascii?Q?UV8tzJDegvrFPI2jjqeh3ealM88mPcvqJcFcaNNyZT4ZMQdWWU1MVQu+VuLC?= =?us-ascii?Q?8VCnq/NBeZQbGIi1puSub0EQNMZeejnbY6F0Dnnfi0VNcNMKi/y1h8xA8f/7?= =?us-ascii?Q?qjuO/cmBSHxCvsT1pXMfN5+QM96/zc8XSUffOHnsC9DEhvllEe2rt+byHRMn?= =?us-ascii?Q?2HzXF/u1N7FMhbqVtWtzCLQbxtRysXRU1FYUKGqZOBLi+4PHpFikmTx7g5TS?= =?us-ascii?Q?6zpMzaSjBBJ0UzSMxGekxdB6ZwrrrgCWcdeLD3E354fVVZOWMREgm2+qAD+A?= =?us-ascii?Q?Urzn4fx54zPeuZcgMvBwjeqdxBujt9l3bJmsorLV1SFNI2YyC53SbzJLc0G3?= =?us-ascii?Q?0h5elzU+uBtwwtt3Bm/e28/HSIrapwipgn8fnt7SscMCgQCva0Hefx5EfA3X?= =?us-ascii?Q?7EYZecH2h/eWkGp4Dx+Wolv7WfwJuCl5OhuKh1hZ1CmnAB47j/NecyLuHthr?= =?us-ascii?Q?Z69LuE9e8SBEzH/KZI3Y7xS0dbN5QSrLbh3VuUsPtwTLrOep+HGYSKbjvDK3?= =?us-ascii?Q?VkdksaONstG8CeZiYipjPO+BPmsEjy83Yic4ud0uLkV2sw3XAVEo7N6wB8V4?= =?us-ascii?Q?n5oRF54l30XjKhoTixAdUBfwMOCWrOe4kkykXKCIf8qQ/tK5b4+lrG9u2S/X?= =?us-ascii?Q?2Wu+2a69uFWUnsr4P/aBUtupyBDTsQUW5nAhX5ghkXWirTBna49qNMEorpv7?= =?us-ascii?Q?G8nJQSIf33WzFBU2I5diLzPfOgOiFUPTQi7teZV5Nq0NDX2sDi6tfrkz8pYV?= =?us-ascii?Q?QVlf9nD2k4JaVbTGqI6PAOC2?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4073.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: af873bb4-c544-42f2-51af-08d90adb54c8 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Apr 2021 06:52:18.4896 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: QMCIZl8NHTNCzDiRw28sLTWozZv4EXR7OQ6CPgRq1JzN5K5KjKJggyftdg91rr2ntZNxpKS3yzjZR00h9gscjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1101MB2268 Return-Path: bob.c.feng@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: Kinney, Michael D =20 Sent: Thursday, April 29, 2021 2:20 PM To: devel@edk2.groups.io Cc: Feng, Bob C ; Liming Gao ; Chen, Christine Subject: [Patch V3 1/1] BaseTools/Source/Python: New Target/ToolChain/Arch = in DSC [BuildOptions] REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3359 Update BaseTools to support new build targets, new tool chains, and new arc= hitectures declared in DSC file [BuildOptions] sections. * Do not expand * when tools_def.txt is parsed. Only expand when both tools_def.txt and DSC [BuilsOptions] sections have been parsed. This also requires more flexible matching of tool keys that contain * in tool key fields. * Pre-scan the platform DSC file for FAMILY and TOOLCHAIN declarations DSC in [BuildOptions] sections before the FAMILY and TOOLCHAIN need to be known. Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Signed-off-by: Michael D Kinney --- .../Python/AutoGen/ModuleAutoGenHelper.py | 50 +++++--- .../Source/Python/AutoGen/PlatformAutoGen.py | 115 ++++++++++++++---- .../Python/Common/ToolDefClassObject.py | 19 +-- .../Python/GenFds/GenFdsGlobalVariable.py | 31 +++-- BaseTools/Source/Python/build/build.py | 111 ++++++++++++----- 5 files changed, 230 insertions(+), 96 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py b/BaseT= ools/Source/Python/AutoGen/ModuleAutoGenHelper.py index 7477b1d77fb8..167bb59d2315 100644 --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py @@ -173,17 +173,30 @@ class AutoGenInfo(object): Family =3D Key[0] Target, Tag, Arch, Tool, Attr =3D Key[1].split("_") # if tool chain family doesn't match, skip it - if Tool in ToolDef and Family !=3D "": - FamilyIsNull =3D False - if ToolDef[Tool].get(TAB_TOD_DEFINES_BUILDRULEFAMILY, "") = !=3D "": - if Family !=3D ToolDef[Tool][TAB_TOD_DEFINES_BUILDRULE= FAMILY]: - continue - else: - if ToolDef[Tool].get(TAB_TOD_DEFINES_FAMILY, "") =3D= =3D "": - continue - if Family !=3D ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]: - continue - FamilyMatch =3D True + if Family !=3D "": + Found =3D False + if Tool in ToolDef: + FamilyIsNull =3D False + if TAB_TOD_DEFINES_BUILDRULEFAMILY in ToolDef[Tool]: + if Family =3D=3D ToolDef[Tool][TAB_TOD_DEFINES_BUI= LDRULEFAMILY]: + FamilyMatch =3D True + Found =3D True + if TAB_TOD_DEFINES_FAMILY in ToolDef[Tool]: + if Family =3D=3D ToolDef[Tool][TAB_TOD_DEFINES_FAM= ILY]: + FamilyMatch =3D True + Found =3D True + if TAB_STAR in ToolDef: + FamilyIsNull =3D False + if TAB_TOD_DEFINES_BUILDRULEFAMILY in ToolDef[TAB_STAR= ]: + if Family =3D=3D ToolDef[TAB_STAR][TAB_TOD_DEFINES= _BUILDRULEFAMILY]: + FamilyMatch =3D True + Found =3D True + if TAB_TOD_DEFINES_FAMILY in ToolDef[TAB_STAR]: + if Family =3D=3D ToolDef[TAB_STAR][TAB_TOD_DEFINES= _FAMILY]: + FamilyMatch =3D True + Found =3D True + if not Found: + continue # expand any wildcard if Target =3D=3D TAB_STAR or Target =3D=3D self.BuildTarget: if Tag =3D=3D TAB_STAR or Tag =3D=3D self.ToolChain: @@ -213,12 +226,19 @@ class AutoGenInfo(object): Family =3D Key[0] Target, Tag, Arch, Tool, Attr =3D Key[1].split("_") # if tool chain family doesn't match, skip it - if Tool not in ToolDef or Family =3D=3D "": + if Family =3D=3D "": continue # option has been added before - if TAB_TOD_DEFINES_FAMILY not in ToolDef[Tool]: - continue - if Family !=3D ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]: + Found =3D False + if Tool in ToolDef: + if TAB_TOD_DEFINES_FAMILY in ToolDef[Tool]: + if Family =3D=3D ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]= : + Found =3D True + if TAB_STAR in ToolDef: + if TAB_TOD_DEFINES_FAMILY in ToolDef[TAB_STAR]: + if Family =3D=3D ToolDef[TAB_STAR][TAB_TOD_DEFINES_FAM= ILY]: + Found =3D True + if not Found: continue =20 # expand any wildcard diff --git a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py b/BaseTools= /Source/Python/AutoGen/PlatformAutoGen.py index e2ef3256773e..21e72438e59e 100644 --- a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py @@ -827,6 +827,33 @@ class PlatformAutoGen(AutoGen): RetVal =3D RetVal + _SplitOption(Flags.strip()) return RetVal =20 + ## Compute a tool defintion key priority value in range 0..15 + # + # TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE 15 + # ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE 14 + # TARGET_*********_ARCH_COMMANDTYPE_ATTRIBUTE 13 + # ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE 12 + # TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE 11 + # ******_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE 10 + # TARGET_*********_****_COMMANDTYPE_ATTRIBUTE 9 + # ******_*********_****_COMMANDTYPE_ATTRIBUTE 8 + # TARGET_TOOLCHAIN_ARCH_***********_ATTRIBUTE 7 + # ******_TOOLCHAIN_ARCH_***********_ATTRIBUTE 6 + # TARGET_*********_ARCH_***********_ATTRIBUTE 5 + # ******_*********_ARCH_***********_ATTRIBUTE 4 + # TARGET_TOOLCHAIN_****_***********_ATTRIBUTE 3 + # ******_TOOLCHAIN_****_***********_ATTRIBUTE 2 + # TARGET_*********_****_***********_ATTRIBUTE 1 + # ******_*********_****_***********_ATTRIBUTE 0 + # + def ToolDefinitionPriority (self,Key): + KeyList =3D Key.split('_') + Priority =3D 0 + for Index in range (0, min(4, len(KeyList))): + if KeyList[Index] !=3D '*': + Priority +=3D (1 << Index) + return Priority + ## Get tool chain definition # # Get each tool definition for given tool chain from tools_def.txt an= d platform @@ -839,8 +866,16 @@ class PlatformAutoGen(AutoGen): ExtraData=3D"[%s]" % self.MetaFile) RetVal =3D OrderedDict() DllPathList =3D set() - for Def in ToolDefinition: + + PrioritizedDefList =3D sorted(ToolDefinition.keys(), key=3Dself.To= olDefinitionPriority, reverse=3DTrue) + for Def in PrioritizedDefList: Target, Tag, Arch, Tool, Attr =3D Def.split("_") + if Target =3D=3D TAB_STAR: + Target =3D self.BuildTarget + if Tag =3D=3D TAB_STAR: + Tag =3D self.ToolChain + if Arch =3D=3D TAB_STAR: + Arch =3D self.Arch if Target !=3D self.BuildTarget or Tag !=3D self.ToolChain or = Arch !=3D self.Arch: continue =20 @@ -850,9 +885,14 @@ class PlatformAutoGen(AutoGen): DllPathList.add(Value) continue =20 + # + # ToolDefinition is sorted from highest priority to lowest pri= ority. + # Only add the first(highest priority) match to RetVal + # if Tool not in RetVal: RetVal[Tool] =3D OrderedDict() - RetVal[Tool][Attr] =3D Value + if Attr not in RetVal[Tool]: + RetVal[Tool][Attr] =3D Value =20 ToolsDef =3D '' if GlobalData.gOptions.SilentMode and "MAKE" in RetVal: @@ -860,9 +900,21 @@ class PlatformAutoGen(AutoGen): RetVal["MAKE"]["FLAGS"] =3D "" RetVal["MAKE"]["FLAGS"] +=3D " -s" MakeFlags =3D '' - for Tool in RetVal: - for Attr in RetVal[Tool]: - Value =3D RetVal[Tool][Attr] + + ToolList =3D list(RetVal.keys()) + ToolList.sort() + for Tool in ToolList: + if Tool =3D=3D TAB_STAR: + continue + AttrList =3D list(RetVal[Tool].keys()) + if TAB_STAR in ToolList: + AttrList +=3D list(RetVal[TAB_STAR]) + AttrList.sort() + for Attr in AttrList: + if Attr in RetVal[Tool]: + Value =3D RetVal[Tool][Attr] + else: + Value =3D RetVal[TAB_STAR][Attr] if Tool in self._BuildOptionWithToolDef(RetVal) and Attr i= n self._BuildOptionWithToolDef(RetVal)[Tool]: # check if override is indicated if self._BuildOptionWithToolDef(RetVal)[Tool][Attr].st= artswith('=3D'): @@ -877,7 +929,7 @@ class PlatformAutoGen(AutoGen): if Attr =3D=3D "PATH": # Don't put MAKE definition in the file if Tool !=3D "MAKE": - ToolsDef +=3D "%s =3D %s\n" % (Tool, Value) + ToolsDef +=3D "%s_%s =3D %s\n" % (Tool, Attr,=20 + Value) elif Attr !=3D "DLL": # Don't put MAKE definition in the file if Tool =3D=3D "MAKE": @@ -1469,17 +1521,31 @@ class PlatformAutoGen(AutoGen): Family =3D Key[0] Target, Tag, Arch, Tool, Attr =3D Key[1].split("_") # if tool chain family doesn't match, skip it - if Tool in ToolDef and Family !=3D "": - FamilyIsNull =3D False - if ToolDef[Tool].get(TAB_TOD_DEFINES_BUILDRULEFAMILY, "") = !=3D "": - if Family !=3D ToolDef[Tool][TAB_TOD_DEFINES_BUILDRULE= FAMILY]: - continue - else: - if ToolDef[Tool].get(TAB_TOD_DEFINES_FAMILY, "") =3D= =3D "": - continue - if Family !=3D ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]: - continue - FamilyMatch =3D True + if Family !=3D "": + Found =3D False + if Tool in ToolDef: + FamilyIsNull =3D False + if TAB_TOD_DEFINES_BUILDRULEFAMILY in ToolDef[Tool]: + if Family =3D=3D ToolDef[Tool][TAB_TOD_DEFINES_BUI= LDRULEFAMILY]: + FamilyMatch =3D True + Found =3D True + if TAB_TOD_DEFINES_FAMILY in ToolDef[Tool]: + if Family =3D=3D ToolDef[Tool][TAB_TOD_DEFINES_FAM= ILY]: + FamilyMatch =3D True + Found =3D True + if TAB_STAR in ToolDef: + FamilyIsNull =3D False + if TAB_TOD_DEFINES_BUILDRULEFAMILY in ToolDef[TAB_STAR= ]: + if Family =3D=3D ToolDef[TAB_STAR][TAB_TOD_DEFINES= _BUILDRULEFAMILY]: + FamilyMatch =3D True + Found =3D True + if TAB_TOD_DEFINES_FAMILY in ToolDef[TAB_STAR]: + if Family =3D=3D ToolDef[TAB_STAR][TAB_TOD_DEFINES= _FAMILY]: + FamilyMatch =3D True + Found =3D True + if not Found: + continue + # expand any wildcard if Target =3D=3D TAB_STAR or Target =3D=3D self.BuildTarget: if Tag =3D=3D TAB_STAR or Tag =3D=3D self.ToolChain: @@ -1509,12 +1575,19 @@ class PlatformAutoGen(AutoGen): Family =3D Key[0] Target, Tag, Arch, Tool, Attr =3D Key[1].split("_") # if tool chain family doesn't match, skip it - if Tool not in ToolDef or Family =3D=3D "": + if Family =3D=3D "": continue # option has been added before - if TAB_TOD_DEFINES_FAMILY not in ToolDef[Tool]: - continue - if Family !=3D ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]: + Found =3D False + if Tool in ToolDef: + if TAB_TOD_DEFINES_FAMILY in ToolDef[Tool]: + if Family =3D=3D ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]= : + Found =3D True + if TAB_STAR in ToolDef: + if TAB_TOD_DEFINES_FAMILY in ToolDef[TAB_STAR]: + if Family =3D=3D ToolDef[TAB_STAR][TAB_TOD_DEFINES_FAM= ILY]: + Found =3D True + if not Found: continue =20 # expand any wildcard diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseToo= ls/Source/Python/Common/ToolDefClassObject.py index 8e70407cb9e9..2b4b23849196 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 # -# C= opyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2021, Intel Corporation. All rights=20 +reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # =20 @@ -86,23 +86,6 @@ class ToolDefClassObject(object): self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TARGET_ARCH].sort() self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_COMMAND_TYPE].sort() =20 - KeyList =3D [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TA= G, TAB_TOD_DEFINES_TARGET_ARCH, TAB_TOD_DEFINES_COMMAND_TYPE] - for Index in range(3, -1, -1): - # make a copy of the keys to enumerate over to prevent issues = when - # adding/removing items from the original dict. - for Key in list(self.ToolsDefTxtDictionary.keys()): - List =3D Key.split('_') - if List[Index] =3D=3D TAB_STAR: - for String in self.ToolsDefTxtDatabase[KeyList[Index]]= : - List[Index] =3D String - NewKey =3D '%s_%s_%s_%s_%s' % tuple(List) - if NewKey not in self.ToolsDefTxtDictionary: - self.ToolsDefTxtDictionary[NewKey] =3D self.To= olsDefTxtDictionary[Key] - del self.ToolsDefTxtDictionary[Key] - elif List[Index] not in self.ToolsDefTxtDatabase[KeyList[I= ndex]]: - del self.ToolsDefTxtDictionary[Key] - - ## IncludeToolDefFile # # Load target.txt file and parse it as if its contents were inside the= main file diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable= .py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index 3019ec63c3bb..c31fc24870d5 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -1,7 +1,7 @@ ## @file # Global variables for GenFds # -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2021, Intel Corporation. All rights=20 +reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -875,14 +875,27 @@ d= ef FindExtendTool(KeyStringList, CurrentArchList, NameGuid): ToolOptionKey =3D None KeyList =3D None for tool_def in ToolDefinition.items(): - if NameGuid.lower() =3D=3D tool_def[1].lower(): - KeyList =3D tool_def[0].split('_') - Key =3D KeyList[0] + \ - '_' + \ - KeyList[1] + \ - '_' + \ - KeyList[2] - if Key in KeyStringList and KeyList[4] =3D=3D DataType.TAB_GUI= D: + KeyList =3D tool_def[0].split('_') + if len(KeyList) < 5: + continue + if KeyList[4] !=3D DataType.TAB_GUID: + continue + if NameGuid.lower() !=3D tool_def[1].lower(): + continue + Key =3D KeyList[0] + \ + '_' + \ + KeyList[1] + \ + '_' + \ + KeyList[2] + for KeyString in KeyStringList: + KeyStringBuildTarget, KeyStringToolChain, KeyStringArch =3D Ke= yString.split('_') + if KeyList[0] =3D=3D DataType.TAB_STAR: + KeyList[0] =3D KeyStringBuildTarget + if KeyList[1] =3D=3D DataType.TAB_STAR: + KeyList[1] =3D KeyStringToolChain + if KeyList[2] =3D=3D DataType.TAB_STAR: + KeyList[2] =3D KeyStringArch + if KeyList[0] =3D=3D KeyStringBuildTarget and KeyList[1] =3D= =3D KeyStringToolChain and KeyList[2] =3D=3D KeyStringArch: ToolPathKey =3D Key + '_' + KeyList[3] + '_PATH' ToolOptionKey =3D Key + '_' + KeyList[3] + '_FLAGS' ToolPath =3D ToolDefinition.get(ToolPathKey) diff --git a/= BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/buil= d.py index c4cfe38ad96a..0570c29f1ada 100755 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -2,7 +2,7 @@ # build a platform or a module # # Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
-# C= opyright (c) 2007 - 2020, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2021, Intel Corporation. All rights=20 +reserved.
# Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.
#= Copyright (c) 2020, ARM Limited. All rights reserved.
# @@ -889,6 +8= 89,47 @@ class Build(): except: return False, UNKNOWN_ERROR =20 + ## Add TOOLCHAIN and FAMILY declared in DSC [BuildOptions] to ToolsDef= TxtDatabase. + # + # Loop through the set of build targets, tool chains, and archs provid= ed on either + # the command line or in target.txt to discover FAMILY and TOOLCHAIN d= elclarations + # in [BuildOptions] sections that may be within !if expressions that m= ay use + # $(TARGET), $(TOOLCHAIN), $(TOOLCHAIN_TAG), or $(ARCH) operands. + # + def GetToolChainAndFamilyFromDsc (self, File): + for BuildTarget in self.BuildTargetList: + GlobalData.gGlobalDefines['TARGET'] =3D BuildTarget + for BuildToolChain in self.ToolChainList: + GlobalData.gGlobalDefines['TOOLCHAIN'] =3D BuildToolC= hain + GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] =3D BuildToolC= hain + for BuildArch in self.ArchList: + GlobalData.gGlobalDefines['ARCH'] =3D BuildArch + dscobj =3D self.BuildDatabase[File, BuildArch] + for KeyFamily, Key, KeyCodeBase in dscobj.BuildOptions= : + try: + Target, ToolChain, Arch, Tool, Attr =3D Key.sp= lit('_') + except: + continue + if ToolChain =3D=3D TAB_STAR or Attr !=3D TAB_TOD_= DEFINES_FAMILY: + continue + try: + Family =3D dscobj.BuildOptions[(KeyFamily, Key= , KeyCodeBase)] + Family =3D Family.strip().strip('=3D').strip() + except: + continue + if TAB_TOD_DEFINES_FAMILY not in self.ToolDef.Tool= sDefTxtDatabase: + self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_FAMILY] =3D {} + if ToolChain not in self.ToolDef.ToolsDefTxtDataba= se[TAB_TOD_DEFINES_FAMILY]: + self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_FAMILY][ToolChain] =3D Family + if TAB_TOD_DEFINES_BUILDRULEFAMILY not in self.Too= lDef.ToolsDefTxtDatabase: + self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_BUILDRULEFAMILY] =3D {} + if ToolChain not in self.ToolDef.ToolsDefTxtDataba= se[TAB_TOD_DEFINES_BUILDRULEFAMILY]: + self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_BUILDRULEFAMILY][ToolChain] =3D Family + if TAB_TOD_DEFINES_TOOL_CHAIN_TAG not in self.Tool= Def.ToolsDefTxtDatabase: + self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFIN= ES_TOOL_CHAIN_TAG] =3D [] + if ToolChain not in self.ToolDef.ToolsDefTxtDataba= se[TAB_TOD_DEFINES_TOOL_CHAIN_TAG]: + =20 + self.ToolDef.ToolsDefTxtDatabase[TAB_TOD_DEFINES_TOOL_CHAIN_TAG].appen + d(ToolChain) + ## Load configuration # # This method will parse target.txt and get the build configurations= . @@ -910,6 +951,26 @@ class Build(): if self.ToolChainList is None or len(self.ToolChainList) =3D= =3D 0: EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, ExtraData= =3D"No toolchain given. Don't know how to build.\n") =20 + if not self.PlatformFile: + PlatformFile =3D self.TargetTxt.TargetTxtDictionary[TAB_TAT_DE= FINES_ACTIVE_PLATFORM] + if not PlatformFile: + # Try to find one in current directory + WorkingDirectory =3D os.getcwd() + FileList =3D glob.glob(os.path.normpath(os.path.join(Worki= ngDirectory, '*.dsc'))) + FileNum =3D len(FileList) + if FileNum >=3D 2: + EdkLogger.error("build", OPTION_MISSING, + ExtraData=3D"There are %d DSC files in= %s. Use '-p' to specify one.\n" % (FileNum, WorkingDirectory)) + elif FileNum =3D=3D 1: + PlatformFile =3D FileList[0] + else: + EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, + ExtraData=3D"No active platform=20 + specified in target.txt or command line! Nothing can be built.\n") + + self.PlatformFile =3D PathClass(NormFile(PlatformFile,=20 + self.WorkspaceDir), self.WorkspaceDir) + + self.GetToolChainAndFamilyFromDsc (self.PlatformFile) + # check if the tool chains are defined or not NewToolChainList =3D [] for ToolChain in self.ToolChainList: @@ -935,23 +996,6 @@ class Build(): ToolChainFamily.append(ToolDefinition[TAB_TOD_DEFINES_FAMI= LY][Tool]) self.ToolChainFamily =3D ToolChainFamily =20 - if not self.PlatformFile: - PlatformFile =3D self.TargetTxt.TargetTxtDictionary[TAB_TAT_DE= FINES_ACTIVE_PLATFORM] - if not PlatformFile: - # Try to find one in current directory - WorkingDirectory =3D os.getcwd() - FileList =3D glob.glob(os.path.normpath(os.path.join(Worki= ngDirectory, '*.dsc'))) - FileNum =3D len(FileList) - if FileNum >=3D 2: - EdkLogger.error("build", OPTION_MISSING, - ExtraData=3D"There are %d DSC files in= %s. Use '-p' to specify one.\n" % (FileNum, WorkingDirectory)) - elif FileNum =3D=3D 1: - PlatformFile =3D FileList[0] - else: - EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, - ExtraData=3D"No active platform specif= ied in target.txt or command line! Nothing can be built.\n") - - self.PlatformFile =3D PathClass(NormFile(PlatformFile, self.Wo= rkspaceDir), self.WorkspaceDir) self.ThreadNumber =3D ThreadNum() ## Initialize build configuration # @@ -2381,24 +2425,25 @@ class Build(): continue =20 for Arch in self.ArchList: - # Build up the list of supported architectures for thi= s build - prefix =3D '%s_%s_%s_' % (BuildTarget, ToolChain, Arch= ) - # Look through the tool definitions for GUIDed tools guidAttribs =3D [] for (attrib, value) in self.ToolDef.ToolsDefTxtDiction= ary.items(): - if attrib.upper().endswith('_GUID'): - split =3D attrib.split('_') - thisPrefix =3D '_'.join(split[0:3]) + '_' - if thisPrefix =3D=3D prefix: - guid =3D self.ToolDef.ToolsDefTxtDictionar= y[attrib] - guid =3D guid.lower() - toolName =3D split[3] - path =3D '_'.join(split[0:4]) + '_PATH' - path =3D self.ToolDef.ToolsDefTxtDictionar= y[path] - path =3D self.GetRealPathOfTool(path) - guidAttribs.append((guid, toolName, path)) - + GuidBuildTarget, GuidToolChain, GuidArch, GuidTool= , GuidAttr =3D attrib.split('_') + if GuidAttr.upper() =3D=3D 'GUID': + if GuidBuildTarget =3D=3D TAB_STAR: + GuidBuildTarget =3D BuildTarget + if GuidToolChain =3D=3D TAB_STAR: + GuidToolChain =3D ToolChain + if GuidArch =3D=3D TAB_STAR: + GuidArch =3D Arch + if GuidBuildTarget =3D=3D BuildTarget and Guid= ToolChain =3D=3D ToolChain and GuidArch =3D=3D Arch: + path =3D '_'.join(attrib.split('_')[:-1]) = + '_PATH' + if path in self.ToolDef.ToolsDefTxtDiction= ary: + path =3D self.ToolDef.ToolsDefTxtDicti= onary[path] + path =3D self.GetRealPathOfTool(path) + guidAttribs.append((value.lower(), Gui= dTool, path)) + # Sort by GuidTool name + sorted (guidAttribs, key=3Dlambda x: x[1]) # Write out GuidedSecTools.txt toolsFile =3D os.path.join(FvDir, 'GuidedSectionTools.= txt') toolsFile =3D open(toolsFile, 'wt') -- 2.31.1.windows.1