From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.8726.1619597051061101751 for ; Wed, 28 Apr 2021 01:04:11 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=vCjj2uox; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: bob.c.feng@intel.com) IronPort-SDR: 5IULIv9AIf6WA8G0hr/oVpQ6ayGxb9i1IHmeRnXSLM8hL9T1JdDC58Z3aX4QyKbPr6zcKJ5Km4 u1rh7ZBweZ+Q== X-IronPort-AV: E=McAfee;i="6200,9189,9967"; a="257986509" X-IronPort-AV: E=Sophos;i="5.82,257,1613462400"; d="scan'208";a="257986509" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2021 01:04:09 -0700 IronPort-SDR: xGSbbpJw4Dky4qyYnAnXK+Dwc+XSxWKzpbiW/QVUjOgvLDYLCcuHT7pCg0g1jGhCVQErUV2mm9 luXdaX13L1aw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,257,1613462400"; d="scan'208";a="526405563" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga001.fm.intel.com with ESMTP; 28 Apr 2021 01:04:09 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX603.amr.corp.intel.com (10.22.229.16) 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 01:04:09 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx609.amr.corp.intel.com (10.22.229.22) 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 01:04:09 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.103) by edgegateway.intel.com (134.134.137.100) 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 01:04:08 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k8STCTduFeGd/vshxUMQMeqpbFYU2mxfIyc17YBC0/u+ZeKWxn19YywVqrym9wlT04ubFK2whbUOl9c43C1F4DjGvIcY0rv4+Oj6UdUJIsgs93oOIT+K50P750X+5cUOo2oLaKa1op9N7gdnY7Kur7OrkRpKsjsNC4opY/o21FZEVEp+TahvyFEP/eBFQYelcnG5YJHFvXgisDXS08hTk0d5bCyUIT5pRTeQ42JU4J8trtu8+pAKguFY2jsdjKqextMD0Ezb/JIKp3YVCNMyZyqQX17gKq90AxMu8K5iXEY3U1CHq0y3DAjWkxgg93NKmb6qGJZUV3Lsz503ZxsWGA== 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=Uge73sPBNRBOk2Q1RWxq/GXP/918LA+kjsl5HEQT7dE=; b=UtDdJev9GkTOnXDLEriGsjLF4SizJ8rNCKOHNhduQkMV8OQe+y04UqdxdtARBW64pl/iziE+Qd5gWCZM0kqwKXIiRRQ0w85hzg/ooVUJbYjq+qdpVqtD7/JwewFiBXpqTLeDWZCaiUL91f96zv1NF3L0cB1baMm40+PSqvEBcoLJi7uR2yOxKVPI7yA3dtp1u7gRWMmKM8EvFpyC83budMl3OCUsTRaKu2MC8X/MwtA0aLbwvzRoGXpZ5OTMwVANpKKOx7ZuuGiGbD8Yz0d0mZSPR5hNWDNgVAVPqoP2E4C6mJVZmOOXlfmT+aiT64ZPAYqXMbXQim2wN8tdUbIzuw== 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=Uge73sPBNRBOk2Q1RWxq/GXP/918LA+kjsl5HEQT7dE=; b=vCjj2uoxbhI+87WzXNgPRt1enCiywfYJSsxzLiSscVb004ZRnbG8BeYTCincSlkRRQGqUonmXzuummof0dkAufTQJhT8+R6NIdGZlluO1L/YUXpe096ZPjYRC7OkMzP571uyCIyebDdiY+QUmrAhIGXSF/EJhXCDrF/1tDKM47s= Received: from DM6PR11MB4073.namprd11.prod.outlook.com (2603:10b6:5:19f::22) by DM5PR11MB1484.namprd11.prod.outlook.com (2603:10b6:4:8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Wed, 28 Apr 2021 08:04:06 +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; Wed, 28 Apr 2021 08:04:06 +0000 From: "Bob Feng" To: "Kinney, Michael D" , "devel@edk2.groups.io" CC: Liming Gao , "Chen, Christine" Subject: Re: [Patch 1/1] BaseTools/Source/Python: New Target/ToolChain/Arch in DSC [BuildOptions] Thread-Topic: [Patch 1/1] BaseTools/Source/Python: New Target/ToolChain/Arch in DSC [BuildOptions] Thread-Index: AQHXO9DT7ORSZ6jMskCkEb7Z4KjN3KrJi+Hw Date: Wed, 28 Apr 2021 08:04:06 +0000 Message-ID: References: <20210428014958.404-1-michael.d.kinney@intel.com> In-Reply-To: <20210428014958.404-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: da1456b6-20dd-410c-1d4b-08d90a1c31e4 x-ms-traffictypediagnostic: DM5PR11MB1484: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:335; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dndX7sctvTpyXOcOlN1g4yciqSByyaMC4jwFK0OA61LNAfwLR/urauU+knWa97gR9dWnrkNViBkSbooQjG7YtFOwX4glXRPbOCcM4oy64ft3u5kj8v4sfdNjV/HQkQd9f3MEwXtOaZltZ/HugSczROpxXKdE470K9B/vnqBjUJBQA+GJlMGsrmh3BrSfSmROo0KWwBoHB71qQuMQtHooe2nf0eFVWa/8h3Nc1USx5hw9mCE0AJ021LftCljgSUPI1Yj3U6Ihj25qdGNF9ULKy3JLzpHzwmmfirBqasqvcfNQsCPhYgO1M9cXv4W8NrIDc8rFMuknP2+qcMlKG6VBBXJDsGUhtif7g6rFYa94zkpTC/FvetGy35Bc0NfXtt8SmUEssQazcRY7/5Ln6uusul9AAEY5F2rEzAsFCdXQ6XRhfJCbhLhBszvs5gugmhW9U/eF9O5YCcIlejbCbQ8RGsG86tGgg7ekpJ+PEf9p5bPug/tm/0RcgqWP51dxpXZF5Lu+LCBkrDVePcJ9EDfgSV/ejJWbOZpV6xRYdccBOnUtEpyw2VFWQUzOpqZQ7H/P2dFem/211bND6wJw+BxG6SH5LpvPxszR9cSCalCJ+eirJcdp6+z56yzujGlvGVCAbOARMWEntC/Bp5B+dRWn27HxjtYQxFNgBfl5LMsACS8wefXcl7B2cmXgafoMoIDR 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:(396003)(366004)(346002)(136003)(376002)(39860400002)(4326008)(110136005)(966005)(54906003)(5660300002)(83380400001)(38100700002)(76116006)(52536014)(30864003)(478600001)(8676002)(53546011)(66476007)(66946007)(71200400001)(26005)(33656002)(316002)(86362001)(7696005)(66446008)(6506007)(64756008)(55016002)(9686003)(107886003)(122000001)(2906002)(8936002)(66556008)(186003)(559001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?Sb/1HNig4qsbWU1bkHVur7AMAJSxeaaEMXSGY9t+wfFS9e7h2Szn0V9aeb9M?= =?us-ascii?Q?cH6mBkVLArawLfN/uHnv+gw7IqkRBvIccIie3MtCDrkSTnWgFmOBI8os5t40?= =?us-ascii?Q?3iCxU619tP9H8zPpIrvbYNUImy/gMxwL2Ce1Mv29R1IdpPMoTy1Shsmxgs8s?= =?us-ascii?Q?UOzlQnCs61TIZfdMMpDibGSPEGDDzPIieu9YM7wkM/myScVvxU9QbPE9+Nrw?= =?us-ascii?Q?dNS8S3+2SyPeREucZwunrU84U263SiAjk9rjxnUqWiJ+djY31oFdfcJXlF/W?= =?us-ascii?Q?Df0LEE1cdJS69jZe6m+PWrwlU8+kJL6raBoopgam0XKOdhoW4S8oYf4KcqZC?= =?us-ascii?Q?3jZUqIs2yzXZuZQ9RZlTzvvPSwkoJ1Si2DMjTWghn+xj+Vt8+J8ULf6k4l4u?= =?us-ascii?Q?9UQkGYWZlYhUrxmvAYkzI8v1V3LesgQRh0iFAFwRXWOdA25HWK2+opcKYkQn?= =?us-ascii?Q?EhiQMvcZWLPCS7GUpl26vwdS0eWWEK3IhzZ2sZNQbXLhvhJO85nlO6q1jPCU?= =?us-ascii?Q?8XNiQ3mJDMNvQ3JmkpUB/0726jyXTIFh8R0IrHcljw80c+aLcq1TgsG+C42Y?= =?us-ascii?Q?lwc9EQQwfCvdTXKszDMupLGX9kIPByLwWLxQKrnw6bxSQjz9I3o8KfeNrIhy?= =?us-ascii?Q?2WDchQqExRco5h8hnacFdsNx/fXfjvtsQNQ5l/sA7nI/9sPiqORJY5eEjRB/?= =?us-ascii?Q?JXlxrsJ/Vp8Gv3btA7l12DYe0y8PLko+0QdZm0KJ4fph9wtcZKSza8fKXYxS?= =?us-ascii?Q?T6I2pqJGT3eHl27okLu21ORofHcC4bqLUaDHC8O/O9q1qMTcixpLiakC3Y03?= =?us-ascii?Q?xUswjTxFNp+1uRg2pcQREsTYCSibZKxk06iTvXk0HbzV6YnC2J/gDNMOJXlg?= =?us-ascii?Q?JLQ5xmymodHXqzN3PNTRH0+9on7PVsFJPh0fOtovgU/n46MINGbycLcKolnJ?= =?us-ascii?Q?8OyBVFA2ZYuKG1aJHnT2PHryR8frHLKjZoHtL0hdwX1Rr7ZwCiZxVR8GYMfp?= =?us-ascii?Q?Hn8F8P9Jd2irANGI8G/9t67yqZDp7T1wS6uu66Tjuaopv5uYsiHNVuJnLjyV?= =?us-ascii?Q?5QLKTdVk3Nkz1tHOVgKjEcemFVHOKh5zQpyum1pvHuSw+St+crZVdtX5kQlh?= =?us-ascii?Q?IW79Q3YAdf5qF1Ayr4IypY9RIOP2xX3/Hcp7rk47asEzM0GdVTbjEVD+0TOz?= =?us-ascii?Q?acKNKqBAVC07It7mr8j68r5Ovl79+eRiG56HrNAJXdwOsKaRGpG7+gxLOnjG?= =?us-ascii?Q?X19pAgl5NtOrAzqISLohMm2Z+ZuxwLqXog2ITD//G4Pq/F8jvBkNRTmp7uHb?= =?us-ascii?Q?eVdH0mQO4hvvN6pf3zl+6yJy?= 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: da1456b6-20dd-410c-1d4b-08d90a1c31e4 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Apr 2021 08:04:06.1121 (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: P91hNsNcgw37NWOeepLLDSkDBswKGJOkhqf8euaONPxIgJGoZsfmx+nMVrVZa5OeLQThAvVNzojRBBswF1aUng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1484 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 Hi Mike, For the new function ReadDscFile(), I'd recommend to use the DscParser to p= arse dsc file and use DscBuildData to get BuildOptions The DscBuildData object can be got in this way. dsc_build_data =3D self.BuildDatabase[self.PlatformFile, Arch] And the build options can be got via dsc_build_data.BuildOptions Other changes are good to me. Thanks, Bob -----Original Message----- From: Kinney, Michael D =20 Sent: Wednesday, April 28, 2021 9:50 AM To: devel@edk2.groups.io Cc: Feng, Bob C ; Liming Gao ; Chen, Christine Subject: [Patch 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 | 110 ++++++++++++----- 5 files changed, 229 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..6190bf47fd10 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.
# @@ -63,6 +63= ,8 @@ from GenFds.FdfParser import FdfParser from AutoGen.IncludesAutoGen = import IncludesAutoGen from GenFds.GenFds import resetFdsGlobalVariable =20 +import configparser + ## standard targets of build command gSupportedTarget =3D ['all', 'genc', 'genmake', 'modules', 'libraries', 'f= ds', 'clean', 'cleanall', 'cleanlib', 'run'] =20 @@ -889,12 +891,70 @@ class Build(): except: return False, UNKNOWN_ERROR =20 + def ReadDscFile (self, File): + try: + Lines =3D [Line.strip() for Line in open(File.OriginalPath.Pat= h).readlines()] + except: + return [] + Result =3D [] + for Line in Lines: + if Line.startswith ('!include '): + IncludeFile =3D Line.split('!include')[1].strip() + IncludeFile =3D PathClass(NormFile(IncludeFile, self.Works= paceDir), self.WorkspaceDir) + Result +=3D self.ReadDscFile (IncludeFile) + else: + Result.append(Line) + return Result + + def GetToolChainAndFamilyFromDsc (self, File): + config =3D configparser.ConfigParser(strict=3DFalse,delimiters=3D(= '=3D','|'),allow_no_value=3DTrue) + config.optionxform =3D lambda option: option + config.read_string('\n'.join(self.ReadDscFile(File))) + for section in config.sections(): + if section.startswith ('BuildOptions'): + for item in config[section].items(): + if item[0].strip().endswith ('_FAMILY'): + ToolChain =3D item[0].split('_')[1] + Family =3Ditem[1].strip().lstrip('=3D').strip() + 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= . # def LoadConfiguration(self): =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) + # if no ARCH given in command line, get it from target.txt if not self.ArchList: self.ArchList =3D self.TargetTxt.TargetTxtDictionary[TAB_TAT_D= EFINES_TARGET_ARCH] @@ -935,23 +995,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 +2424,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