public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: "Zhu, Yonghong" <yonghong.zhu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [Patch] BaseTools: Copy "TianoCore" userextensions into As Built Inf
Date: Wed, 3 May 2017 09:24:26 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D728457@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1492069058-18964-1-git-send-email-yonghong.zhu@intel.com>

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Zhu, Yonghong
>Sent: Thursday, April 13, 2017 3:38 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>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 <liming.gao@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
>---
> 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] = DepexExpressionList
>         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 = []
>+        for M in [self.Module] + self.DependentLibraryList:
>+            Filename = M.MetaFile.Path
>+            InfObj = InfSectionParser.InfSectionParser(Filename)
>+            TianoCoreUserExtenList = InfObj.GetUserExtensionTianoCore()
>+            for TianoCoreUserExtent in TianoCoreUserExtenList:
>+                for Section in TianoCoreUserExtent.keys():
>+                    ItemList = Section.split(TAB_SPLIT)
>+                    Arch = self.Arch
>+                    if len(ItemList) == 4:
>+                        Arch = ItemList[3]
>+                    if Arch.upper() == TAB_ARCH_COMMON or Arch.upper() ==
>self.Arch.upper():
>+                        TianoCoreList = []
>+                        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 file
>     #
>     def _GetSpecification(self):
>@@ -4044,10 +4070,20 @@ class ModuleAutoGen(AutoGen):
>
>         # Generated LibraryClasses section in comments.
>         for Library in self.LibraryAutoGenList:
>             AsBuiltInfDict['libraryclasses_item'] += [Library.MetaFile.File.replace('\\',
>'/')]
>
>+        # Generated UserExtensions TianoCore section.
>+        # All tianocore user extensions are copied.
>+        UserExtStr = ''
>+        for TianoCore in self._GetTianoCoreUserExtensionList():
>+            UserExtStr += '\n'.join(TianoCore)
>+            ExtensionFile = os.path.join(self.MetaFile.Dir, TianoCore[1])
>+            if os.path.isfile(ExtensionFile):
>+                shutil.copy2(ExtensionFile, self.OutputDir)
>+        AsBuiltInfDict['userextension_tianocore_item'] = UserExtStr
>+
>         # Generated depex expression section in comments.
>         AsBuiltInfDict['depexsection_item'] = ''
>         DepexExpresion = self._GetDepexExpresionString()
>         if DepexExpresion:
>             AsBuiltInfDict['depexsection_item'] = 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 = True
>                 self._FileSectionDataList.append({SectionLine: SectionData[:]})
>                 SectionData = []
>                 SectionLine = ''
>
>+    # Get user extension TianoCore data
>+    #
>+    # @return: a list include some dictionary that key is section and value is a
>list contain all data.
>+    def GetUserExtensionTianoCore(self):
>+        UserExtensionTianoCore = []
>+        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 =
>key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)
>+                    SubSectionList = [SectionLine]
>+                    if str(SectionLine).find(TAB_COMMA_SPLIT) > -1:
>+                        SubSectionList = str(SectionLine).split(TAB_COMMA_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 value is a list
>contain all data.
>     def GetDepexExpresionList(self):
>--
>2.6.1.windows.1



      reply	other threads:[~2017-05-03  9:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-13  7:37 [Patch] BaseTools: Copy "TianoCore" userextensions into As Built Inf Yonghong Zhu
2017-05-03  9:24 ` Gao, Liming [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14D728457@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox