]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/GuidSection.py
BaseTools: Update Makefile to support FFS file generation
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / GuidSection.py
index f199dcd2ccc11ad6d2df5dd612f50f499ee435e7..ea737bb9a7ea5c251cc05d2f8197b50f622c783a 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process GUIDed section generation\r
 #\r
-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -54,7 +54,7 @@ class GuidSection(GuidSectionClassObject) :
     #   @param  Dict        dictionary contains macro and its value\r
     #   @retval tuple       (Generated file name, 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
         # Generate all section\r
         #\r
@@ -94,7 +94,7 @@ class GuidSection(GuidSectionClassObject) :
             elif isinstance(Sect, GuidSection):\r
                 Sect.FvAddr = self.FvAddr\r
                 Sect.FvParentAddr = self.FvParentAddr\r
-            ReturnSectList, align = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict)\r
+            ReturnSectList, align = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=IsMakefile)\r
             if isinstance(Sect, GuidSection):\r
                 if Sect.IncludeFvSection:\r
                     self.IncludeFvSection = Sect.IncludeFvSection\r
@@ -137,7 +137,7 @@ class GuidSection(GuidSectionClassObject) :
         #\r
         if self.NameGuid == None :\r
             GenFdsGlobalVariable.VerboseLogger("Use GenSection function Generate CRC32 Section")\r
-            GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Section.Section.SectionType[self.SectionType], InputAlign=SectAlign)\r
+            GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Section.Section.SectionType[self.SectionType], InputAlign=SectAlign, IsMakefile=IsMakefile)\r
             OutputFileList = []\r
             OutputFileList.append(OutputFile)\r
             return OutputFileList, self.Alignment\r
@@ -149,7 +149,7 @@ class GuidSection(GuidSectionClassObject) :
             #\r
             # Call GenSection with DUMMY section type.\r
             #\r
-            GenFdsGlobalVariable.GenerateSection(DummyFile, SectFile, InputAlign=SectAlign)\r
+            GenFdsGlobalVariable.GenerateSection(DummyFile, SectFile, InputAlign=SectAlign, IsMakefile=IsMakefile)\r
             #\r
             # Use external tool process the Output\r
             #\r
@@ -172,75 +172,99 @@ class GuidSection(GuidSectionClassObject) :
             CmdOption = '-e'\r
             if ExternalOption != None:\r
                 CmdOption = CmdOption + ' ' + ExternalOption\r
-            if self.ProcessRequired not in ("TRUE", "1") and self.IncludeFvSection and not FvAddrIsSet and self.FvParentAddr != None:\r
-                #FirstCall is only set for the encapsulated flash FV image without process required attribute.\r
-                FirstCall = True\r
-            #\r
-            # Call external tool\r
-            #\r
-            ReturnValue = [1]\r
-            if FirstCall:\r
-                #first try to call the guided tool with -z option and CmdOption for the no process required guided tool.\r
-                GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalTool, '-z' + ' ' + CmdOption, ReturnValue)\r
+            if not GenFdsGlobalVariable.EnableGenfdsMultiThread:\r
+                if self.ProcessRequired not in ("TRUE", "1") and self.IncludeFvSection and not FvAddrIsSet and self.FvParentAddr != None:\r
+                    #FirstCall is only set for the encapsulated flash FV image without process required attribute.\r
+                    FirstCall = True\r
+                #\r
+                # Call external tool\r
+                #\r
+                ReturnValue = [1]\r
+                if FirstCall:\r
+                    #first try to call the guided tool with -z option and CmdOption for the no process required guided tool.\r
+                    GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalTool, '-z' + ' ' + CmdOption, ReturnValue)\r
 \r
