## @file\r
# Create makefile for MS nmake and GNU make\r
#\r
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2016, 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
ToolsDef.append("%s_%s = %s" % (Tool, Attr, Value))\r
ToolsDef.append("")\r
\r
+ # generate the Response file and Response flag\r
+ RespDict = self.CommandExceedLimit()\r
+ RespFileList = os.path.join(self._AutoGenObject.OutputDir, 'respfilelist.txt')\r
+ if RespDict:\r
+ RespFileListContent = ''\r
+ for Resp in RespDict.keys():\r
+ RespFile = os.path.join(self._AutoGenObject.OutputDir, str(Resp).lower() + '.txt')\r
+ SaveFileOnChange(RespFile, RespDict[Resp], False)\r
+ ToolsDef.append("%s = %s" % (Resp, '@' + RespFile))\r
+ RespFileListContent += '@' + RespFile + os.linesep\r
+ RespFileListContent += RespDict[Resp] + os.linesep\r
+ SaveFileOnChange(RespFileList, RespFileListContent, False)\r
+ else:\r
+ if os.path.exists(RespFileList):\r
+ os.remove(RespFileList)\r
+\r
# convert source files and binary files to build targets\r
self.ResultFileList = [str(T.Target) for T in self._AutoGenObject.CodaTargetList]\r
if len(self.ResultFileList) == 0 and len(self._AutoGenObject.SourceFileList) <> 0:\r
\r
return MakefileTemplateDict\r
\r
+ def CommandExceedLimit(self):\r
+ FlagDict = {\r
+ 'CC' : { 'Macro' : '$(CC_FLAGS)', 'Value' : False},\r
+ 'PP' : { 'Macro' : '$(PP_FLAGS)', 'Value' : False},\r
+ 'APP' : { 'Macro' : '$(APP_FLAGS)', 'Value' : False},\r
+ 'ASLPP' : { 'Macro' : '$(ASLPP_FLAGS)', 'Value' : False},\r
+ 'VFRPP' : { 'Macro' : '$(VFRPP_FLAGS)', 'Value' : False},\r
+ 'ASM' : { 'Macro' : '$(ASM_FLAGS)', 'Value' : False},\r
+ 'ASLCC' : { 'Macro' : '$(ASLCC_FLAGS)', 'Value' : False},\r
+ }\r
+\r
+ RespDict = {}\r
+ FileTypeList = []\r
+ IncPrefix = self._INC_FLAG_[self._AutoGenObject.ToolChainFamily]\r
+\r
+ # base on the source files to decide the file type\r
+ for File in self._AutoGenObject.SourceFileList:\r
+ for type in self._AutoGenObject.FileTypes:\r
+ if File in self._AutoGenObject.FileTypes[type]:\r
+ if type not in FileTypeList:\r
+ FileTypeList.append(type)\r
+\r
+ # calculate the command-line length\r
+ if FileTypeList:\r
+ for type in FileTypeList:\r
+ BuildTargets = self._AutoGenObject.BuildRules[type].BuildTargets\r
+ for Target in BuildTargets:\r
+ CommandList = BuildTargets[Target].Commands\r
+ for SingleCommand in CommandList:\r
+ Tool = ''\r
+ SingleCommandLength = len(SingleCommand)\r
+ SingleCommandList = SingleCommand.split()\r
+ if len(SingleCommandList) > 0:\r
+ for Flag in FlagDict.keys():\r
+ if '$('+ Flag +')' in SingleCommandList[0]:\r
+ Tool = Flag\r
+ break\r
+ if Tool:\r
+ SingleCommandLength += len(self._AutoGenObject._BuildOption[Tool]['PATH'])\r
+ for item in SingleCommandList[1:]:\r
+ if FlagDict[Tool]['Macro'] in item:\r
+ Str = self._AutoGenObject._BuildOption[Tool]['FLAGS']\r
+ while(Str.find('$(') != -1):\r
+ for macro in self._AutoGenObject.Macros.keys():\r
+ MacroName = '$('+ macro + ')'\r
+ if (Str.find(MacroName) != -1):\r
+ Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])\r
+ break\r
+ else:\r
+ EdkLogger.error("build", AUTOGEN_ERROR, "Not supported macro is found in make command : %s" % Str, ExtraData="[%s]" % str(self._AutoGenObject))\r
+ SingleCommandLength += len(Str)\r
+ elif '$(INC)' in item:\r
+ SingleCommandLength += self._AutoGenObject.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject._IncludePathList)\r
+ elif item.find('$(') != -1:\r
+ Str = item\r
+ for Option in self._AutoGenObject.BuildOption.keys():\r
+ for Attr in self._AutoGenObject.BuildOption[Option]:\r
+ if Str.find(Option + '_' + Attr) != -1:\r
+ Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])\r
+ while(Str.find('$(') != -1):\r
+ for macro in self._AutoGenObject.Macros.keys():\r
+ MacroName = '$('+ macro + ')'\r
+ if (Str.find(MacroName) != -1):\r
+ Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])\r
+ break\r
+ else:\r
+ EdkLogger.error("build", AUTOGEN_ERROR, "Not supported macro is found in make command : %s" % Str, ExtraData="[%s]" % str(self._AutoGenObject))\r
+\r
+ SingleCommandLength += len(Str)\r
+\r
+ if SingleCommandLength > GlobalData.gCommandMaxLength:\r
+ FlagDict[Tool]['Value'] = True\r
+\r
+ # generate the response file content by combine the FLAGS and INC\r
+ for Flag in FlagDict.keys():\r
+ if FlagDict[Flag]['Value']:\r
+ Key = Flag + '_RESP'\r
+ RespMacro = FlagDict[Flag]['Macro'].replace('FLAGS', 'RESP')\r
+ Value = self._AutoGenObject.BuildOption[Flag]['FLAGS']\r
+ for inc in self._AutoGenObject._IncludePathList:\r
+ Value += ' ' + IncPrefix + inc\r
+ while (Value.find('$(') != -1):\r
+ for macro in self._AutoGenObject.Macros.keys():\r
+ MacroName = '$('+ macro + ')'\r
+ if (Value.find(MacroName) != -1):\r
+ Value = Value.replace(MacroName, self._AutoGenObject.Macros[macro])\r
+ break\r
+ else:\r
+ EdkLogger.error("build", AUTOGEN_ERROR, "Not supported macro is found in make command : %s" % Str, ExtraData="[%s]" % str(self._AutoGenObject))\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
+ BuildTargets[Target].Commands[i] = SingleCommand.replace('$(INC)','').replace(FlagDict[Flag]['Macro'], RespMacro)\r
+ return RespDict\r
+\r
def ProcessBuildTargetList(self):\r
#\r
# Search dependency file list for each source file\r
if Proc.returncode != 0:\r
if type(Command) != type(""):\r
Command = " ".join(Command)\r
+ # print out the Response file and its content when make failure\r
+ RespFile = os.path.join(WorkingDir, 'OUTPUT', 'respfilelist.txt')\r
+ if os.path.isfile(RespFile):\r
+ f = open(RespFile)\r
+ RespContent = f.read()\r
+ f.close()\r
+ EdkLogger.info(RespContent)\r
+\r
EdkLogger.error("build", COMMAND_FAILURE, ExtraData="%s [%s]" % (Command, WorkingDir))\r
\r
## The smallest unit that can be built in multi-thread build mode\r
self.UniFlag = BuildOptions.Flag\r
self.BuildModules = []\r
\r
+ if BuildOptions.CommandLength:\r
+ GlobalData.gCommandMaxLength = BuildOptions.CommandLength\r
+\r
# print dot character during doing some time-consuming work\r
self.Progress = Utils.Progressor()\r
\r
Parser.add_option("--check-usage", action="store_true", dest="CheckUsage", default=False, help="Check usage content of entries listed in INF file.")\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("-l", "--cmd-len", action="store", type="int", dest="CommandLength", help="Specify the maximum line length of build command. Default is 4096.")\r
\r
(Opt, Args) = Parser.parse_args()\r
return (Opt, Args)\r