]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/EfiSection.py
BaseTools: Update Makefile to support FFS file generation
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / EfiSection.py
index 7da3c1e7b0c88e1a84446d0665c832e31a2c7fa8..7b3b71719147c9e7e61315a327bdd09638be230d 100644 (file)
@@ -53,7 +53,7 @@ class EfiSection (EfiSectionClassObject):
     #   @param  Dict        dictionary contains macro and its value\r
     #   @retval tuple       (Generated file name list, section alignment)\r
     #\r
-    def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}) :\r
+    def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False) :\r
         \r
         if self.FileName != None and self.FileName.startswith('PCD('):\r
             self.FileName = GenFdsGlobalVariable.GetPcdValue(self.FileName)\r
@@ -91,6 +91,8 @@ class EfiSection (EfiSectionClassObject):
                 FileList.append(Filename)\r
             elif os.path.exists(Filename):\r
                 FileList.append(Filename)\r
+            elif '.depex' in FfsInf.FinalTargetSuffixMap or FfsInf.Depex:\r
+                FileList.append(Filename)\r
         else:\r
             FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict)\r
             if IsSect :\r
@@ -119,8 +121,9 @@ class EfiSection (EfiSectionClassObject):
                 Num = SecNum\r
                 OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))\r
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',\r
-                                                     #Ui=StringData, \r
-                                                     Ver=BuildNum)\r
+                                                    #Ui=StringData,\r
+                                                    Ver=BuildNum,\r
+                                                    IsMakefile=IsMakefile)\r
                 OutputFileList.append(OutputFile)\r
 \r
             elif FileList != []:\r
@@ -135,8 +138,9 @@ class EfiSection (EfiSectionClassObject):
                     if BuildNum != None and BuildNum != '':\r
                         BuildNumTuple = ('-j', BuildNum)\r
                     GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',\r
-                                                         #Ui=VerString, \r
-                                                         Ver=BuildNum)\r
+                                                        #Ui=VerString,\r
+                                                        Ver=BuildNum,\r
+                                                        IsMakefile=IsMakefile)\r
                     OutputFileList.append(OutputFile)\r
 \r
             else:\r
@@ -157,8 +161,9 @@ class EfiSection (EfiSectionClassObject):
                 Num = SecNum\r
                 OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))\r
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',\r
-                                                     #Ui=VerString, \r
-                                                     Ver=BuildNum)\r
+                                                    #Ui=VerString,\r
+                                                    Ver=BuildNum,\r
+                                                    IsMakefile=IsMakefile)\r
                 OutputFileList.append(OutputFile)\r
 \r
         #\r
@@ -175,7 +180,7 @@ class EfiSection (EfiSectionClassObject):
                 Num = SecNum\r
                 OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))\r
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',\r
-                                                     Ui=StringData)\r
+                                                     Ui=StringData, IsMakefile=IsMakefile)\r
                 OutputFileList.append(OutputFile)\r
 \r
             elif FileList != []:\r
@@ -187,7 +192,7 @@ class EfiSection (EfiSectionClassObject):
                     UiString = f.read()\r
                     f.close()\r
                     GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',\r
-                                                         Ui=UiString)\r
+                                                        Ui=UiString, IsMakefile=IsMakefile)\r
                     OutputFileList.append(OutputFile)\r
             else:\r
                 if StringData != None and len(StringData) > 0:\r
@@ -204,7 +209,7 @@ class EfiSection (EfiSectionClassObject):
                 Num = SecNum\r
                 OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))\r
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',\r
-                                                     Ui=StringData)\r
+                                                     Ui=StringData, IsMakefile=IsMakefile)\r
                 OutputFileList.append(OutputFile)\r
 \r
 \r
@@ -238,23 +243,36 @@ class EfiSection (EfiSectionClassObject):
 \r
                     if File[(len(File)-4):] == '.efi':\r
                         MapFile = File.replace('.efi', '.map')\r
-                        if os.path.exists(MapFile):\r
-                            CopyMapFile = os.path.join(OutputPath, ModuleName + '.map')\r
-                            if not os.path.exists(CopyMapFile) or \\r
-                                   (os.path.getmtime(MapFile) > os.path.getmtime(CopyMapFile)):\r
-                                CopyLongFilePath(MapFile, CopyMapFile)\r
+                        CopyMapFile = os.path.join(OutputPath, ModuleName + '.map')\r
+                        if IsMakefile:\r
+                            if GenFdsGlobalVariable.CopyList == []:\r
+                                GenFdsGlobalVariable.CopyList = [(MapFile, CopyMapFile)]\r
+                            else:\r
+                                GenFdsGlobalVariable.CopyList.append((MapFile, CopyMapFile))\r
+                        else:\r
+                            if os.path.exists(MapFile):\r
+                                if not os.path.exists(CopyMapFile) or \\r
+                                       (os.path.getmtime(MapFile) > os.path.getmtime(CopyMapFile)):\r
+                                    CopyLongFilePath(MapFile, CopyMapFile)\r
 \r
                     if not NoStrip:\r
                         FileBeforeStrip = os.path.join(OutputPath, ModuleName + '.efi')\r
-                        if not os.path.exists(FileBeforeStrip) or \\r
-                            (os.path.getmtime(File) > os.path.getmtime(FileBeforeStrip)):\r
-                            CopyLongFilePath(File, FileBeforeStrip)\r
+                        if IsMakefile:\r
+                            if GenFdsGlobalVariable.CopyList == []:\r
+                                GenFdsGlobalVariable.CopyList = [(File, FileBeforeStrip)]\r
+                            else:\r
+                                GenFdsGlobalVariable.CopyList.append((File, FileBeforeStrip))\r
+                        else:\r
+                            if not os.path.exists(FileBeforeStrip) or \\r
+                                (os.path.getmtime(File) > os.path.getmtime(FileBeforeStrip)):\r
+                                CopyLongFilePath(File, FileBeforeStrip)\r
                         StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')\r
                         GenFdsGlobalVariable.GenerateFirmwareImage(\r
-                                                StrippedFile,\r
-                                                [File],\r
-                                                Strip=True\r
-                                                )\r
+                                StrippedFile,\r
+                                [File],\r
+                                Strip=True,\r
+                                IsMakefile = IsMakefile\r
+                            )\r
                         File = StrippedFile\r
                     \r
                     """For TE Section call GenFw to generate TE image"""\r
@@ -262,17 +280,19 @@ class EfiSection (EfiSectionClassObject):
                     if SectionType == 'TE':\r
                         TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')\r
                         GenFdsGlobalVariable.GenerateFirmwareImage(\r
-                                                TeFile,\r
-                                                [File],\r
-                                                Type='te'\r
-                                                )\r
+                                TeFile,\r
+                                [File],\r
+                                Type='te',\r
+                                IsMakefile = IsMakefile\r
+                            )\r
                         File = TeFile\r
 \r
                     """Call GenSection"""\r
                     GenFdsGlobalVariable.GenerateSection(OutputFile,\r
-                                                         [File],\r
-                                                         Section.Section.SectionType.get (SectionType)\r
-                                                         )\r
+                                                        [File],\r
+                                                        Section.Section.SectionType.get (SectionType),\r
+                                                        IsMakefile=IsMakefile\r
+                                                        )\r
                     OutputFileList.append(OutputFile)\r
 \r
         return OutputFileList, Align\r