-            #\r
-            # when no call or first call failed, ReturnValue are not 1.\r
-            # Call the guided tool with CmdOption\r
-            #\r
-            if ReturnValue[0] != 0:\r
-                FirstCall = False\r
-                ReturnValue[0] = 0\r
-                GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalTool, CmdOption)\r
-            #\r
-            # There is external tool which does not follow standard rule which return nonzero if tool fails\r
-            # The output file has to be checked\r
-            #\r
-            if not os.path.exists(TempFile):\r
-                EdkLogger.error("GenFds", COMMAND_FAILURE, 'Fail to call %s, no output file was generated' % ExternalTool)\r
-\r
-            FileHandleIn = open(DummyFile, 'rb')\r
-            FileHandleIn.seek(0, 2)\r
-            InputFileSize = FileHandleIn.tell()\r
-\r
-            FileHandleOut = open(TempFile, 'rb')\r
-            FileHandleOut.seek(0, 2)\r
-            TempFileSize = FileHandleOut.tell()\r
-\r
-            Attribute = []\r
-            HeaderLength = None\r
-            if self.ExtraHeaderSize != -1:\r
-                HeaderLength = str(self.ExtraHeaderSize)\r
-\r
-            if self.ProcessRequired == "NONE" and HeaderLength == None:\r
-                if TempFileSize > InputFileSize:\r
-                    FileHandleIn.seek(0)\r
-                    BufferIn = FileHandleIn.read()\r
-                    FileHandleOut.seek(0)\r
-                    BufferOut = FileHandleOut.read()\r
-                    if BufferIn == BufferOut[TempFileSize - InputFileSize:]:\r
-                        HeaderLength = str(TempFileSize - InputFileSize)\r
-                #auto sec guided attribute with process required\r
-                if HeaderLength == None:\r
-                    Attribute.append('PROCESSING_REQUIRED')\r
-\r
-            FileHandleIn.close()\r
-            FileHandleOut.close()\r
-\r
-            if FirstCall and 'PROCESSING_REQUIRED' in Attribute:\r
-                # Guided data by -z option on first call is the process required data. Call the guided tool with the real option.\r
-                GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalTool, CmdOption)\r
+                #\r
+                # when no call or first call failed, ReturnValue are not 1.\r
+                # Call the guided tool with CmdOption\r
+                #\r
+                if ReturnValue[0] != 0:\r
+                    FirstCall = False\r
+                    ReturnValue[0] = 0\r
+                    GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalTool, CmdOption)\r
+                #\r
+                # There is external tool which does not follow standard rule which return nonzero if tool fails\r
+                # The output file has to be checked\r
+                #\r
+\r
+                if not os.path.exists(TempFile) :\r
+                    EdkLogger.error("GenFds", COMMAND_FAILURE, 'Fail to call %s, no output file was generated' % ExternalTool)\r
+\r
+                FileHandleIn = open(DummyFile, 'rb')\r
+                FileHandleIn.seek(0, 2)\r
+                InputFileSize = FileHandleIn.tell()\r
+\r
+                FileHandleOut = open(TempFile, 'rb')\r
+                FileHandleOut.seek(0, 2)\r
+                TempFileSize = FileHandleOut.tell()\r
+\r
+                Attribute = []\r
+                HeaderLength = None\r
+                if self.ExtraHeaderSize != -1:\r
+                    HeaderLength = str(self.ExtraHeaderSize)\r
+\r
+                if self.ProcessRequired == "NONE" and HeaderLength == None:\r
+                    if TempFileSize > InputFileSize:\r
+                        FileHandleIn.seek(0)\r
+                        BufferIn = FileHandleIn.read()\r
+                        FileHandleOut.seek(0)\r
+                        BufferOut = FileHandleOut.read()\r
+                        if BufferIn == BufferOut[TempFileSize - InputFileSize:]:\r
+                            HeaderLength = str(TempFileSize - InputFileSize)\r
+                    #auto sec guided attribute with process required\r
+                    if HeaderLength == None:\r
+                        Attribute.append('PROCESSING_REQUIRED')\r
+\r
+                FileHandleIn.close()\r
+                FileHandleOut.close()\r
+\r
+                if FirstCall and 'PROCESSING_REQUIRED' in Attribute:\r
+                    # Guided data by -z option on first call is the process required data. Call the guided tool with the real option.\r
+                    GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalTool, CmdOption)\r
+\r
+                #\r
+                # Call Gensection Add Section Header\r
+                #\r
+                if self.ProcessRequired in ("TRUE", "1"):\r
+                    if 'PROCESSING_REQUIRED' not in Attribute:\r
+                        Attribute.append('PROCESSING_REQUIRED')\r
+\r
+                if self.AuthStatusValid in ("TRUE", "1"):\r
+                    Attribute.append('AUTH_STATUS_VALID')\r
+                GenFdsGlobalVariable.GenerateSection(OutputFile, [TempFile], Section.Section.SectionType['GUIDED'],\r
+                                                     Guid=self.NameGuid, GuidAttr=Attribute, GuidHdrLen=HeaderLength)\r
+\r
+            else:\r
+                #add input file for GenSec get PROCESSING_REQUIRED\r
+                GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalTool, CmdOption, IsMakefile=IsMakefile)\r
+                Attribute = []\r
+                HeaderLength = None\r
+                if self.ExtraHeaderSize != -1:\r
+                    HeaderLength = str(self.ExtraHeaderSize)\r
+                if self.AuthStatusValid in ("TRUE", "1"):\r
+                    Attribute.append('AUTH_STATUS_VALID')\r
+                if self.ProcessRequired == "NONE" and HeaderLength == None:\r
+                    GenFdsGlobalVariable.GenerateSection(OutputFile, [TempFile], Section.Section.SectionType['GUIDED'],\r
+                                                         Guid=self.NameGuid, GuidAttr=Attribute,\r
+                                                         GuidHdrLen=HeaderLength, DummyFile=DummyFile, IsMakefile=IsMakefile)\r
+                else:\r
+                    if self.ProcessRequired in ("TRUE", "1"):\r
+                        if 'PROCESSING_REQUIRED' not in Attribute:\r
+                            Attribute.append('PROCESSING_REQUIRED')\r
+                    GenFdsGlobalVariable.GenerateSection(OutputFile, [TempFile], Section.Section.SectionType['GUIDED'],\r
+                                                         Guid=self.NameGuid, GuidAttr=Attribute,\r
+                                                         GuidHdrLen=HeaderLength, IsMakefile=IsMakefile)\r
 \r
-            #\r
-            # Call Gensection Add Section Header\r
-            #\r
-            if self.ProcessRequired in ("TRUE", "1"):\r
-                if 'PROCESSING_REQUIRED' not in Attribute:\r
-                    Attribute.append('PROCESSING_REQUIRED')\r
-\r
-            if self.AuthStatusValid in ("TRUE", "1"):\r
-                Attribute.append('AUTH_STATUS_VALID')\r
-            GenFdsGlobalVariable.GenerateSection(OutputFile, [TempFile], Section.Section.SectionType['GUIDED'],\r
-                                                 Guid=self.NameGuid, GuidAttr=Attribute, GuidHdrLen=HeaderLength)\r
             OutputFileList = []\r
             OutputFileList.append(OutputFile)\r
             if 'PROCESSING_REQUIRED' in Attribute:\r