]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Update Makefile to support FFS file generation
authorYonghong Zhu <yonghong.zhu@intel.com>
Wed, 22 Nov 2017 07:42:25 +0000 (15:42 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Tue, 5 Dec 2017 01:26:22 +0000 (09:26 +0800)
Update Makefile to support FFS file generation with new build option
--genfds-multi-thread.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
24 files changed:
BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/AutoGen/GenMake.py
BaseTools/Source/Python/Common/GlobalData.py
BaseTools/Source/Python/GenFds/AprioriSection.py
BaseTools/Source/Python/GenFds/CompressSection.py
BaseTools/Source/Python/GenFds/DataSection.py
BaseTools/Source/Python/GenFds/DepexSection.py
BaseTools/Source/Python/GenFds/EfiSection.py
BaseTools/Source/Python/GenFds/Fd.py
BaseTools/Source/Python/GenFds/FfsFileStatement.py
BaseTools/Source/Python/GenFds/FfsInfStatement.py
BaseTools/Source/Python/GenFds/Fv.py
BaseTools/Source/Python/GenFds/FvImageSection.py
BaseTools/Source/Python/GenFds/GenFds.py
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
BaseTools/Source/Python/GenFds/GuidSection.py
BaseTools/Source/Python/GenFds/OptRomFileStatement.py
BaseTools/Source/Python/GenFds/OptRomInfStatement.py
BaseTools/Source/Python/GenFds/OptionRom.py
BaseTools/Source/Python/GenFds/Region.py
BaseTools/Source/Python/GenFds/Section.py
BaseTools/Source/Python/GenFds/UiSection.py
BaseTools/Source/Python/GenFds/VerSection.py
BaseTools/Source/Python/build/build.py

index 008ad8ebc3ccdee3666dad91db942e9c4d8f5a44..1c4c3954797cb2b5438b12ba9d71caa92f0f7cc7 100644 (file)
@@ -1307,12 +1307,15 @@ class PlatformAutoGen(AutoGen):
     #   @param      CreateModuleMakeFile    Flag indicating if the makefile for\r
     #                                       modules will be created as well\r
     #\r
-    def CreateMakeFile(self, CreateModuleMakeFile=False):\r
+    def CreateMakeFile(self, CreateModuleMakeFile=False, FfsCommand = {}):\r
         if CreateModuleMakeFile:\r
             for ModuleFile in self.Platform.Modules:\r
                 Ma = ModuleAutoGen(self.Workspace, ModuleFile, self.BuildTarget,\r
                                    self.ToolChain, self.Arch, self.MetaFile)\r
-                Ma.CreateMakeFile(True)\r
+                if (ModuleFile.File, self.Arch) in FfsCommand:\r
+                    Ma.CreateMakeFile(True, FfsCommand[ModuleFile.File, self.Arch])\r
+                else:\r
+                    Ma.CreateMakeFile(True)\r
                 #Ma.CreateAsBuiltInf()\r
 \r
         # no need to create makefile for the platform more than once\r
@@ -2760,6 +2763,7 @@ class ModuleAutoGen(AutoGen):
 \r
         self._BuildDir        = None\r
         self._OutputDir       = None\r
+        self._FfsOutputDir    = None\r
         self._DebugDir        = None\r
         self._MakeFileDir     = None\r
 \r
@@ -2876,6 +2880,7 @@ class ModuleAutoGen(AutoGen):
             self._Macro["PLATFORM_RELATIVE_DIR" ] = self.PlatformInfo.SourceDir\r
             self._Macro["PLATFORM_DIR"          ] = mws.join(self.WorkspaceDir, self.PlatformInfo.SourceDir)\r
             self._Macro["PLATFORM_OUTPUT_DIR"   ] = self.PlatformInfo.OutputDir\r
+            self._Macro["FFS_OUTPUT_DIR"        ] = self.FfsOutputDir\r
         return self._Macro\r
 \r
     ## Return the module build data object\r
@@ -2966,6 +2971,15 @@ class ModuleAutoGen(AutoGen):
             CreateDirectory(self._OutputDir)\r
         return self._OutputDir\r
 \r
+    ## Return the directory to store ffs file\r
+    def _GetFfsOutputDir(self):\r
+        if self._FfsOutputDir == None:\r
+            if GlobalData.gFdfParser != None:\r
+                self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, "FV", "Ffs", self.Guid + self.Name)\r
+            else:\r
+                self._FfsOutputDir = ''\r
+        return self._FfsOutputDir\r
+\r
     ## Return the directory to store auto-gened source files of the mdoule\r
     def _GetDebugDir(self):\r
         if self._DebugDir == None:\r
@@ -4222,14 +4236,14 @@ class ModuleAutoGen(AutoGen):
     #   @param      CreateLibraryMakeFile   Flag indicating if or not the makefiles of\r
     #                                       dependent libraries will be created\r
     #\r
-    def CreateMakeFile(self, CreateLibraryMakeFile=True):\r
+    def CreateMakeFile(self, CreateLibraryMakeFile=True, GenFfsList = []):\r
         # Ignore generating makefile when it is a binary module\r
         if self.IsBinaryModule:\r
             return\r
 \r
         if self.IsMakeFileCreated:\r
             return\r
-\r
+        self.GenFfsList = GenFfsList\r
         if not self.IsLibrary and CreateLibraryMakeFile:\r
             for LibraryAutoGen in self.LibraryAutoGenList:\r
                 LibraryAutoGen.CreateMakeFile()\r
@@ -4457,6 +4471,7 @@ class ModuleAutoGen(AutoGen):
     IsBinaryModule  = property(_IsBinaryModule)\r
     BuildDir        = property(_GetBuildDir)\r
     OutputDir       = property(_GetOutputDir)\r
+    FfsOutputDir    = property(_GetFfsOutputDir)\r
     DebugDir        = property(_GetDebugDir)\r
     MakeFileDir     = property(_GetMakeFileDir)\r
     CustomMakefile  = property(_GetCustomMakefile)\r
index 942eb44cc2eecaab3656a708578f12d7587d9d74..2abfdb3ac471dc243e0dbe94a0aee124077cb38d 100644 (file)
@@ -143,6 +143,11 @@ class BuildFile(object):
         "nmake" :   'if exist %(dir)s $(RD) %(dir)s',\r
         "gmake" :   "$(RD) %(dir)s"\r
     }\r
+    ## cp if exist\r
+    _CP_TEMPLATE_ = {\r
+        "nmake" :   'if exist %(Src)s $(CP) %(Src)s %(Dst)s',\r
+        "gmake" :   "test -f %(Src)s && $(CP) %(Src)s %(Dst)s"\r
+    }\r
 \r
     _CD_TEMPLATE_ = {\r
         "nmake" :   'if exist %(dir)s cd %(dir)s',\r
@@ -211,6 +216,8 @@ class BuildFile(object):
             for MacroName in MacroDefinitions:\r
                 MacroValue = MacroDefinitions[MacroName]\r
                 MacroValueLength = len(MacroValue)\r
+                if MacroValueLength == 0:\r
+                    continue\r
                 if MacroValueLength <= PathLength and Path.startswith(MacroValue):\r
                     Path = "$(%s)%s" % (MacroName, Path[MacroValueLength:])\r
                     break\r
@@ -250,6 +257,7 @@ BASE_NAME = $(MODULE_NAME)
 MODULE_RELATIVE_DIR = ${module_relative_directory}\r
 PACKAGE_RELATIVE_DIR = ${package_relative_directory}\r
 MODULE_DIR = ${module_dir}\r
+FFS_OUTPUT_DIR = ${ffs_output_directory}\r
 \r
 MODULE_ENTRY_POINT = ${module_entry_point}\r
 ARCH_ENTRY_POINT = ${arch_entry_point}\r
@@ -441,6 +449,10 @@ cleanlib:
         self.Macros["BIN_DIR"         ] = self._AutoGenObject.Macros["BIN_DIR"]\r
         self.Macros["BUILD_DIR"       ] = self._AutoGenObject.Macros["BUILD_DIR"]\r
         self.Macros["WORKSPACE"       ] = self._AutoGenObject.Macros["WORKSPACE"]\r
+        self.Macros["FFS_OUTPUT_DIR"  ] = self._AutoGenObject.Macros["FFS_OUTPUT_DIR"]\r
+        self.GenFfsList                 = ModuleAutoGen.GenFfsList\r
+        self.MacroList = ['FFS_OUTPUT_DIR', 'MODULE_GUID', 'OUTPUT_DIR']\r
+        self.FfsOutputFileList = []\r
 \r
     # Compose a dict object containing information used to do replacement in template\r
     def _CreateTemplateDict(self):\r
@@ -555,6 +567,7 @@ cleanlib:
                             ExtraData="[%s]" % str(self._AutoGenObject))\r
 \r
         self.ProcessBuildTargetList()\r
+        self.ParserGenerateFfsCmd()\r
 \r
         # Generate macros used to represent input files\r
         FileMacroList = [] # macro name = file list\r
@@ -627,6 +640,7 @@ cleanlib:
             "platform_version"          : self.PlatformInfo.Version,\r
             "platform_relative_directory": self.PlatformInfo.SourceDir,\r
             "platform_output_directory" : self.PlatformInfo.OutputDir,\r
+            "ffs_output_directory"      : self._AutoGenObject.Macros["FFS_OUTPUT_DIR"],\r
             "platform_dir"              : self._AutoGenObject.Macros["PLATFORM_DIR"],\r
 \r
             "module_name"               : self._AutoGenObject.Name,\r
@@ -673,6 +687,79 @@ cleanlib:
 \r
         return MakefileTemplateDict\r
 \r
+    def ParserGenerateFfsCmd(self):\r
+        #Add Ffs cmd to self.BuildTargetList\r
+        OutputFile = ''\r
+        DepsFileList = []\r
+\r
+        for Cmd in self.GenFfsList:\r
+            if Cmd[2]:\r
+                for CopyCmd in Cmd[2]:\r
+                    Src, Dst = CopyCmd\r
+                    Src = self.ReplaceMacro(Src)\r
+                    Dst = self.ReplaceMacro(Dst)\r
+                    if Dst not in self.ResultFileList:\r
+                        self.ResultFileList.append('%s' % Dst)\r
+                    if '%s :' %(Dst) not in self.BuildTargetList:\r
+                        self.BuildTargetList.append("%s :" %(Dst))\r
+                        self.BuildTargetList.append('\t' + self._CP_TEMPLATE_[self._FileType] %{'Src': Src, 'Dst': Dst})\r
+\r
+            FfsCmdList = Cmd[0]\r
+            for index, Str in enumerate(FfsCmdList):\r
+                if '-o' == Str:\r
+                    OutputFile = FfsCmdList[index + 1]\r
+                if '-i' == Str:\r
+                    if DepsFileList == []:\r
+                        DepsFileList = [FfsCmdList[index + 1]]\r
+                    else:\r
+                        DepsFileList.append(FfsCmdList[index + 1])\r
+            DepsFileString = ' '.join(DepsFileList).strip()\r
+            if DepsFileString == '':\r
+                continue\r
+            OutputFile = self.ReplaceMacro(OutputFile)\r
+            self.ResultFileList.append('%s' % OutputFile)\r
+            DepsFileString = self.ReplaceMacro(DepsFileString)\r
+            self.BuildTargetList.append('%s : %s' % (OutputFile, DepsFileString))\r
+            CmdString = ' '.join(FfsCmdList).strip()\r
+            CmdString = self.ReplaceMacro(CmdString)\r
+            self.BuildTargetList.append('\t%s' % CmdString)\r
+\r
+            self.ParseSecCmd(DepsFileList, Cmd[1])\r
+            for SecOutputFile, SecDepsFile, SecCmd in self.FfsOutputFileList :\r
+                self.BuildTargetList.append('%s : %s' % (self.ReplaceMacro(SecOutputFile), self.ReplaceMacro(SecDepsFile)))\r
+                self.BuildTargetList.append('\t%s' % self.ReplaceMacro(SecCmd))\r
+            self.FfsOutputFileList = []\r
+\r
+    def ParseSecCmd(self, OutputFileList, CmdTuple):\r
+        for OutputFile in OutputFileList:\r
+            for SecCmdStr in CmdTuple:\r
+                SecDepsFileList = []\r
+                SecCmdList = SecCmdStr.split()\r
+                CmdName = SecCmdList[0]\r
+                for index, CmdItem in enumerate(SecCmdList):\r
+                    if '-o' == CmdItem and OutputFile == SecCmdList[index + 1]:\r
+                        index = index + 1\r
+                        while index + 1 < len(SecCmdList):\r
+                            if not SecCmdList[index+1].startswith('-'):\r
+                                SecDepsFileList.append(SecCmdList[index + 1])\r
+                            index = index + 1\r
+                        if CmdName == 'Trim':\r
+                            SecDepsFileList.append(os.path.join('$(DEBUG_DIR)', os.path.basename(OutputFile).replace('offset', 'efi')))\r
+                        if OutputFile.endswith('.ui') or OutputFile.endswith('.ver'):\r
+                            SecDepsFileList.append(os.path.join('$(MODULE_DIR)','$(MODULE_FILE)'))\r
+                        self.FfsOutputFileList.append((OutputFile, ' '.join(SecDepsFileList), SecCmdStr))\r
+                        if len(SecDepsFileList) > 0:\r
+                            self.ParseSecCmd(SecDepsFileList, CmdTuple)\r
+                        break\r
+                    else:\r
+                        continue\r
+\r
+    def ReplaceMacro(self, str):\r
+        for Macro in self.MacroList:\r
+            if self._AutoGenObject.Macros[Macro] and self._AutoGenObject.Macros[Macro] in str:\r
+                str = str.replace(self._AutoGenObject.Macros[Macro], '$(' + Macro + ')')\r
+        return str\r
+\r
     def CommandExceedLimit(self):\r
         FlagDict = {\r
                     'CC'    :  { 'Macro' : '$(CC_FLAGS)',    'Value' : False},\r
@@ -1453,7 +1540,8 @@ class TopLevelMakefile(BuildFile):
 \r
         if GlobalData.gCaseInsensitive:\r
             ExtraOption += " -c"\r
-\r
+        if GlobalData.gEnableGenfdsMultiThread:\r
+            ExtraOption += " --genfds-multi-thread"\r
         if GlobalData.gIgnoreSource:\r
             ExtraOption += " --ignore-sources"\r
 \r
index e348e9af2d58ecd8b74ac278fd4335ba2eeb1776..8b7562daa130ccfc71b3820b4f691b79a6e195c0 100644 (file)
@@ -95,3 +95,4 @@ gBinCacheSource = None
 gPlatformHash = None\r
 gPackageHash = {}\r
 gModuleHash = {}\r
+gEnableGenfdsMultiThread = False\r
index a2306d062d2dea61eb1564baa3b972e81ced42cc..70e2e5a3baf23e86b8b9e11af8f3913744df450a 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process APRIORI file data and generate PEI/DXE APRIORI file\r
 #\r
-#  Copyright (c) 2007 - 2014, 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
@@ -47,7 +47,7 @@ class AprioriSection (AprioriSectionClassObject):
     #   @param  Dict        dictionary contains macro and its value\r
     #   @retval string      Generated file name\r
     #\r
-    def GenFfs (self, FvName, Dict = {}):\r
+    def GenFfs (self, FvName, Dict = {}, IsMakefile = False):\r
         DXE_GUID = "FC510EE7-FFDC-11D4-BD41-0080C73C8881"\r
         PEI_GUID = "1B45CC0A-156A-428A-AF62-49864DA0E6E6"\r
         Buffer = StringIO.StringIO('')\r
@@ -66,6 +66,7 @@ class AprioriSection (AprioriSectionClassObject):
                                     AprioriFileGuid + FvName + '.Ffs')\r
 \r
         Dict.update(self.DefineVarDict)\r
+        InfFileName = None\r
         for FfsObj in self.FfsList :\r
             Guid = ""\r
             if isinstance(FfsObj, FfsFileStatement.FileStatement):\r
@@ -110,9 +111,14 @@ class AprioriSection (AprioriSectionClassObject):
 \r
         RawSectionFileName = os.path.join( OutputAprFilePath, \\r
                                        AprioriFileGuid + FvName + '.raw' )\r
-        GenFdsGlobalVariable.GenerateSection(RawSectionFileName, [OutputAprFileName], 'EFI_SECTION_RAW')\r
+        MakefilePath = None\r
+        if IsMakefile:\r
+            if not InfFileName:\r
+                return None\r
+            MakefilePath = InfFileName, Arch\r
+        GenFdsGlobalVariable.GenerateSection(RawSectionFileName, [OutputAprFileName], 'EFI_SECTION_RAW', IsMakefile=IsMakefile)\r
         GenFdsGlobalVariable.GenerateFfs(AprFfsFileName, [RawSectionFileName],\r
-                                         'EFI_FV_FILETYPE_FREEFORM', AprioriFileGuid)\r
+                                        'EFI_FV_FILETYPE_FREEFORM', AprioriFileGuid, MakefilePath=MakefilePath)\r
 \r
         return AprFfsFileName\r
 \r
index fac58d14f82b0fc58e1aa6bb77f699acd43c5128..64ad275d832ed0c30eb6d784dad5cc53a60a7ffa 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process compress section generation\r
 #\r
-#  Copyright (c) 2007 - 2014, 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
@@ -53,7 +53,7 @@ class CompressSection (CompressSectionClassObject) :
     #   @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
         if FfsInf != None:\r
             self.CompType = FfsInf.__ExtendMacro__(self.CompType)\r
@@ -64,10 +64,10 @@ class CompressSection (CompressSectionClassObject) :
         for Sect in self.SectionList:\r
             Index = Index + 1\r
             SecIndex = '%s.%d' %(SecNum, Index)\r
-            ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict)\r
+            ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=IsMakefile)\r
             if ReturnSectList != []:\r
                 for FileData in ReturnSectList:\r
-                   SectFiles += (FileData,)\r
+                    SectFiles += (FileData,)\r
 \r
 \r
         OutputFile = OutputPath + \\r
@@ -79,7 +79,7 @@ class CompressSection (CompressSectionClassObject) :
         OutputFile = os.path.normpath(OutputFile)\r
 \r
         GenFdsGlobalVariable.GenerateSection(OutputFile, SectFiles, Section.Section.SectionType['COMPRESS'],\r
-                                             CompressionType=self.CompTypeDict[self.CompType])\r
+                                             CompressionType=self.CompTypeDict[self.CompType], IsMakefile=IsMakefile)\r
         OutputFileList = []\r
         OutputFileList.append(OutputFile)\r
         return OutputFileList, self.Alignment\r
index 78c0af4db1ab2c4e9e8a6782f5831ad4ef1e1a78..2d2975f75c0f5ae0ba8509a9cf6e836fcc9a6fdf 100644 (file)
@@ -48,7 +48,7 @@ class DataSection (DataSectionClassObject):
     #   @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, FfsFile = None, Dict = {}):\r
+    def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}, IsMakefile = False):\r
         #\r
         # Prepare the parameter of GenSection\r
         #\r
@@ -69,10 +69,16 @@ class DataSection (DataSectionClassObject):
         Filename = GenFdsGlobalVariable.MacroExtend(self.SectFileName)\r
         if Filename[(len(Filename)-4):] == '.efi':\r
             MapFile = Filename.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 (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 (os.path.getmtime(MapFile) > os.path.getmtime(CopyMapFile)):\r
+                        CopyLongFilePath(MapFile, CopyMapFile)\r
 \r
         #Get PE Section alignment when align is set to AUTO\r
         if self.Alignment == 'Auto' and self.SecType in ('TE', 'PE32'):\r
@@ -96,24 +102,25 @@ class DataSection (DataSectionClassObject):
                 CopyLongFilePath(self.SectFileName, FileBeforeStrip)\r
             StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')\r
             GenFdsGlobalVariable.GenerateFirmwareImage(\r
-                                    StrippedFile,\r
-                                    [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)],\r
-                                    Strip=True\r
-                                    )\r
+                    StrippedFile,\r
+                    [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)],\r
+                    Strip=True,\r
+                    IsMakefile = IsMakefile\r
+                )\r
             self.SectFileName = StrippedFile\r
 \r
         if self.SecType == 'TE':\r
             TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')\r
             GenFdsGlobalVariable.GenerateFirmwareImage(\r
-                                    TeFile,\r
-                                    [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)],\r
-                                    Type='te'\r
-                                    )\r
+                    TeFile,\r
+                    [GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)],\r
+                    Type='te',\r
+                    IsMakefile = IsMakefile\r
+                )\r
             self.SectFileName = TeFile\r
 \r
         OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get(self.SecType))\r
         OutputFile = os.path.normpath(OutputFile)\r
-\r
-        GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileName], Section.Section.SectionType.get(self.SecType))\r
+        GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileName], Section.Section.SectionType.get(self.SecType), IsMakefile = IsMakefile)\r
         FileList = [OutputFile]\r
         return FileList, self.Alignment\r
index 8f78c0fad474fb38829160b94cd3331c4127dea1..1992d2abd8070d5d7676a42e59a0843a0e9a7621 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process depex section generation\r
 #\r
-#  Copyright (c) 2007 - 2014, 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
@@ -76,7 +76,7 @@ class DepexSection (DepexSectionClassObject):
     #   @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, FfsFile = None, Dict = {}):\r
+    def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}, IsMakefile = False):\r
         \r
         if self.ExpressionProcessed == False:\r
             self.Expression = self.Expression.replace("\n", " ").replace("\r", " ")\r
@@ -119,6 +119,6 @@ class DepexSection (DepexSectionClassObject):
         OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.dpx')\r
         OutputFile = os.path.normpath(OutputFile)\r
 \r
-        GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType))\r
+        GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType), IsMakefile=IsMakefile)\r
         FileList = [OutputFile]\r
         return FileList, self.Alignment\r
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
index f330a7ed55dc0536ea7188835148395f1bb88098..f735d3b5b015bc679c6b0fc8a3dfed895d1870f9 100644 (file)
@@ -45,7 +45,7 @@ class FD(FDClassObject):
     #\r
     #   @retval string      Generated FD file name\r
     #\r
-    def GenFd (self):\r
+    def GenFd (self, Flag = False):\r
         if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict.keys():\r
             return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd']\r
 \r
@@ -53,7 +53,8 @@ class FD(FDClassObject):
         # Print Information\r
         #\r
         FdFileName = os.path.join(GenFdsGlobalVariable.FvDir, self.FdUiName + '.fd')\r
-        GenFdsGlobalVariable.InfLogger("Fd File Name:%s (%s)" %(self.FdUiName, FdFileName))\r
+        if not Flag:\r
+            GenFdsGlobalVariable.InfLogger("\nFd File Name:%s (%s)" %(self.FdUiName, FdFileName))\r
 \r
         Offset = 0x00\r
         for item in self.BlockSizeList:\r
@@ -85,11 +86,13 @@ class FD(FDClassObject):
                 elif RegionObj.Offset <= PreviousRegionStart or (RegionObj.Offset >=PreviousRegionStart and RegionObj.Offset < PreviousRegionStart + PreviousRegionSize):\r
                     pass\r
                 elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSize:\r
-                    GenFdsGlobalVariable.InfLogger('Padding region starting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize)))\r
+                    if not Flag:\r
+                        GenFdsGlobalVariable.InfLogger('Padding region starting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize)))\r
                     PadRegion = Region.Region()\r
                     PadRegion.Offset = PreviousRegionStart + PreviousRegionSize\r
                     PadRegion.Size = RegionObj.Offset - PadRegion.Offset\r
-                    PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)\r
+                    if not Flag:\r
+                        PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)\r
                 PreviousRegionStart = RegionObj.Offset\r
                 PreviousRegionSize = RegionObj.Size\r
                 #\r
