## @file\r
# Create makefile for MS nmake and GNU make\r
#\r
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\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
#\r
clean:\r
\t${BEGIN}${clean_command}\r
-\t${END}\r
+\t${END}\t$(RM) AutoGenTimeStamp\r
\r
#\r
# clean all generated files\r
${BEGIN}\t${cleanall_command}\r
${END}\t$(RM) *.pdb *.idb > NUL 2>&1\r
\t$(RM) $(BIN_DIR)${separator}$(MODULE_NAME).efi\r
+\t$(RM) AutoGenTimeStamp\r
\r
#\r
# clean all dependent libraries built\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
if 'IMAGE_ENTRY_POINT' not in self._AutoGenObject.Macros.keys():\r
self._AutoGenObject.Macros['IMAGE_ENTRY_POINT'] = ImageEntryPoint\r
\r
+ PCI_COMPRESS_Flag = False\r
+ for k, v in self._AutoGenObject.Module.Defines.iteritems():\r
+ if 'PCI_COMPRESS' == k and 'TRUE' == v:\r
+ PCI_COMPRESS_Flag = True\r
+\r
# tools definitions\r
ToolsDef = []\r
IncPrefix = self._INC_FLAG_[self._AutoGenObject.ToolChainFamily]\r
# Remove duplicated include path, if any\r
if Attr == "FLAGS":\r
Value = RemoveDupOption(Value, IncPrefix, self._AutoGenObject.IncludePathList)\r
+ if Tool == "OPTROM" and PCI_COMPRESS_Flag:\r
+ ValueList = Value.split()\r
+ if ValueList:\r
+ for i, v in enumerate(ValueList):\r
+ if '-e' == v:\r
+ ValueList[i] = '-ec'\r
+ Value = ' '.join(ValueList)\r
+\r
ToolsDef.append("%s_%s = %s" % (Tool, Attr, Value))\r
ToolsDef.append("")\r
\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
while not found and os.sep in package_rel_dir:\r
index = package_rel_dir.index(os.sep)\r
current_dir = mws.join(current_dir, package_rel_dir[:index])\r
- for fl in os.listdir(current_dir):\r
- if fl.endswith('.dec'):\r
- found = True\r
- break\r
+ if os.path.exists(current_dir):\r
+ for fl in os.listdir(current_dir):\r
+ if fl.endswith('.dec'):\r
+ found = True\r
+ break\r
package_rel_dir = package_rel_dir[index + 1:]\r
\r
MakefileTemplateDict = {\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
break\r
else:\r
break\r
- RespDict[Key] = Value\r
+\r
+ if self._AutoGenObject.ToolChainFamily == 'GCC':\r
+ RespDict[Key] = Value.replace('\\', '/')\r
+ else:\r
+ RespDict[Key] = Value\r
for Target in BuildTargets:\r
for i, SingleCommand in enumerate(BuildTargets[Target].Commands):\r
if FlagDict[Flag]['Macro'] in SingleCommand:\r
if File.Ext == '.h':\r
ForceIncludedFile.append(File)\r
SourceFileList = []\r
+ OutPutFileList = []\r
for Target in self._AutoGenObject.IntroTargetList:\r
SourceFileList.extend(Target.Inputs)\r
+ OutPutFileList.extend(Target.Outputs)\r
+\r
+ if OutPutFileList:\r
+ for Item in OutPutFileList:\r
+ if Item in SourceFileList:\r
+ SourceFileList.remove(Item)\r
\r
self.FileDependency = self.GetFileDependency(\r
SourceFileList,\r
if not self.FileDependency[File]:\r
self.FileDependency[File] = ['$(FORCE_REBUILD)']\r
continue\r
+\r
+ self._AutoGenObject.AutoGenDepSet |= set(self.FileDependency[File])\r
+\r
# skip non-C files\r
if File.Ext not in [".c", ".C"] or File.Name == "AutoGen.c":\r
continue\r
# Use file list macro as dependency\r
if T.GenFileListMacro:\r
Deps.append("$(%s)" % T.FileListMacro)\r
+ if Type in [TAB_OBJECT_FILE, TAB_STATIC_LIBRARY]:\r
+ Deps.append("$(%s)" % T.ListFileMacro)\r
\r
TargetDict = {\r
"target" : self.PlaceMacro(T.Target.Path, self.Macros),\r
## For creating makefile targets for dependent libraries\r
def ProcessDependentLibrary(self):\r
for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:\r
- self.LibraryBuildDirectoryList.append(self.PlaceMacro(LibraryAutoGen.BuildDir, self.Macros))\r
+ if not LibraryAutoGen.IsBinaryModule:\r
+ self.LibraryBuildDirectoryList.append(self.PlaceMacro(LibraryAutoGen.BuildDir, self.Macros))\r
\r
## Return a list containing source file's dependencies\r
#\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
if GlobalData.BuildOptionPcd:\r
for index, option in enumerate(GlobalData.gCommand):\r
if "--pcd" == option and GlobalData.gCommand[index+1]:\r
- ExtraOption += " --pcd " + GlobalData.gCommand[index+1]\r
+ pcdName, pcdValue = GlobalData.gCommand[index+1].split('=')\r
+ if pcdValue.startswith('H'):\r
+ pcdValue = 'H' + '"' + pcdValue[1:] + '"'\r
+ ExtraOption += " --pcd " + pcdName + '=' + pcdValue\r
+ elif pcdValue.startswith("L'"):\r
+ ExtraOption += "--pcd " + pcdName + '=' + pcdValue\r
+ elif pcdValue.startswith('L'):\r
+ pcdValue = 'L' + '"' + pcdValue[1:] + '"'\r
+ ExtraOption += " --pcd " + pcdName + '=' + pcdValue\r
+ else:\r
+ ExtraOption += " --pcd " + GlobalData.gCommand[index+1]\r
\r
MakefileName = self._FILE_NAME_[self._FileType]\r
SubBuildCommandList = []\r