diff options
author | Yonghong Zhu <yonghong.zhu@intel.com> | 2017-04-13 14:33:05 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2017-06-24 23:00:08 +0800 |
commit | dfa41b4a483e562f3c739acfbc2d911550f50e47 (patch) | |
tree | 727744d9c5d65fb293264759f9f31960d56df838 | |
parent | 78bcd52abb1444c4dec7536d35f1a89dfe7e3625 (diff) | |
download | edk2-dfa41b4a483e562f3c739acfbc2d911550f50e47.zip edk2-dfa41b4a483e562f3c739acfbc2d911550f50e47.tar.gz edk2-dfa41b4a483e562f3c739acfbc2d911550f50e47.tar.bz2 |
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>
Reviewed-by: Liming Gao <liming.gao@intel.com>
-rw-r--r-- | BaseTools/Source/Python/AutoGen/AutoGen.py | 36 | ||||
-rw-r--r-- | BaseTools/Source/Python/AutoGen/InfSectionParser.py | 18 |
2 files changed, 54 insertions, 0 deletions
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index e05bf47..70e2e62 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -143,6 +143,8 @@ ${END} ${depexsection_item}
+${userextension_tianocore_item}
+
${tail_comments}
[BuildOptions.${module_arch}]
@@ -3088,6 +3090,30 @@ class ModuleAutoGen(AutoGen): 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
@@ -4059,6 +4085,16 @@ class ModuleAutoGen(AutoGen): 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()
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 @@ -62,6 +62,24 @@ class InfSectionParser(): 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
#
|