@@ -113,11 +116,13 @@ class FD(FDClassObject):
                                 'Region offset 0x%X overlaps with Region starting from 0x%X, size 0x%X' \\r
                                 % (RegionObj.Offset, PreviousRegionStart, PreviousRegionSize))\r
             elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSize:\r
-                GenFdsGlobalVariable.InfLogger('Padding region starting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize)))\r
+                if not Flag:\r
+                    GenFdsGlobalVariable.InfLogger('Padding region starting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize)))\r
                 PadRegion = Region.Region()\r
                 PadRegion.Offset = PreviousRegionStart + PreviousRegionSize\r
                 PadRegion.Size = RegionObj.Offset - PadRegion.Offset\r
-                PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)\r
+                if not Flag:\r
+                    PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)\r
             PreviousRegionStart = RegionObj.Offset\r
             PreviousRegionSize = RegionObj.Size\r
             #\r
@@ -131,13 +136,14 @@ class FD(FDClassObject):
             # Call each region's AddToBuffer function\r
             #\r
             GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')\r
-            RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict)\r
+            RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict,Flag=Flag)\r
         #\r
         # Write the buffer contents to Fd file\r
         #\r
         GenFdsGlobalVariable.VerboseLogger('Write the buffer contents to Fd file')\r
-        SaveFileOnChange(FdFileName, FdBuffer.getvalue())\r
-        FdBuffer.close();\r
+        if not Flag:\r
+            SaveFileOnChange(FdFileName, FdBuffer.getvalue())\r
+        FdBuffer.close()\r
         GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] = FdFileName\r
         return FdFileName\r
 \r
index f76ddf4d95a4fe2d0052cf8acab51c7c73e035c2..edb131266d98d1b6ac5e41872809a3293bb7f514 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process FFS generation from FILE statement\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
@@ -57,7 +57,7 @@ class FileStatement (FileStatementClassObject) :
     #   @param  FvParentAddr Parent Fv base address\r
     #   @retval string       Generated FFS file name\r
     #\r
-    def GenFfs(self, Dict = {}, FvChildAddr=[], FvParentAddr=None):\r
+    def GenFfs(self, Dict = {}, FvChildAddr=[], FvParentAddr=None, IsMakefile=False):\r
         \r
         if self.NameGuid != None and self.NameGuid.startswith('PCD('):\r
             PcdValue = GenFdsGlobalVariable.GetPcdValue(self.NameGuid)\r
index 958cecfad63e847b4ecf58acb45c946505ec3ee0..4b4781755dd41fb0199199a8e73109f5a93b0bde 100644 (file)
@@ -44,6 +44,8 @@ from PatchPcdValue.PatchPcdValue import PatchBinaryFile
 from Common.LongFilePathSupport import CopyLongFilePath\r
 from Common.LongFilePathSupport import OpenLongFilePath as open\r
 import Common.GlobalData as GlobalData\r
+from DepexSection import DepexSection\r
+from Common.Misc import SaveFileOnChange\r
 \r
 ## generate FFS from INF\r
 #\r
@@ -72,6 +74,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
         self.OverrideGuid = None\r
         self.PatchedBinFile = ''\r
         self.MacroDict = {}\r
+        self.Depex = False\r
 \r
     ## GetFinalTargetSuffixMap() method\r
     #\r
@@ -320,6 +323,11 @@ class FfsInfStatement(FfsInfStatementClassObject):
         self.InfModule = Inf\r
         self.PcdIsDriver = Inf.PcdIsDriver\r
         self.IsBinaryModule = Inf.IsBinaryModule\r
+        Inf._GetDepex()\r
+        Inf._GetDepexExpression()\r
+        if len(Inf._Depex.data) > 0 and len(Inf._DepexExpression.data) > 0:\r
+            self.Depex = True\r
+\r
         GenFdsGlobalVariable.VerboseLogger("BaseName : %s" % self.BaseName)\r
         GenFdsGlobalVariable.VerboseLogger("ModuleGuid : %s" % self.ModuleGuid)\r
         GenFdsGlobalVariable.VerboseLogger("ModuleType : %s" % self.ModuleType)\r
@@ -335,7 +343,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
         if not os.path.exists(self.OutputPath) :\r
             os.makedirs(self.OutputPath)\r
 \r
-        self.EfiOutputPath = self.__GetEFIOutPutPath__()\r
+        self.EfiOutputPath, self.EfiDebugPath = self.__GetEFIOutPutPath__()\r
         GenFdsGlobalVariable.VerboseLogger( "ModuelEFIPath: " + self.EfiOutputPath)\r
 \r
     ## PatchEfiFile\r
@@ -414,12 +422,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
     #   @param  FvParentAddr Parent Fv base address\r
     #   @retval string       Generated FFS file name\r
     #\r
-    def GenFfs(self, Dict = {}, FvChildAddr = [], FvParentAddr=None):\r
+    def GenFfs(self, Dict = {}, FvChildAddr = [], FvParentAddr=None, IsMakefile=False):\r
         #\r
         # Parse Inf file get Module related information\r
         #\r
 \r
         self.__InfParse__(Dict)\r
+        Arch = self.GetCurrentArch()\r
         SrcFile = mws.join( GenFdsGlobalVariable.WorkSpaceDir , self.InfFileName);\r
         DestFile = os.path.join( self.OutputPath, self.ModuleGuid + '.ffs')\r
         \r
@@ -451,7 +460,9 @@ class FfsInfStatement(FfsInfStatementClassObject):
         if len(self.BinFileList) > 0:\r
             if self.Rule == None or self.Rule == "":\r
                 self.Rule = "BINARY"\r
-                \r
+\r
+        if not IsMakefile and GenFdsGlobalVariable.EnableGenfdsMultiThread and self.Rule != 'BINARY':\r
+            IsMakefile = True\r
         #\r
         # Get the rule of how to generate Ffs file\r
         #\r
@@ -472,17 +483,19 @@ class FfsInfStatement(FfsInfStatementClassObject):
         #\r
         # For the rule only has simpleFile\r
         #\r
+        MakefilePath = None\r
+        if IsMakefile:\r
+            MakefilePath = self.InfFileName, Arch\r
         if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) :\r
-            SectionOutputList = self.__GenSimpleFileSection__(Rule)\r
-            FfsOutput = self.__GenSimpleFileFfs__(Rule, SectionOutputList)\r
+            SectionOutputList = self.__GenSimpleFileSection__(Rule, IsMakefile=IsMakefile)\r
+            FfsOutput = self.__GenSimpleFileFfs__(Rule, SectionOutputList, MakefilePath=MakefilePath)\r
             return FfsOutput\r
         #\r
         # For Rule has ComplexFile\r
         #\r
         elif isinstance(Rule, RuleComplexFile.RuleComplexFile):\r
-            InputSectList, InputSectAlignments = self.__GenComplexFileSection__(Rule, FvChildAddr, FvParentAddr)\r
-            FfsOutput = self.__GenComplexFileFfs__(Rule, InputSectList, InputSectAlignments)\r
-\r
+            InputSectList, InputSectAlignments = self.__GenComplexFileSection__(Rule, FvChildAddr, FvParentAddr, IsMakefile=IsMakefile)\r
+            FfsOutput = self.__GenComplexFileFfs__(Rule, InputSectList, InputSectAlignments, MakefilePath=MakefilePath)\r
             return FfsOutput\r
 \r
     ## __ExtendMacro__() method\r
@@ -651,6 +664,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
     def __GetEFIOutPutPath__(self):\r
         Arch = ''\r
         OutputPath = ''\r
+        DebugPath = ''\r
         (ModulePath, FileName) = os.path.split(self.InfFileName)\r
         Index = FileName.rfind('.')\r
         FileName = FileName[0:Index]\r
@@ -666,8 +680,15 @@ class FfsInfStatement(FfsInfStatementClassObject):
                                   FileName,\r
                                   'OUTPUT'\r
                                   )\r
+        DebugPath = os.path.join(GenFdsGlobalVariable.OutputDirDict[Arch],\r
+                                  Arch ,\r
+                                  ModulePath,\r
+                                  FileName,\r
+                                  'DEBUG'\r
+                                  )\r
         OutputPath = os.path.realpath(OutputPath)\r
-        return OutputPath\r
+        DebugPath = os.path.realpath(DebugPath)\r
+        return OutputPath, DebugPath\r
 \r
     ## __GenSimpleFileSection__() method\r
     #\r
@@ -677,7 +698,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
     #   @param  Rule        The rule object used to generate section\r
     #   @retval string      File name of the generated section file\r
     #\r
-    def __GenSimpleFileSection__(self, Rule):\r
+    def __GenSimpleFileSection__(self, Rule, IsMakefile = False):\r
         #\r
         # Prepare the parameter of GenSection\r
         #\r
@@ -743,22 +764,23 @@ class FfsInfStatement(FfsInfStatementClassObject):
                         CopyLongFilePath(File, FileBeforeStrip)\r
                     StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')\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
                 if SectionType == 'TE':\r
                     TeFile = os.path.join( self.OutputPath, self.ModuleGuid + '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
-                GenFdsGlobalVariable.GenerateSection(OutputFile, [File], Section.Section.SectionType[SectionType])\r
+                GenFdsGlobalVariable.GenerateSection(OutputFile, [File], Section.Section.SectionType[SectionType], IsMakefile=IsMakefile)\r
                 OutputFileList.append(OutputFile)\r
         else:\r
             SecNum = '%d' %Index\r
@@ -785,22 +807,23 @@ class FfsInfStatement(FfsInfStatementClassObject):
 \r
                 StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')\r
                 GenFdsGlobalVariable.GenerateFirmwareImage(\r
-                                        StrippedFile,\r
-                                        [GenSecInputFile],\r
-                                        Strip=True\r
-                                        )\r
+                        StrippedFile,\r
+                        [GenSecInputFile],\r
+                        Strip=True,\r
+                        IsMakefile=IsMakefile\r
+                    )\r
                 GenSecInputFile = StrippedFile\r
 \r
             if SectionType == 'TE':\r
                 TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')\r
                 GenFdsGlobalVariable.GenerateFirmwareImage(\r
-                                        TeFile,\r
-                                        [GenSecInputFile],\r
-                                        Type='te'\r
-                                        )\r
+                        TeFile,\r
+                        [GenSecInputFile],\r
+                        Type='te',\r
+                        IsMakefile=IsMakefile\r
+                    )\r
                 GenSecInputFile = TeFile\r
-\r
-            GenFdsGlobalVariable.GenerateSection(OutputFile, [GenSecInputFile], Section.Section.SectionType[SectionType])\r
+            GenFdsGlobalVariable.GenerateSection(OutputFile, [GenSecInputFile], Section.Section.SectionType[SectionType], IsMakefile=IsMakefile)\r
             OutputFileList.append(OutputFile)\r
 \r
         return OutputFileList\r
@@ -814,7 +837,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
     #   @param  InputFileList        The output file list from GenSection\r
     #   @retval string      Generated FFS file name\r
     #\r
-    def __GenSimpleFileFfs__(self, Rule, InputFileList):\r
+    def __GenSimpleFileFfs__(self, Rule, InputFileList, MakefilePath = None):\r
         FfsOutput = self.OutputPath                     + \\r
                     os.sep                              + \\r
                     self.__ExtendMacro__(Rule.NameGuid) + \\r
@@ -840,12 +863,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
                             % (Rule.NameGuid))\r
             self.ModuleGuid = RegistryGuidStr\r
 \r
-        GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputSection,\r
-                                         Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType],\r
-                                         self.ModuleGuid, Fixed=Rule.Fixed,\r
-                                         CheckSum=Rule.CheckSum, Align=Rule.Alignment,\r
-                                         SectionAlign=SectionAlignments\r
-                                        )\r
+            GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputSection,\r
+                                             Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType],\r
+                                             self.ModuleGuid, Fixed=Rule.Fixed,\r
+                                             CheckSum=Rule.CheckSum, Align=Rule.Alignment,\r
+                                             SectionAlign=SectionAlignments,\r
+                                             MakefilePath=MakefilePath\r
+                                             )\r
         return FfsOutput\r
 \r
     ## __GenComplexFileSection__() method\r
