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 C350F21A13496 for ; Wed, 3 May 2017 02:24:31 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2017 02:24:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,283,1491289200"; d="scan'208";a="96642493" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga005.fm.intel.com with ESMTP; 03 May 2017 02:24:31 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 3 May 2017 02:24:31 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 3 May 2017 02:24:31 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.246]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.224]) with mapi id 14.03.0319.002; Wed, 3 May 2017 17:24:27 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] BaseTools: Copy "TianoCore" userextensions into As Built Inf Thread-Index: AQHStCjZaWcCvqhgw0uk2Oz+L6jqSKHidbfQ Date: Wed, 3 May 2017 09:24:26 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D728457@shsmsx102.ccr.corp.intel.com> References: <1492069058-18964-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1492069058-18964-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] BaseTools: Copy "TianoCore" userextensions into As Built Inf X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 May 2017 09:24:32 -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 >Sent: Thursday, April 13, 2017 3:38 PM >To: edk2-devel@lists.01.org >Cc: Gao, Liming >Subject: [Patch] BaseTools: Copy "TianoCore" userextensions into As Built = Inf > >Per build spec to update the tool to copy "TianoCore" userextensions to >As Built INF file. > >Cc: Liming Gao >Contributed-under: TianoCore Contribution Agreement 1.0 >Signed-off-by: Yonghong Zhu >--- > BaseTools/Source/Python/AutoGen/AutoGen.py | 36 >++++++++++++++++++++++ > .../Source/Python/AutoGen/InfSectionParser.py | 18 +++++++++++ > 2 files changed, 54 insertions(+) > >diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py >b/BaseTools/Source/Python/AutoGen/AutoGen.py >index 285e4a4..c18802f 100644 >--- a/BaseTools/Source/Python/AutoGen/AutoGen.py >+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py >@@ -138,10 +138,12 @@ ${END} > ## @LIB_INSTANCES${BEGIN} > # ${libraryclasses_item}${END} > > ${depexsection_item} > >+${userextension_tianocore_item} >+ > ${tail_comments} > > [BuildOptions.${module_arch}] > ## @AsBuilt${BEGIN} > ## ${flags_item}${END} >@@ -3077,10 +3079,34 @@ class ModuleAutoGen(AutoGen): > if len(DepexExpressionList) > 0: > EdkLogger.verbose('') > self._DepexExpressionList[ModuleType] =3D DepexExpression= List > return self._DepexExpressionList > >+ # Get the tiano core user extension, it is contain dependent library. >+ # @retval: a list contain tiano core userextension. >+ # >+ def _GetTianoCoreUserExtensionList(self): >+ TianoCoreUserExtentionList =3D [] >+ for M in [self.Module] + self.DependentLibraryList: >+ Filename =3D M.MetaFile.Path >+ InfObj =3D InfSectionParser.InfSectionParser(Filename) >+ TianoCoreUserExtenList =3D InfObj.GetUserExtensionTianoCore() >+ for TianoCoreUserExtent in TianoCoreUserExtenList: >+ for Section in TianoCoreUserExtent.keys(): >+ ItemList =3D Section.split(TAB_SPLIT) >+ Arch =3D self.Arch >+ if len(ItemList) =3D=3D 4: >+ Arch =3D ItemList[3] >+ if Arch.upper() =3D=3D TAB_ARCH_COMMON or Arch.upper(= ) =3D=3D >self.Arch.upper(): >+ TianoCoreList =3D [] >+ TianoCoreList.extend([TAB_SECTION_START + Section= + >TAB_SECTION_END]) >+ TianoCoreList.extend(TianoCoreUserExtent[Section]= [:]) >+ TianoCoreList.append('\n') >+ TianoCoreUserExtentionList.append(TianoCoreList) >+ >+ return TianoCoreUserExtentionList >+ > ## Return the list of specification version required for the module > # > # @retval list The list of specification defined in module f= ile > # > def _GetSpecification(self): >@@ -4044,10 +4070,20 @@ class ModuleAutoGen(AutoGen): > > # Generated LibraryClasses section in comments. > for Library in self.LibraryAutoGenList: > AsBuiltInfDict['libraryclasses_item'] +=3D [Library.MetaFile.= File.replace('\\', >'/')] > >+ # Generated UserExtensions TianoCore section. >+ # All tianocore user extensions are copied. >+ UserExtStr =3D '' >+ for TianoCore in self._GetTianoCoreUserExtensionList(): >+ UserExtStr +=3D '\n'.join(TianoCore) >+ ExtensionFile =3D os.path.join(self.MetaFile.Dir, TianoCore[1= ]) >+ if os.path.isfile(ExtensionFile): >+ shutil.copy2(ExtensionFile, self.OutputDir) >+ AsBuiltInfDict['userextension_tianocore_item'] =3D UserExtStr >+ > # Generated depex expression section in comments. > AsBuiltInfDict['depexsection_item'] =3D '' > DepexExpresion =3D self._GetDepexExpresionString() > if DepexExpresion: > AsBuiltInfDict['depexsection_item'] =3D DepexExpresion >diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py >b/BaseTools/Source/Python/AutoGen/InfSectionParser.py >index 7f78236..cdc9e5e 100644 >--- a/BaseTools/Source/Python/AutoGen/InfSectionParser.py >+++ b/BaseTools/Source/Python/AutoGen/InfSectionParser.py >@@ -60,10 +60,28 @@ class InfSectionParser(): > FindEnd =3D True > self._FileSectionDataList.append({SectionLine: SectionDat= a[:]}) > SectionData =3D [] > SectionLine =3D '' > >+ # Get user extension TianoCore data >+ # >+ # @return: a list include some dictionary that key is section and val= ue is a >list contain all data. >+ def GetUserExtensionTianoCore(self): >+ UserExtensionTianoCore =3D [] >+ if not self._FileSectionDataList: >+ return UserExtensionTianoCore >+ for SectionDataDict in self._FileSectionDataList: >+ for key in SectionDataDict.keys(): >+ if key.lower().startswith("[userextensions") and >key.lower().find('.tianocore.') > -1: >+ SectionLine =3D >key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END) >+ SubSectionList =3D [SectionLine] >+ if str(SectionLine).find(TAB_COMMA_SPLIT) > -1: >+ SubSectionList =3D str(SectionLine).split(TAB_COM= MA_SPLIT) >+ for SubSection in SubSectionList: >+ if SubSection.lower().find('.tianocore.') > -1: >+ UserExtensionTianoCore.append({SubSection: >SectionDataDict[key]}) >+ return UserExtensionTianoCore > > # Get depex expresion > # > # @return: a list include some dictionary that key is section and val= ue is a list >contain all data. > def GetDepexExpresionList(self): >-- >2.6.1.windows.1