]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Copy "TianoCore" userextensions into As Built Inf
authorYonghong Zhu <yonghong.zhu@intel.com>
Thu, 13 Apr 2017 06:33:05 +0000 (14:33 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Sat, 24 Jun 2017 15:00:08 +0000 (23:00 +0800)
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>
BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/AutoGen/InfSectionParser.py

index e05bf479ff837d13916b22a86caed8a08a86ca0f..70e2e62057c1d37451779388462c2310680f59fa 100644 (file)
@@ -143,6 +143,8 @@ ${END}
 \r
 ${depexsection_item}\r
 \r
+${userextension_tianocore_item}\r
+\r
 ${tail_comments}\r
 \r
 [BuildOptions.${module_arch}]\r
@@ -3088,6 +3090,30 @@ class ModuleAutoGen(AutoGen):
                 self._DepexExpressionList[ModuleType] = DepexExpressionList\r
         return self._DepexExpressionList\r
 \r
+    # Get the tiano core user extension, it is contain dependent library.\r
+    # @retval: a list contain tiano core userextension.\r
+    #\r
+    def _GetTianoCoreUserExtensionList(self):\r
+        TianoCoreUserExtentionList = []\r
+        for M in [self.Module] + self.DependentLibraryList:\r
+            Filename = M.MetaFile.Path\r
+            InfObj = InfSectionParser.InfSectionParser(Filename)\r
+            TianoCoreUserExtenList = InfObj.GetUserExtensionTianoCore()\r
+            for TianoCoreUserExtent in TianoCoreUserExtenList:\r
+                for Section in TianoCoreUserExtent.keys():\r
+                    ItemList = Section.split(TAB_SPLIT)\r
+                    Arch = self.Arch\r
+                    if len(ItemList) == 4:\r
+                        Arch = ItemList[3]\r
+                    if Arch.upper() == TAB_ARCH_COMMON or Arch.upper() == self.Arch.upper():\r
+                        TianoCoreList = []\r
+                        TianoCoreList.extend([TAB_SECTION_START + Section + TAB_SECTION_END])\r
+                        TianoCoreList.extend(TianoCoreUserExtent[Section][:])\r
+                        TianoCoreList.append('\n')\r
+                        TianoCoreUserExtentionList.append(TianoCoreList)\r
+\r
+        return TianoCoreUserExtentionList\r
+\r
     ## Return the list of specification version required for the module\r
     #\r
     #   @retval     list    The list of specification defined in module file\r
@@ -4059,6 +4085,16 @@ class ModuleAutoGen(AutoGen):
         for Library in self.LibraryAutoGenList:\r
             AsBuiltInfDict['libraryclasses_item'] += [Library.MetaFile.File.replace('\\', '/')]\r
         \r
+        # Generated UserExtensions TianoCore section.\r
+        # All tianocore user extensions are copied.\r
+        UserExtStr = ''\r
+        for TianoCore in self._GetTianoCoreUserExtensionList():\r
+            UserExtStr += '\n'.join(TianoCore)\r
+            ExtensionFile = os.path.join(self.MetaFile.Dir, TianoCore[1])\r
+            if os.path.isfile(ExtensionFile):\r
+                shutil.copy2(ExtensionFile, self.OutputDir)\r
+        AsBuiltInfDict['userextension_tianocore_item'] = UserExtStr\r
+\r
         # Generated depex expression section in comments.\r
         AsBuiltInfDict['depexsection_item'] = ''\r
         DepexExpresion = self._GetDepexExpresionString()\r
index 7f782365480e7d1e4d5bada4adc805ed3833113f..cdc9e5e8a849808b6bbc8677c1a69fefc5b23be8 100644 (file)
@@ -62,6 +62,24 @@ class InfSectionParser():
                 SectionData = []\r
                 SectionLine = ''\r
     \r
+    # Get user extension TianoCore data\r
+    #\r
+    # @return: a list include some dictionary that key is section and value is a list contain all data.\r
+    def GetUserExtensionTianoCore(self):\r
+        UserExtensionTianoCore = []\r
+        if not self._FileSectionDataList:\r
+            return UserExtensionTianoCore\r
+        for SectionDataDict in self._FileSectionDataList:\r
+            for key in SectionDataDict.keys():\r
+                if key.lower().startswith("[userextensions") and key.lower().find('.tianocore.') > -1:\r
+                    SectionLine = key.lstrip(TAB_SECTION_START).rstrip(TAB_SECTION_END)\r
+                    SubSectionList = [SectionLine]\r
+                    if str(SectionLine).find(TAB_COMMA_SPLIT) > -1:\r
+                        SubSectionList = str(SectionLine).split(TAB_COMMA_SPLIT)\r
+                    for SubSection in SubSectionList:\r
+                        if SubSection.lower().find('.tianocore.') > -1:\r
+                            UserExtensionTianoCore.append({SubSection: SectionDataDict[key]})\r
+        return UserExtensionTianoCore\r
 \r
     # Get depex expresion\r
     #\r