+ 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