@@ -858,14 +882,14 @@ class FfsInfStatement(FfsInfStatementClassObject):
     #   @param  FvParentAddr Parent Fv base address\r
     #   @retval string       File name of the generated section file\r
     #\r
-    def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr):\r
+    def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr, IsMakefile = False):\r
         if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):\r
             if Rule.KeepReloc != None:\r
                 self.KeepRelocFromRule = Rule.KeepReloc\r
         SectFiles = []\r
         SectAlignments = []\r
         Index = 1\r
-        HasGneratedFlag = False\r
+        HasGeneratedFlag = False\r
         if self.PcdIsDriver == 'PEI_PCD_DRIVER':\r
             if self.IsBinaryModule:\r
                 PcdExDbFileName = os.path.join(GenFdsGlobalVariable.FvDir, "PEIPcdDataBase.raw")\r
@@ -875,6 +899,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
             GenFdsGlobalVariable.GenerateSection(PcdExDbSecName,\r
                                                  [PcdExDbFileName],\r
                                                  "EFI_SECTION_RAW",\r
+                                                 IsMakefile = IsMakefile\r
                                                  )\r
             SectFiles.append(PcdExDbSecName)\r
             SectAlignments.append(None)\r
@@ -885,9 +910,10 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 PcdExDbFileName = os.path.join(self.EfiOutputPath, "DXEPcdDataBase.raw")\r
             PcdExDbSecName = os.path.join(self.OutputPath, "DXEPcdDataBaseSec.raw")\r
             GenFdsGlobalVariable.GenerateSection(PcdExDbSecName,\r
-                                                 [PcdExDbFileName],\r
-                                                 "EFI_SECTION_RAW",\r
-                                                 )\r
+                                                [PcdExDbFileName],\r
+                                                "EFI_SECTION_RAW",\r
+                                                IsMakefile = IsMakefile\r
+                                                )\r
             SectFiles.append(PcdExDbSecName)\r
             SectAlignments.append(None)\r
         for Sect in Rule.SectionList:\r
@@ -917,11 +943,11 @@ class FfsInfStatement(FfsInfStatementClassObject):
                 Sect.FvParentAddr = FvParentAddr\r
             \r
             if Rule.KeyStringList != []:\r
-                SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, Rule.KeyStringList, self)\r
+                SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, Rule.KeyStringList, self, IsMakefile = IsMakefile)\r
             else :\r
-                SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, self.KeyStringList, self)\r
+                SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, self.KeyStringList, self, IsMakefile = IsMakefile)\r
             \r
-            if not HasGneratedFlag:\r
+            if not HasGeneratedFlag:\r
                 UniVfrOffsetFileSection = ""    \r
                 ModuleFileName = mws.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName)\r
                 InfData = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(ModuleFileName), self.CurrentArch]\r
@@ -944,27 +970,40 @@ class FfsInfStatement(FfsInfStatementClassObject):
                     \r
                 \r
                 if len(VfrUniBaseName) > 0:\r
-                    VfrUniOffsetList = self.__GetBuildOutputMapFileVfrUniInfo(VfrUniBaseName)\r
-                    #\r
-                    # Generate the Raw data of raw section\r
-                    #\r
-                    if VfrUniOffsetList:\r
-                        os.path.join( self.OutputPath, self.BaseName + '.offset')\r
-                        UniVfrOffsetFileName    =  os.path.join( self.OutputPath, self.BaseName + '.offset')\r
-                        UniVfrOffsetFileSection =  os.path.join( self.OutputPath, self.BaseName + 'Offset' + '.raw')\r
-\r
-                        self.__GenUniVfrOffsetFile (VfrUniOffsetList, UniVfrOffsetFileName)\r
-\r
-                        UniVfrOffsetFileNameList = []\r
-                        UniVfrOffsetFileNameList.append(UniVfrOffsetFileName)\r
-                        """Call GenSection"""\r
-                        GenFdsGlobalVariable.GenerateSection(UniVfrOffsetFileSection,\r
-                                                             UniVfrOffsetFileNameList,\r
-                                                             "EFI_SECTION_RAW"\r
-                                                             )\r
-                        os.remove(UniVfrOffsetFileName)\r
+                    if IsMakefile:\r
+                        if InfData.BuildType != 'UEFI_HII':\r
+                            UniVfrOffsetFileName = os.path.join(self.OutputPath, self.BaseName + '.offset')\r
+                            UniVfrOffsetFileSection = os.path.join(self.OutputPath, self.BaseName + 'Offset' + '.raw')\r
+                            UniVfrOffsetFileNameList = []\r
+                            UniVfrOffsetFileNameList.append(UniVfrOffsetFileName)\r
+                            TrimCmd = "Trim --Vfr-Uni-Offset -o %s --ModuleName=%s --DebugDir=%s " % (UniVfrOffsetFileName, self.BaseName, self.EfiDebugPath)\r
+                            GenFdsGlobalVariable.SecCmdList.append(TrimCmd)\r
+                            GenFdsGlobalVariable.GenerateSection(UniVfrOffsetFileSection,\r
+                                                                [UniVfrOffsetFileName],\r
+                                                                "EFI_SECTION_RAW",\r
+                                                                IsMakefile = True\r
+                                                                )\r
+                    else:\r
+                        VfrUniOffsetList = self.__GetBuildOutputMapFileVfrUniInfo(VfrUniBaseName)\r
+                        #\r
+                        # Generate the Raw data of raw section\r
+                        #\r
+                        if VfrUniOffsetList:\r
+                            UniVfrOffsetFileName = os.path.join(self.OutputPath, self.BaseName + '.offset')\r
+                            UniVfrOffsetFileSection = os.path.join(self.OutputPath, self.BaseName + 'Offset' + '.raw')\r
+                            self.__GenUniVfrOffsetFile (VfrUniOffsetList, UniVfrOffsetFileName)\r
+                            UniVfrOffsetFileNameList = []\r
+                            UniVfrOffsetFileNameList.append(UniVfrOffsetFileName)\r
+                            """Call GenSection"""\r
+\r
+                            GenFdsGlobalVariable.GenerateSection(UniVfrOffsetFileSection,\r
+                                                                 UniVfrOffsetFileNameList,\r
+                                                                 "EFI_SECTION_RAW"\r
+                                                                 )\r
+                            #os.remove(UniVfrOffsetFileName)\r
+                    if UniVfrOffsetFileSection:\r
                         SectList.append(UniVfrOffsetFileSection)\r
-                        HasGneratedFlag = True\r
+                        HasGeneratedFlag = True\r
                 \r
             for SecName in  SectList :\r
                 SectFiles.append(SecName)\r
@@ -981,7 +1020,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
     #   @param  InputFileList        The output file list from GenSection\r
     #   @retval string      Generated FFS file name\r
     #\r
-    def __GenComplexFileFfs__(self, Rule, InputFile, Alignments):\r
+    def __GenComplexFileFfs__(self, Rule, InputFile, Alignments, MakefilePath = None):\r
 \r
         if Rule.NameGuid != None and Rule.NameGuid.startswith('PCD('):\r
             PcdValue = GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid)\r
@@ -998,11 +1037,12 @@ class FfsInfStatement(FfsInfStatementClassObject):
 \r
         FfsOutput = os.path.join( self.OutputPath, self.ModuleGuid + '.ffs')\r
         GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputFile,\r
-                                         Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType],\r
-                                         self.ModuleGuid, Fixed=Rule.Fixed,\r
-                                         CheckSum=Rule.CheckSum, Align=Rule.Alignment,\r
-                                         SectionAlign=Alignments\r
-                                        )\r
+                                             Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType],\r
+                                             self.ModuleGuid, Fixed=Rule.Fixed,\r
+                                             CheckSum=Rule.CheckSum, Align=Rule.Alignment,\r
+                                             SectionAlign=Alignments,\r
+                                             MakefilePath=MakefilePath\r
+                                             )\r
         return FfsOutput\r
 \r
     ## __GetGenFfsCmdParameter__() method\r
@@ -1048,12 +1088,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
     #   @param  UniVfrOffsetFileName    The output offset file name.\r
     #\r
     def __GenUniVfrOffsetFile(self, VfrUniOffsetList, UniVfrOffsetFileName):\r
-        \r
-        try:\r
-            fInputfile = open(UniVfrOffsetFileName, "wb+", 0)\r
-        except:\r
-            EdkLogger.error("GenFds", FILE_OPEN_FAILURE, "File open failed for %s" %UniVfrOffsetFileName,None)\r
-            \r
+\r
         # Use a instance of StringIO to cache data\r
         fStringIO = StringIO.StringIO('')  \r
         \r
@@ -1085,18 +1120,11 @@ class FfsInfStatement(FfsInfStatementClassObject):
         #\r
         # write data into file.\r
         #\r
-        try :  \r
-            fInputfile.write (fStringIO.getvalue())\r
+        try :\r
+            SaveFileOnChange(UniVfrOffsetFileName, fStringIO.getvalue())\r
         except:\r
             EdkLogger.error("GenFds", FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." %UniVfrOffsetFileName,None)\r
         \r
         fStringIO.close ()\r
-        fInputfile.close ()\r
-        \r
-                \r
-                    \r
-            \r
-            \r
-        \r
-                                \r
+\r
         \r
index 45f6696a5fd74a8be1c42b41dc3063996705ae2e..3953756e0f8fb3e489fa66b650bd784707826a8e 100644 (file)
@@ -22,6 +22,7 @@ from struct import *
 \r
 import Ffs\r
 import AprioriSection\r
+import FfsFileStatement\r
 from GenFdsGlobalVariable import GenFdsGlobalVariable\r
 from GenFds import GenFds\r
 from CommonDataClass.FdfClass import FvClassObject\r
@@ -67,7 +68,7 @@ class FV (FvClassObject):
     #   @param  MacroDict   macro value pair\r
     #   @retval string      Generated FV file path\r
     #\r
-    def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}) :\r
+    def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :\r
 \r
         if BaseAddress == None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict.keys():\r
             return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv']\r
@@ -88,15 +89,15 @@ class FV (FvClassObject):
                                 continue\r
                             elif self.UiFvName.upper() == RegionData.upper():\r
                                 GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper()))\r
-\r
-        GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV" %self.UiFvName)\r
+        if not Flag:\r
+            GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV" %self.UiFvName)\r
         GenFdsGlobalVariable.LargeFileInFvFlags.append(False)\r
         FFSGuid = None\r
         \r
         if self.FvBaseAddress != None:\r
             BaseAddress = self.FvBaseAddress\r
-\r
-        self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, ErasePloarity, VtfDict)\r
+        if not Flag:\r
+            self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, ErasePloarity, VtfDict)\r
         #\r
         # First Process the Apriori section\r
         #\r
@@ -105,23 +106,30 @@ class FV (FvClassObject):
         GenFdsGlobalVariable.VerboseLogger('First generate Apriori file !')\r
         FfsFileList = []\r
         for AprSection in self.AprioriSectionList:\r
-            FileName = AprSection.GenFfs (self.UiFvName, MacroDict)\r
+            FileName = AprSection.GenFfs (self.UiFvName, MacroDict, IsMakefile=Flag)\r
             FfsFileList.append(FileName)\r
             # Add Apriori file name to Inf file\r
-            self.FvInfFile.writelines("EFI_FILE_NAME = " + \\r
-                                       FileName          + \\r
-                                           T_CHAR_LF)\r
+            if not Flag:\r
+                self.FvInfFile.writelines("EFI_FILE_NAME = " + \\r
+                                            FileName          + \\r
+                                            T_CHAR_LF)\r
 \r
         # Process Modules in FfsList\r
         for FfsFile in self.FfsList :\r
-            FileName = FfsFile.GenFfs(MacroDict, FvParentAddr=BaseAddress)\r
+            if Flag:\r
+                if isinstance(FfsFile, FfsFileStatement.FileStatement):\r
+                    continue\r
+            if GenFdsGlobalVariable.EnableGenfdsMultiThread and GenFdsGlobalVariable.ModuleFile and GenFdsGlobalVariable.ModuleFile.Path.find(os.path.normpath(FfsFile.InfFileName)) == -1:\r
+                continue\r
+            FileName = FfsFile.GenFfs(MacroDict, FvParentAddr=BaseAddress, IsMakefile=Flag)\r
             FfsFileList.append(FileName)\r
-            self.FvInfFile.writelines("EFI_FILE_NAME = " + \\r
-                                       FileName          + \\r
-                                       T_CHAR_LF)\r
-\r
-        SaveFileOnChange(self.InfFileName, self.FvInfFile.getvalue(), False)\r
-        self.FvInfFile.close()\r
+            if not Flag:\r
+                self.FvInfFile.writelines("EFI_FILE_NAME = " + \\r
+                                            FileName          + \\r
+                                            T_CHAR_LF)\r
+        if not Flag:\r
+            SaveFileOnChange(self.InfFileName, self.FvInfFile.getvalue(), False)\r
+            self.FvInfFile.close()\r
         #\r
         # Call GenFv tool\r
         #\r
@@ -131,88 +139,91 @@ class FV (FvClassObject):
         if self.CreateFileName != None:\r
             FvOutputFile = self.CreateFileName\r
 \r
+        if Flag:\r
+            GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile\r
+            return FvOutputFile\r
+\r
         FvInfoFileName = os.path.join(GenFdsGlobalVariable.FfsDir, self.UiFvName + '.inf')\r
-        CopyLongFilePath(GenFdsGlobalVariable.FvAddressFileName, FvInfoFileName)\r
-        OrigFvInfo = None\r
-        if os.path.exists (FvInfoFileName):\r
-            OrigFvInfo = open(FvInfoFileName, 'r').read()\r
-        if GenFdsGlobalVariable.LargeFileInFvFlags[-1]:\r
-            FFSGuid = GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID;\r
-        GenFdsGlobalVariable.GenerateFirmwareVolume(\r
-                                FvOutputFile,\r
-                                [self.InfFileName],\r
-                                AddressFile=FvInfoFileName,\r
-                                FfsList=FfsFileList,\r
-                                ForceRebase=self.FvForceRebase,\r
-                                FileSystemGuid=FFSGuid\r
-                                )\r
+        if not Flag:\r
+            CopyLongFilePath(GenFdsGlobalVariable.FvAddressFileName, FvInfoFileName)\r
+            OrigFvInfo = None\r
+            if os.path.exists (FvInfoFileName):\r
+                OrigFvInfo = open(FvInfoFileName, 'r').read()\r
+            if GenFdsGlobalVariable.LargeFileInFvFlags[-1]:\r
+                FFSGuid = GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID\r
+            GenFdsGlobalVariable.GenerateFirmwareVolume(\r
+                                    FvOutputFile,\r
+                                    [self.InfFileName],\r
+                                    AddressFile=FvInfoFileName,\r
+                                    FfsList=FfsFileList,\r
+                                    ForceRebase=self.FvForceRebase,\r
+                                    FileSystemGuid=FFSGuid\r
+                                    )\r
 \r
-        NewFvInfo = None\r
-        if os.path.exists (FvInfoFileName):\r
-            NewFvInfo = open(FvInfoFileName, 'r').read()\r
-        if NewFvInfo != None and NewFvInfo != OrigFvInfo:\r
-            FvChildAddr = []\r
-            AddFileObj = open(FvInfoFileName, 'r')\r
-            AddrStrings = AddFileObj.readlines()\r
-            AddrKeyFound = False\r
-            for AddrString in AddrStrings:\r
-                if AddrKeyFound:\r
-                    #get base address for the inside FvImage\r
-                    FvChildAddr.append (AddrString)\r
-                elif AddrString.find ("[FV_BASE_ADDRESS]") != -1:\r
-                    AddrKeyFound = True\r
-            AddFileObj.close()\r
+            NewFvInfo = None\r
+            if os.path.exists (FvInfoFileName):\r
+                NewFvInfo = open(FvInfoFileName, 'r').read()\r
+            if NewFvInfo != None and NewFvInfo != OrigFvInfo:\r
+                FvChildAddr = []\r
+                AddFileObj = open(FvInfoFileName, 'r')\r
+                AddrStrings = AddFileObj.readlines()\r
+                AddrKeyFound = False\r
+                for AddrString in AddrStrings:\r
+                    if AddrKeyFound:\r
+                        #get base address for the inside FvImage\r
+                        FvChildAddr.append (AddrString)\r
+                    elif AddrString.find ("[FV_BASE_ADDRESS]") != -1:\r
+                        AddrKeyFound = True\r
+                AddFileObj.close()\r
 \r
-            if FvChildAddr != []:\r
-                # Update Ffs again\r
-                for FfsFile in self.FfsList :\r
-                    FileName = FfsFile.GenFfs(MacroDict, FvChildAddr, BaseAddress)\r
-                \r
-                if GenFdsGlobalVariable.LargeFileInFvFlags[-1]:\r
-                    FFSGuid = GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID;\r
-                #Update GenFv again\r
-                GenFdsGlobalVariable.GenerateFirmwareVolume(\r
-                                        FvOutputFile,\r
-                                        [self.InfFileName],\r
-                                        AddressFile=FvInfoFileName,\r
-                                        FfsList=FfsFileList,\r
-                                        ForceRebase=self.FvForceRebase,\r
-                                        FileSystemGuid=FFSGuid\r
-                                        )\r
+                if FvChildAddr != []:\r
+                    # Update Ffs again\r
+                    for FfsFile in self.FfsList :\r
+                        FileName = FfsFile.GenFfs(MacroDict, FvChildAddr, BaseAddress, IsMakefile=Flag)\r
 \r
-        #\r
-        # Write the Fv contents to Buffer\r
-        #\r
-        if os.path.isfile(FvOutputFile):\r
-            FvFileObj = open ( FvOutputFile,'rb')\r
+                    if GenFdsGlobalVariable.LargeFileInFvFlags[-1]:\r
+                        FFSGuid = GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUID;\r
+                    #Update GenFv again\r
+                        GenFdsGlobalVariable.GenerateFirmwareVolume(\r
+                                                FvOutputFile,\r
+                                                [self.InfFileName],\r
+                                                AddressFile=FvInfoFileName,\r
+                                                FfsList=FfsFileList,\r
+                                                ForceRebase=self.FvForceRebase,\r
+                                                FileSystemGuid=FFSGuid\r
+                                                )\r
 \r
-            GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s FV Successfully" %self.UiFvName)\r
-            GenFdsGlobalVariable.SharpCounter = 0\r
+            #\r
+            # Write the Fv contents to Buffer\r
+            #\r
+            if os.path.isfile(FvOutputFile):\r
+                FvFileObj = open(FvOutputFile, 'rb')\r
+                GenFdsGlobalVariable.VerboseLogger("\nGenerate %s FV Successfully" % self.UiFvName)\r
+                GenFdsGlobalVariable.SharpCounter = 0\r
 \r
-            Buffer.write(FvFileObj.read())\r
-            FvFileObj.seek(0)\r
-            # PI FvHeader is 0x48 byte\r
-            FvHeaderBuffer = FvFileObj.read(0x48)\r
-            # FV alignment position.\r
-            FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)\r
-            # FvAlignmentValue is larger than or equal to 1K\r
-            if FvAlignmentValue >= 0x400:\r
-                if FvAlignmentValue >= 0x100000:\r
-                    #The max alignment supported by FFS is 16M.\r
-                    if FvAlignmentValue >= 0x1000000:\r
-                        self.FvAlignment = "16M"\r
+                Buffer.write(FvFileObj.read())\r
+                FvFileObj.seek(0)\r
+                # PI FvHeader is 0x48 byte\r
+                FvHeaderBuffer = FvFileObj.read(0x48)\r
+                # FV alignment position.\r
+                FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1F)\r
+                if FvAlignmentValue >= 0x400:\r
+                    if FvAlignmentValue >= 0x100000:\r
+                        if FvAlignmentValue >= 0x1000000:\r
+                        #The max alignment supported by FFS is 16M.\r
+                            self.FvAlignment = "16M"\r
+                        else:\r
+                            self.FvAlignment = str(FvAlignmentValue / 0x100000) + "M"\r
                     else:\r
-                        self.FvAlignment = str(FvAlignmentValue / 0x100000) + "M"\r
+                        self.FvAlignment = str(FvAlignmentValue / 0x400) + "K"\r
                 else:\r
-                    self.FvAlignment = str (FvAlignmentValue / 0x400) + "K"\r
+                    # FvAlignmentValue is less than 1K\r
+                    self.FvAlignment = str (FvAlignmentValue)\r
+                FvFileObj.close()\r
+                GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile\r
+                GenFdsGlobalVariable.LargeFileInFvFlags.pop()\r
             else:\r
-                # FvAlignmentValue is less than 1K\r
-                self.FvAlignment = str (FvAlignmentValue)\r
-            FvFileObj.close()\r
-            GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile\r
-            GenFdsGlobalVariable.LargeFileInFvFlags.pop()\r
-        else:\r
-            GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV file." %self.UiFvName)\r
+                GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV file." %self.UiFvName)\r
         return FvOutputFile\r
 \r
     ## _GetBlockSize()\r
index 68f17c31e8be27207564e330435096b38b423b5c..916ff919176cc00695af6b7bd6ad9c9d68a1897a 100644 (file)
@@ -50,7 +50,7 @@ class FvImageSection(FvImageSectionClassObject):
     #   @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
         OutputFileList = []\r
         if self.FvFileType != None:\r
@@ -75,7 +75,7 @@ class FvImageSection(FvImageSectionClassObject):
                     MaxFvAlignment = FvAlignmentValue\r
 \r
                 OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get("FV_IMAGE"))\r
-                GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE')\r
+                GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=IsMakefile)\r
                 OutputFileList.append(OutputFile)\r
 \r
             # MaxFvAlignment is larger than or equal to 1K\r
@@ -101,7 +101,7 @@ class FvImageSection(FvImageSectionClassObject):
             Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName)\r
             if Fv != None:\r
                 self.Fv = Fv\r
-                FvFileName = Fv.AddToBuffer(Buffer, self.FvAddr, MacroDict = Dict)\r
+                FvFileName = Fv.AddToBuffer(Buffer, self.FvAddr, MacroDict = Dict, Flag=IsMakefile)\r
                 if Fv.FvAlignment != None:\r
                     if self.Alignment == None:\r
                         self.Alignment = Fv.FvAlignment\r
@@ -139,7 +139,7 @@ class FvImageSection(FvImageSectionClassObject):
             # Prepare the parameter of GenSection\r
             #\r
             OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get("FV_IMAGE"))\r
-            GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE')\r
+            GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=IsMakefile)\r
             OutputFileList.append(OutputFile)\r
 \r
             return OutputFileList, self.Alignment\r
index c19dc4075793b8c9ea0b10df3b1cbd2952c54125..4a5d6f476abdd2bdc3cffaee86f4c790f812c603 100644 (file)
@@ -99,6 +99,8 @@ def main():
                 GenFdsGlobalVariable.EdkSourceDir = os.path.normcase(os.environ['EDK_SOURCE'])\r
             if (Options.debug):\r
                 GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace)\r
+            if Options.GenfdsMultiThread:\r
+                GenFdsGlobalVariable.EnableGenfdsMultiThread = True\r
         os.chdir(GenFdsGlobalVariable.WorkSpaceDir)\r
         \r
         # set multiple workspace\r
@@ -538,6 +540,7 @@ def myOptionParser():
     Parser.add_option("--conf", action="store", type="string", dest="ConfDirectory", help="Specify the customized Conf directory.")\r
     Parser.add_option("--ignore-sources", action="store_true", dest="IgnoreSources", default=False, help="Focus to a binary build and ignore all source files")\r
     Parser.add_option("--pcd", action="append", dest="OptionPcd", help="Set PCD value by command line. Format: \"PcdName=Value\" ")\r
+    Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=False, help="Enable GenFds multi thread to generate ffs file.")\r
 \r
     (Options, args) = Parser.parse_args()\r
     return Options\r
@@ -611,6 +614,23 @@ class GenFds :
                 for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys():\r
                     OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName]\r
                     OptRomObj.AddToBuffer(None)\r
+    @staticmethod\r
+    def GenFfsMakefile(OutputDir, FdfParser, WorkSpace, ArchList, GlobalData):\r
+        GenFdsGlobalVariable.SetEnv(FdfParser, WorkSpace, ArchList, GlobalData)\r
+        for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():\r
+            FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]\r
+            FdObj.GenFd(Flag=True)\r
+\r
+        for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():\r
+            FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName]\r
+            FvObj.AddToBuffer(Buffer=None, Flag=True)\r
+\r
+        if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}:\r
+            for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys():\r
+                OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName]\r
+                OptRomObj.AddToBuffer(Buffer=None, Flag=True)\r
+\r
+        return GenFdsGlobalVariable.FfsCmdDict\r
 \r
     ## GetFvBlockSize()\r
     #\r
index 83996beeea958f8518430909fc4cf4f99503328c..371d5a8217f70ffcf3cbe8175d79ac2cc8b7a1a4 100644 (file)
@@ -69,6 +69,11 @@ class GenFdsGlobalVariable:
     ToolChainFamily = "MSFT"\r
     __BuildRuleDatabase = None\r
     GuidToolDefinition = {}\r
+    FfsCmdDict = {}\r
+    SecCmdList = []\r
+    CopyList   = []\r
+    ModuleFile = ''\r
+    EnableGenfdsMultiThread = False\r
     \r
     #\r
     # The list whose element are flags to indicate if large FFS or SECTION files exist in FV.\r
@@ -264,6 +269,10 @@ class GenFdsGlobalVariable:
                 SourceList.extend(Target.Outputs)\r
                 LastTarget = Target\r
                 FileType = DataType.TAB_UNKNOWN_FILE\r
+                for Cmd in Target.Commands:\r
+                    if "$(CP)" == Cmd.split()[0]:\r
+                        CpTarget = Cmd.split()[2]\r
+                        TargetList.add(CpTarget)\r
 \r
         return list(TargetList)\r
 \r
@@ -317,6 +326,73 @@ class GenFdsGlobalVariable:
 \r
         FvAddressFile.close()\r
 \r
+    def SetEnv(FdfParser, WorkSpace, ArchList, GlobalData):\r
+        GenFdsGlobalVariable.ModuleFile = WorkSpace.ModuleFile\r
+        GenFdsGlobalVariable.FdfParser = FdfParser\r
+        GenFdsGlobalVariable.WorkSpace = WorkSpace.Db\r
+        GenFdsGlobalVariable.ArchList = ArchList\r
+        GenFdsGlobalVariable.ToolChainTag = GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]\r
+        GenFdsGlobalVariable.TargetName = GlobalData.gGlobalDefines["TARGET"]\r
+        GenFdsGlobalVariable.ActivePlatform = GlobalData.gActivePlatform\r
+        GenFdsGlobalVariable.EdkSourceDir = GlobalData.gGlobalDefines["EDK_SOURCE"]\r
+        GenFdsGlobalVariable.ConfDir  = GlobalData.gConfDirectory\r
+        GenFdsGlobalVariable.EnableGenfdsMultiThread = GlobalData.gEnableGenfdsMultiThread\r
+        for Arch in ArchList:\r
+            GenFdsGlobalVariable.OutputDirDict[Arch] = os.path.normpath(\r
+                os.path.join(GlobalData.gWorkspace,\r
+                             WorkSpace.Db.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch,GlobalData.gGlobalDefines['TARGET'],\r
+                             GlobalData.gGlobalDefines['TOOLCHAIN']].OutputDirectory,\r
+                             GlobalData.gGlobalDefines['TARGET'] +'_' + GlobalData.gGlobalDefines['TOOLCHAIN']))\r
+            GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = os.path.normpath(\r
+                             WorkSpace.Db.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch,\r
+                             GlobalData.gGlobalDefines['TARGET'], GlobalData.gGlobalDefines['TOOLCHAIN']].OutputDirectory)\r
+            GenFdsGlobalVariable.PlatformName = WorkSpace.Db.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch,\r
+                                                                      GlobalData.gGlobalDefines['TARGET'],\r
+                                                                      GlobalData.gGlobalDefines['TOOLCHAIN']].PlatformName\r
+        GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], 'FV')\r
+        if not os.path.exists(GenFdsGlobalVariable.FvDir):\r
+            os.makedirs(GenFdsGlobalVariable.FvDir)\r
+        GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')\r
+        if not os.path.exists(GenFdsGlobalVariable.FfsDir):\r
+            os.makedirs(GenFdsGlobalVariable.FfsDir)\r
+\r
+        T_CHAR_LF = '\n'\r
+        #\r
+        # Create FV Address inf file\r
+        #\r
+        GenFdsGlobalVariable.FvAddressFileName = os.path.join(GenFdsGlobalVariable.FfsDir, 'FvAddress.inf')\r
+        FvAddressFile = open(GenFdsGlobalVariable.FvAddressFileName, 'w')\r
+        #\r
+        # Add [Options]\r
+        #\r
+        FvAddressFile.writelines("[options]" + T_CHAR_LF)\r
+        BsAddress = '0'\r
+        for Arch in ArchList:\r
+            BsAddress = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch,\r
+                                                                   GlobalData.gGlobalDefines['TARGET'],\r
+                                                                   GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]].BsBaseAddress\r
+            if BsAddress:\r
+                break\r
+\r
+        FvAddressFile.writelines("EFI_BOOT_DRIVER_BASE_ADDRESS = " + \\r
+                                 BsAddress + \\r
+                                 T_CHAR_LF)\r
+\r
+        RtAddress = '0'\r
+        for Arch in ArchList:\r
+            if GenFdsGlobalVariable.WorkSpace.BuildObject[\r
+                GenFdsGlobalVariable.ActivePlatform, Arch, GlobalData.gGlobalDefines['TARGET'],\r
+                GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]].RtBaseAddress:\r
+                RtAddress = GenFdsGlobalVariable.WorkSpace.BuildObject[\r
+                    GenFdsGlobalVariable.ActivePlatform, Arch, GlobalData.gGlobalDefines['TARGET'],\r
+                    GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]].RtBaseAddress\r
+\r
+        FvAddressFile.writelines("EFI_RUNTIME_DRIVER_BASE_ADDRESS = " + \\r
+                                 RtAddress + \\r
+                                 T_CHAR_LF)\r
+\r
+        FvAddressFile.close()\r
+\r
     ## ReplaceWorkspaceMacro()\r
     #\r
     #   @param  String           String that may contain macro\r
@@ -363,7 +439,7 @@ class GenFdsGlobalVariable:
 \r
     @staticmethod\r
     def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None,\r
-                        GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None, BuildNumber=None):\r
+                        GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None, BuildNumber=None, DummyFile=None, IsMakefile=False):\r
         Cmd = ["GenSec"]\r
         if Type not in [None, '']:\r
             Cmd += ["-s", Type]\r
@@ -371,6 +447,8 @@ class GenFdsGlobalVariable:
             Cmd += ["-c", CompressionType]\r
         if Guid != None:\r
             Cmd += ["-g", Guid]\r
+        if DummyFile != None:\r
+            Cmd += ["--dummy", DummyFile]\r
         if GuidHdrLen not in [None, '']:\r
             Cmd += ["-l", GuidHdrLen]\r
         if len(GuidAttr) != 0:\r
@@ -385,13 +463,21 @@ class GenFdsGlobalVariable:
         CommandFile = Output + '.txt'\r
         if Ui not in [None, '']:\r
             #Cmd += ["-n", '"' + Ui + '"']\r
-            SectionData = array.array('B', [0, 0, 0, 0])\r
-            SectionData.fromstring(Ui.encode("utf_16_le"))\r
-            SectionData.append(0)\r
-            SectionData.append(0)\r
-            Len = len(SectionData)\r
-            GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15)\r
-            SaveFileOnChange(Output, SectionData.tostring())\r
+            if IsMakefile:\r
+                Cmd += ["-n", "$(MODULE_NAME)"]\r
+                Cmd += ["-o", Output]\r
+                #SaveFileOnChange(CommandFile, ' '.join(Cmd), False)\r
+                if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
+                    GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())\r
+            else:\r
+                SectionData = array.array('B', [0, 0, 0, 0])\r
+                SectionData.fromstring(Ui.encode("utf_16_le"))\r
+                SectionData.append(0)\r
+                SectionData.append(0)\r
+                Len = len(SectionData)\r
+                GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15)\r
+                SaveFileOnChange(Output, SectionData.tostring())\r
+\r
         elif Ver not in [None, '']:\r
             Cmd += ["-n", Ver]\r
             if BuildNumber:\r
@@ -399,22 +485,27 @@ class GenFdsGlobalVariable:
             Cmd += ["-o", Output]\r
 \r
             SaveFileOnChange(CommandFile, ' '.join(Cmd), False)\r
-            if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):\r
-                return\r
-\r
-            GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")\r
+            if IsMakefile:\r
+                if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
+                    GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())\r
+            else:\r
+                if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):\r
+                    return\r
+                GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")\r
         else:\r
             Cmd += ["-o", Output]\r
             Cmd += Input\r
 \r
             SaveFileOnChange(CommandFile, ' '.join(Cmd), False)\r
-            if GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):\r
+            if IsMakefile:\r
+                if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
+                    GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())\r
+            elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input)):\r
                 GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))\r
                 GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")\r
-\r
-            if (os.path.getsize(Output) >= GenFdsGlobalVariable.LARGE_FILE_SIZE and\r
-                GenFdsGlobalVariable.LargeFileInFvFlags):\r
-                GenFdsGlobalVariable.LargeFileInFvFlags[-1] = True \r
+                if (os.path.getsize(Output) >= GenFdsGlobalVariable.LARGE_FILE_SIZE and\r
+                    GenFdsGlobalVariable.LargeFileInFvFlags):\r
+                    GenFdsGlobalVariable.LargeFileInFvFlags[-1] = True\r
 \r
     @staticmethod\r
     def GetAlignment (AlignString):\r
@@ -429,7 +520,7 @@ class GenFdsGlobalVariable:
 \r
     @staticmethod\r
     def GenerateFfs(Output, Input, Type, Guid, Fixed=False, CheckSum=False, Align=None,\r
-                    SectionAlign=None):\r
+                    SectionAlign=None, MakefilePath=None):\r
         Cmd = ["GenFfs", "-t", Type, "-g", Guid]\r
         mFfsValidAlign = ["0", "8", "16", "128", "512", "1K", "4K", "32K", "64K", "128K", "256K", "512K", "1M", "2M", "4M", "8M", "16M"]\r
         if Fixed == True:\r
@@ -453,11 +544,17 @@ class GenFdsGlobalVariable:
 \r
         CommandFile = Output + '.txt'\r
         SaveFileOnChange(CommandFile, ' '.join(Cmd), False)\r
-        if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):\r
-            return\r
-        GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))\r
 \r
-        GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FFS")\r
+        GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))\r
+        if MakefilePath:\r
+            if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(GenFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict.keys():\r
+                GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple(GenFdsGlobalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)] = MakefilePath\r
+            GenFdsGlobalVariable.SecCmdList = []\r
+            GenFdsGlobalVariable.CopyList = []\r
+        else:\r
+            if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input)):\r
+                return\r
+            GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FFS")\r
 \r
     @staticmethod\r
     def GenerateFirmwareVolume(Output, Input, BaseAddress=None, ForceRebase=None, Capsule=False, Dump=False,\r
@@ -511,8 +608,8 @@ class GenFdsGlobalVariable:
     @staticmethod\r
     def GenerateFirmwareImage(Output, Input, Type="efi", SubType=None, Zero=False,\r
                               Strip=False, Replace=False, TimeStamp=None, Join=False,\r
-                              Align=None, Padding=None, Convert=False):\r
-        if not GenFdsGlobalVariable.NeedsUpdate(Output, Input):\r
+                              Align=None, Padding=None, Convert=False, IsMakefile=False):\r
+        if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsMakefile:\r
             return\r
         GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))\r
 \r
@@ -539,12 +636,15 @@ class GenFdsGlobalVariable:
             Cmd += ["-m"]\r
         Cmd += ["-o", Output]\r
         Cmd += Input\r
-\r
-        GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate firmware image")\r
+        if IsMakefile:\r
+            if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
+                GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip())\r
+        else:\r
+            GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate firmware image")\r
 \r
     @staticmethod\r
     def GenerateOptionRom(Output, EfiInput, BinaryInput, Compress=False, ClassCode=None,\r
-                        Revision=None, DeviceId=None, VendorId=None):\r
+                        Revision=None, DeviceId=None, VendorId=None, IsMakefile=False):\r
         InputList = []   \r
         Cmd = ["EfiRom"]\r
         if len(EfiInput) > 0:\r
@@ -565,7 +665,7 @@ class GenFdsGlobalVariable:
                 InputList.append (BinFile)\r
 \r
         # Check List\r
-        if not GenFdsGlobalVariable.NeedsUpdate(Output, InputList):\r
+        if not GenFdsGlobalVariable.NeedsUpdate(Output, InputList) and not IsMakefile:\r
             return\r
         GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, InputList))\r
                         \r
@@ -579,11 +679,15 @@ class GenFdsGlobalVariable:
             Cmd += ["-f", VendorId]\r
 \r
         Cmd += ["-o", Output]\r
-        GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate option rom")\r
+        if IsMakefile:\r
+            if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
+                GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip())\r
+        else:\r
+            GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate option rom")\r
 \r
     @staticmethod\r
-    def GuidTool(Output, Input, ToolPath, Options='', returnValue=[]):\r
-        if not GenFdsGlobalVariable.NeedsUpdate(Output, Input):\r
+    def GuidTool(Output, Input, ToolPath, Options='', returnValue=[], IsMakefile=False):\r
+        if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsMakefile:\r
             return\r
         GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))\r
 \r
@@ -591,8 +695,11 @@ class GenFdsGlobalVariable:
         Cmd += Options.split(' ')\r
         Cmd += ["-o", Output]\r
         Cmd += Input\r
-\r
-        GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to call " + ToolPath, returnValue)\r
+        if IsMakefile:\r
+            if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
+                GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip())\r
+        else:\r
+            GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to call " + ToolPath, returnValue)\r
 \r
     def CallExternalTool (cmd, errorMess, returnValue=[]):\r
 \r
@@ -727,6 +834,7 @@ class GenFdsGlobalVariable:
         return PcdValue\r
 \r
     SetDir = staticmethod(SetDir)\r
+    SetEnv = staticmethod(SetEnv)\r
     ReplaceWorkspaceMacro = staticmethod(ReplaceWorkspaceMacro)\r
     CallExternalTool = staticmethod(CallExternalTool)\r
     VerboseLogger = staticmethod(VerboseLogger)\r
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
index 5e3273d0f8512cb2ed1d74a6978d796d69f1a9c6..ab4fae611e3395d7297ea28b5d1cbb6fbb3c8f0b 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process OptionROM generation from FILE statement\r
 #\r
-#  Copyright (c) 2007 - 2014, 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
@@ -39,7 +39,7 @@ class OptRomFileStatement:
     #   @param  Dict        dictionary contains macro and value pair\r
     #   @retval string      Generated FFS file name\r
     #\r
-    def GenFfs(self, Dict = {}):\r
+    def GenFfs(self, Dict = {}, IsMakefile=False):\r
         \r
         if self.FileName != None:\r
             self.FileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)\r
index 069414df5b00bd18ca1b07c7dbad9f571456a75f..80c4bbab6effa848b416e2535c742e10f7f29c44 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process OptionROM generation from INF statement\r
 #\r
-#  Copyright (c) 2007, 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
@@ -81,7 +81,7 @@ class OptRomInfStatement (FfsInfStatement):
     #   @param  self        The object pointer\r
     #   @retval string      Generated .efi file name\r
     #\r
-    def GenFfs(self):\r
+    def GenFfs(self, IsMakefile=False):\r
         #\r
         # Parse Inf file get Module related information\r
         #\r
@@ -98,13 +98,13 @@ class OptRomInfStatement (FfsInfStatement):
         # For the rule only has simpleFile\r
         #\r
         if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) :\r
-            EfiOutputList = self.__GenSimpleFileSection__(Rule)\r
+            EfiOutputList = self.__GenSimpleFileSection__(Rule, IsMakefile=IsMakefile)\r
             return EfiOutputList\r
         #\r
         # For Rule has ComplexFile\r
         #\r
         elif isinstance(Rule, RuleComplexFile.RuleComplexFile):\r
-            EfiOutputList = self.__GenComplexFileSection__(Rule)\r
+            EfiOutputList = self.__GenComplexFileSection__(Rule, IsMakefile=IsMakefile)\r
             return EfiOutputList\r
 \r
     ## __GenSimpleFileSection__() method\r
@@ -115,7 +115,7 @@ class OptRomInfStatement (FfsInfStatement):
     #   @param  Rule        The rule object used to generate section\r
     #   @retval string      File name of the generated section file\r
     #\r
-    def __GenSimpleFileSection__(self, Rule):\r
+    def __GenSimpleFileSection__(self, Rule, IsMakefile = False):\r
         #\r
         # Prepare the parameter of GenSection\r
         #\r
@@ -138,7 +138,7 @@ class OptRomInfStatement (FfsInfStatement):
     #   @param  Rule        The rule object used to generate section\r
     #   @retval string      File name of the generated section file\r
     #\r
-    def __GenComplexFileSection__(self, Rule):\r
+    def __GenComplexFileSection__(self, Rule, IsMakefile=False):\r
 \r
         OutputFileList = []\r
         for Sect in Rule.SectionList:\r
index 7886a7cfe73e6b639d30b5d50c13aec4acc61620..2e61a38c1d333693bbb3912c4c770c7cfd586e26 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process OptionROM 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
@@ -49,9 +49,9 @@ class OPTIONROM (OptionRomClassObject):
     #   @param  Buffer      The buffer generated OptROM data will be put\r
     #   @retval string      Generated OptROM file path\r
     #\r
-    def AddToBuffer (self, Buffer) :\r
-\r
-        GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..." %self.DriverName)\r
+    def AddToBuffer (self, Buffer, Flag=False) :\r
+        if not Flag:\r
+            GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..." %self.DriverName)\r
 \r
         EfiFileList = []\r
         BinFileList = []\r
@@ -60,7 +60,7 @@ class OPTIONROM (OptionRomClassObject):
         for FfsFile in self.FfsList :\r
             \r
             if isinstance(FfsFile, OptRomInfStatement.OptRomInfStatement):\r
-                FilePathNameList = FfsFile.GenFfs()\r
+                FilePathNameList = FfsFile.GenFfs(IsMakefile=Flag)\r
                 if len(FilePathNameList) == 0:\r
                     EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s not produce .efi files, so NO file could be put into option ROM." % (FfsFile.InfFileName))\r
                 if FfsFile.OverrideAttribs == None:\r
@@ -79,10 +79,11 @@ class OPTIONROM (OptionRomClassObject):
                                                            FfsFile.OverrideAttribs.PciClassCode, \r
                                                            FfsFile.OverrideAttribs.PciRevision, \r
                                                            FfsFile.OverrideAttribs.PciDeviceId, \r
-                                                           FfsFile.OverrideAttribs.PciVendorId)\r
+                                                           FfsFile.OverrideAttribs.PciVendorId,\r
+                                                           IsMakefile = Flag)\r
                     BinFileList.append(TmpOutputFile)\r
             else:\r
-                FilePathName = FfsFile.GenFfs()\r
+                FilePathName = FfsFile.GenFfs(IsMakefile=Flag)\r
                 if FfsFile.OverrideAttribs != None:\r
                     FileName = os.path.basename(FilePathName)\r
                     TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName, FfsFile.CurrentArch)\r
@@ -97,7 +98,8 @@ class OPTIONROM (OptionRomClassObject):
                                                            FfsFile.OverrideAttribs.PciClassCode, \r
                                                            FfsFile.OverrideAttribs.PciRevision, \r
                                                            FfsFile.OverrideAttribs.PciDeviceId, \r
-                                                           FfsFile.OverrideAttribs.PciVendorId)\r
+                                                           FfsFile.OverrideAttribs.PciVendorId,\r
+                                                           IsMakefile=Flag)\r
                     BinFileList.append(TmpOutputFile)\r
                 else:\r
                     if FfsFile.FileType == 'EFI':\r
@@ -114,10 +116,11 @@ class OPTIONROM (OptionRomClassObject):
         GenFdsGlobalVariable.GenerateOptionRom(\r
                                 OutputFile,\r
                                 EfiFileList,\r
-                                BinFileList\r
-                                )\r
+                                BinFileList,\r
+                                IsMakefile=Flag)\r
 \r
-        GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Successfully" %self.DriverName)\r
+        if not Flag:\r
+            GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Successfully" %self.DriverName)\r
         GenFdsGlobalVariable.SharpCounter = 0\r
         \r
         return OutputFile\r
index 945c5489fdfede83b46ce4f5fadc15f91b7629f0..c946758cf549cf7914d8af9c6d9468fb8064e5e6 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process FD Region generation\r
 #\r
-#  Copyright (c) 2007 - 2015, 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
@@ -74,11 +74,14 @@ class Region(RegionClassObject):
     #   @retval string      Generated FV file path\r
     #\r
 \r
-    def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, ImageBinDict, vtfDict=None, MacroDict={}):\r
+    def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, ImageBinDict, vtfDict=None, MacroDict={}, Flag=False):\r
         Size = self.Size\r
-        GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X' % self.Offset)\r
-        GenFdsGlobalVariable.InfLogger("   Region Size = 0x%X" % Size)\r
+        if not Flag:\r
+            GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X' % self.Offset)\r
+            GenFdsGlobalVariable.InfLogger("   Region Size = 0x%X" % Size)\r
         GenFdsGlobalVariable.SharpCounter = 0\r
+        if Flag and (self.RegionType != 'FV'):\r
+            return\r
 \r
         if self.RegionType == 'FV':\r
             #\r
@@ -91,7 +94,8 @@ class Region(RegionClassObject):
                 FileName = None\r
                 if RegionData.endswith(".fv"):\r
                     RegionData = GenFdsGlobalVariable.MacroExtend(RegionData, MacroDict)\r
-                    GenFdsGlobalVariable.InfLogger('   Region FV File Name = .fv : %s' % RegionData)\r
+                    if not Flag:\r
+                        GenFdsGlobalVariable.InfLogger('   Region FV File Name = .fv : %s' % RegionData)\r
                     if RegionData[1] != ':' :\r
                         RegionData = mws.join (GenFdsGlobalVariable.WorkSpaceDir, RegionData)\r
                     if not os.path.exists(RegionData):\r
@@ -99,7 +103,8 @@ class Region(RegionClassObject):
 \r
                     FileName = RegionData\r
                 elif RegionData.upper() + 'fv' in ImageBinDict.keys():\r
-                    GenFdsGlobalVariable.InfLogger('   Region Name = FV')\r
+                    if not Flag:\r
+                        GenFdsGlobalVariable.InfLogger('   Region Name = FV')\r
                     FileName = ImageBinDict[RegionData.upper() + 'fv']\r
                 else:\r
                     #\r
@@ -110,7 +115,8 @@ class Region(RegionClassObject):
                         FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(RegionData.upper())\r
 \r
                     if FvObj != None :\r
-                        GenFdsGlobalVariable.InfLogger('   Region Name = FV')\r
+                        if not Flag:\r
+                            GenFdsGlobalVariable.InfLogger('   Region Name = FV')\r
                         #\r
                         # Call GenFv tool\r
                         #\r
@@ -124,7 +130,10 @@ class Region(RegionClassObject):
                         FvBaseAddress = '0x%X' % self.FvAddress\r
                         BlockSize = None\r
                         BlockNum = None\r
-                        FvObj.AddToBuffer(FvBuffer, FvBaseAddress, BlockSize, BlockNum, ErasePolarity, vtfDict)\r
+                        FvObj.AddToBuffer(FvBuffer, FvBaseAddress, BlockSize, BlockNum, ErasePolarity, vtfDict, Flag=Flag)\r
+                        if Flag:\r
+                            continue\r
+\r
                         if FvBuffer.len > Size:\r
                             FvBuffer.close()\r
                             EdkLogger.error("GenFds", GENFDS_ERROR,\r
@@ -142,20 +151,22 @@ class Region(RegionClassObject):
                 #\r
                 # Add the exist Fv image into FD buffer\r
                 #\r
-                if FileName != None:\r
-                    FileLength = os.stat(FileName)[ST_SIZE]\r
-                    if FileLength > Size:\r
-                        EdkLogger.error("GenFds", GENFDS_ERROR,\r
-                                        "Size of FV File (%s) is larger than Region Size 0x%X specified." \\r
-                                        % (RegionData, Size))\r
-                    BinFile = open(FileName, 'rb')\r
-                    Buffer.write(BinFile.read())\r
-                    BinFile.close()\r
-                    Size = Size - FileLength\r
+                if not Flag:\r
+                    if FileName != None:\r
+                        FileLength = os.stat(FileName)[ST_SIZE]\r
+                        if FileLength > Size:\r
+                            EdkLogger.error("GenFds", GENFDS_ERROR,\r
+                                            "Size of FV File (%s) is larger than Region Size 0x%X specified." \\r
+                                            % (RegionData, Size))\r
+                        BinFile = open(FileName, 'rb')\r
+                        Buffer.write(BinFile.read())\r
+                        BinFile.close()\r
+                        Size = Size - FileLength\r
             #\r
             # Pad the left buffer\r
             #\r
-            self.PadBuffer(Buffer, ErasePolarity, Size)\r
+            if not Flag:\r
+                self.PadBuffer(Buffer, ErasePolarity, Size)\r
 \r
         if self.RegionType == 'CAPSULE':\r
             #\r
index 942dd5cd3a9f0535d9e03431b7631e46dbc3a29b..4c1aaacd68d1146724b56ff72cb7837ae1fbf218 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # section base class\r
 #\r
-#  Copyright (c) 2007-2015, 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
@@ -141,7 +141,7 @@ class Section (SectionClassObject):
                 else:\r
                     GenFdsGlobalVariable.InfLogger ("\nCurrent ARCH \'%s\' of File %s is not in the Support Arch Scope of %s specified by INF %s in FDF" %(FfsInf.CurrentArch, File.File, File.Arch, FfsInf.InfFileName))\r
 \r
-        if Suffix != None and os.path.exists(FfsInf.EfiOutputPath):\r
+        if Suffix != None:\r
             #\r
             # Get Makefile path and time stamp\r
             #\r
index 419e1ee3584fddfda20d5f0709c26827936b2130..4f6926f7cae45af6b1630f443b559e0e78b732a8 100644 (file)
@@ -48,7 +48,7 @@ class UiSection (UiSectionClassObject):
     #   @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
         # Prepare the parameter of GenSection\r
         #\r
@@ -69,8 +69,7 @@ class UiSection (UiSectionClassObject):
             FileObj.close()\r
         else:\r
             NameString = ''\r
-\r
-        GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTION_USER_INTERFACE', Ui=NameString)\r
+        GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTION_USER_INTERFACE', Ui=NameString, IsMakefile=IsMakefile)\r
 \r
         OutputFileList = []\r
         OutputFileList.append(OutputFile)\r
index ad995d314bd66529c2f1454f62dbf0f41907b627..e29029980fad02db8fa36ca9014b4f0609e40fc8 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # process Version section generation\r
 #\r
-#  Copyright (c) 2007 - 2015, 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
@@ -48,7 +48,7 @@ class VerSection (VerSectionClassObject):
     #   @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
         # Prepare the parameter of GenSection\r
         #\r
@@ -65,7 +65,7 @@ class VerSection (VerSectionClassObject):
         # Get String Data\r
         StringData = ''\r
         if self.StringData != None:\r
-             StringData = self.StringData\r
+            StringData = self.StringData\r
         elif self.FileName != None:\r
             FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)\r
             FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)\r
@@ -75,9 +75,8 @@ class VerSection (VerSectionClassObject):
             FileObj.close()\r
         else:\r
             StringData = ''\r
-\r
         GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',\r
-                                             Ver=StringData, BuildNumber=self.BuildNum)\r
+                                             Ver=StringData, BuildNumber=self.BuildNum, IsMakefile=IsMakefile)\r
         OutputFileList = []\r
         OutputFileList.append(OutputFile)\r
         return OutputFileList, self.Alignment\r
index 53f12457f8c3d24ac7b2818601fb335d15102d3b..f94285a964ed2ea4774cfe0a9a95cffeafdbdeb9 100644 (file)
@@ -50,6 +50,7 @@ from PatchPcdValue.PatchPcdValue import *
 \r
 import Common.EdkLogger\r
 import Common.GlobalData as GlobalData\r
+from GenFds.GenFds import GenFds\r
 \r
 # Version and Copyright\r
 VersionNumber = "0.60" + ' ' + gBUILD_VERSION\r
@@ -774,6 +775,7 @@ class Build():
         GlobalData.gUseHashCache = BuildOptions.UseHashCache\r
         GlobalData.gBinCacheDest   = BuildOptions.BinCacheDest\r
         GlobalData.gBinCacheSource = BuildOptions.BinCacheSource\r
+        GlobalData.gEnableGenfdsMultiThread = BuildOptions.GenfdsMultiThread\r
 \r
         if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache:\r
             EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData="--binary-destination must be used together with --hash.")\r
@@ -1208,7 +1210,7 @@ class Build():
     #   @param  CreateDepModuleMakeFile     Flag used to indicate creating makefile\r
     #                                       for dependent modules/Libraries\r
     #\r
-    def _BuildPa(self, Target, AutoGenObject, CreateDepsCodeFile=True, CreateDepsMakeFile=True, BuildModule=False):\r
+    def _BuildPa(self, Target, AutoGenObject, CreateDepsCodeFile=True, CreateDepsMakeFile=True, BuildModule=False, FfsCommand={}):\r
         if AutoGenObject == None:\r
             return False\r
 \r
@@ -1224,7 +1226,7 @@ class Build():
 \r
             if not self.SkipAutoGen or Target == 'genmake':\r
                 self.Progress.Start("Generating makefile")\r
-                AutoGenObject.CreateMakeFile(CreateDepsMakeFile)\r
+                AutoGenObject.CreateMakeFile(CreateDepsMakeFile, FfsCommand)\r
                 self.Progress.Stop("done!")\r
             if Target == "genmake":\r
                 return True\r
@@ -1731,6 +1733,12 @@ class Build():
                 self.LoadFixAddress = Wa.Platform.LoadFixAddress\r
                 self.BuildReport.AddPlatformReport(Wa)\r
                 self.Progress.Stop("done!")\r
+\r
+                # Add ffs build to makefile\r
+                CmdListDict = {}\r
+                if GlobalData.gEnableGenfdsMultiThread and self.Fdf:\r
+                    CmdListDict = self._GenFfsCmd()\r
+\r
                 for Arch in Wa.ArchList:\r
                     GlobalData.gGlobalDefines['ARCH'] = Arch\r
                     Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, ToolChain, Arch)\r
@@ -1740,7 +1748,7 @@ class Build():
                         if Ma == None:\r
                             continue\r
                         self.BuildModules.append(Ma)\r
-                    self._BuildPa(self.Target, Pa)\r
+                    self._BuildPa(self.Target, Pa, FfsCommand=CmdListDict)\r
 \r
                 # Create MAP file when Load Fix Address is enabled.\r
                 if self.Target in ["", "all", "fds"]:\r
@@ -1819,6 +1827,10 @@ class Build():
                 self.Fdf = Wa.FdfFile\r
                 self.LoadFixAddress = Wa.Platform.LoadFixAddress\r
                 Wa.CreateMakeFile(False)\r
+                # Add ffs build to makefile\r
+                CmdListDict = None\r
+                if GlobalData.gEnableGenfdsMultiThread and self.Fdf:\r
+                    CmdListDict = self._GenFfsCmd()\r
                 self.Progress.Stop("done!")\r
                 MaList = []\r
                 ExitFlag = threading.Event()\r
@@ -1838,7 +1850,11 @@ class Build():
                                 if not self.SkipAutoGen or self.Target == 'genc':\r
                                     Ma.CreateCodeFile(True)\r
                                 if not self.SkipAutoGen or self.Target == 'genmake':\r
-                                    Ma.CreateMakeFile(True)\r
+                                    if CmdListDict and self.Fdf and (Module.File, Arch) in CmdListDict:\r
+                                        Ma.CreateMakeFile(True, CmdListDict[Module.File, Arch])\r
+                                        del CmdListDict[Module.File, Arch]\r
+                                    else:\r
+                                        Ma.CreateMakeFile(True)\r
                             MaList.append(Ma)\r
                             self.BuildModules.append(Ma)\r
                     self.AutoGenTime += int(round((time.time() - AutoGenStart)))\r
@@ -1922,6 +1938,17 @@ class Build():
                     #\r
                     self._SaveMapFile (MapBuffer, Wa)\r
 \r
+    def _GenFfsCmd(self):\r
+        CmdListDict = {}\r
+        GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, self.ArchList, GlobalData)\r
+        for Cmd in GenFfsDict:\r
+            tmpInf, tmpArch = GenFfsDict[Cmd]\r
+            if (tmpInf, tmpArch) not in CmdListDict.keys():\r
+                CmdListDict[tmpInf, tmpArch] = [Cmd]\r
+            else:\r
+                CmdListDict[tmpInf, tmpArch].append(Cmd)\r
+        return CmdListDict\r
+\r
     ## Build a platform in multi-thread mode\r
     #\r
     def _MultiThreadBuildPlatform(self):\r
@@ -1957,6 +1984,11 @@ class Build():
                 self.BuildReport.AddPlatformReport(Wa)\r
                 Wa.CreateMakeFile(False)\r
 \r
+                # Add ffs build to makefile\r
+                CmdListDict = None\r
+                if GlobalData.gEnableGenfdsMultiThread and self.Fdf:\r
+                    CmdListDict = self._GenFfsCmd()\r
+\r
                 # multi-thread exit flag\r
                 ExitFlag = threading.Event()\r
                 ExitFlag.clear()\r
@@ -1995,7 +2027,11 @@ class Build():
                                 continue\r
 \r
                             if not self.SkipAutoGen or self.Target == 'genmake':\r
-                                Ma.CreateMakeFile(True)\r
+                                if CmdListDict and self.Fdf and (Module.File, Arch) in CmdListDict:\r
+                                    Ma.CreateMakeFile(True, CmdListDict[Module.File, Arch])\r
+                                    del CmdListDict[Module.File, Arch]\r
+                                else:\r
+                                    Ma.CreateMakeFile(True)\r
                             if self.Target == "genmake":\r
                                 continue\r
                         self.BuildModules.append(Ma)\r
@@ -2311,7 +2347,7 @@ def MyOptionParser():
     Parser.add_option("--hash", action="store_true", dest="UseHashCache", default=False, help="Enable hash-based caching during build process.")\r
     Parser.add_option("--binary-destination", action="store", type="string", dest="BinCacheDest", help="Generate a cache of binary files in the specified directory.")\r
     Parser.add_option("--binary-source", action="store", type="string", dest="BinCacheSource", help="Consume a cache of binary files from the specified directory.")\r
-\r
+    Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=False, help="Enable GenFds multi thread to generate ffs file.")\r
     (Opt, Args) = Parser.parse_args()\r
     return (Opt, Args)\r
 \r