# @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
\r
self._BuildDir = None\r
self._OutputDir = None\r
+ self._FfsOutputDir = None\r
self._DebugDir = None\r
self._MakeFileDir = None\r
\r
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
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
# @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
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
"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
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
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
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
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
"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
\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
\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
gPlatformHash = None\r
gPackageHash = {}\r
gModuleHash = {}\r
+gEnableGenfdsMultiThread = False\r
## @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
# @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
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
\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
## @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
# @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
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
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
# @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
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
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
## @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
# @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
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
# @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
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
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
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
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
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
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
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
\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
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
#\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
# 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
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
'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
# 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
## @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
# @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
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
self.OverrideGuid = None\r
self.PatchedBinFile = ''\r
self.MacroDict = {}\r
+ self.Depex = False\r
\r
## GetFinalTargetSuffixMap() method\r
#\r
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
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
# @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
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
#\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
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
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
# @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
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
\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
# @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
% (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
# @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
GenFdsGlobalVariable.GenerateSection(PcdExDbSecName,\r
[PcdExDbFileName],\r
"EFI_SECTION_RAW",\r
+ IsMakefile = IsMakefile\r
)\r
SectFiles.append(PcdExDbSecName)\r
SectAlignments.append(None)\r
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
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
\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
# @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
\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
# @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
#\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
\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
# @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
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
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
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
# @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
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
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
# 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
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
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
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
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
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
\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
\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
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
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
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
\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
\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
@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
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
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
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
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
return PcdValue\r
\r
SetDir = staticmethod(SetDir)\r
+ SetEnv = staticmethod(SetEnv)\r
ReplaceWorkspaceMacro = staticmethod(ReplaceWorkspaceMacro)\r
CallExternalTool = staticmethod(CallExternalTool)\r
VerboseLogger = staticmethod(VerboseLogger)\r
## @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
# @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
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
#\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
#\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
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
## @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
# @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
## @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
# @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
# 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
# @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
# @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
## @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
# @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
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
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
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
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
## @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
# @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
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
\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
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
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
#\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
## @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
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
# @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
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
## @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
# @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
# 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
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
\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
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
# @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
\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
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
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
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
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
#\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
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
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
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