BaseTools: not include the undefined macro in response file

In last Nmake patch, when we generate the response file, we would replace
all the Macros in the make file. Once there have undefined macro used,
the tool direct report error. In this patch, we use following solution to
resolve the failure.
1. Add all the defined macros into AutoGenObject macro dict
2. For the undefined macros which used in the Make file, when we generate
the response file, we not include this macro, let make phase to handle.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Yonghong Zhu 2016-03-23 14:54:36 +08:00
parent c7d1e742ec
commit 3570e33248
2 changed files with 41 additions and 7 deletions

View File

@ -2480,6 +2480,12 @@ class ModuleAutoGen(AutoGen):
self._Macro["DEBUG_DIR" ] = self.DebugDir self._Macro["DEBUG_DIR" ] = self.DebugDir
self._Macro["DEST_DIR_OUTPUT" ] = self.OutputDir self._Macro["DEST_DIR_OUTPUT" ] = self.OutputDir
self._Macro["DEST_DIR_DEBUG" ] = self.DebugDir self._Macro["DEST_DIR_DEBUG" ] = self.DebugDir
self._Macro["PLATFORM_NAME" ] = self.PlatformInfo.Name
self._Macro["PLATFORM_GUID" ] = self.PlatformInfo.Guid
self._Macro["PLATFORM_VERSION" ] = self.PlatformInfo.Version
self._Macro["PLATFORM_RELATIVE_DIR" ] = self.PlatformInfo.SourceDir
self._Macro["PLATFORM_DIR" ] = mws.join(self.WorkspaceDir, self.PlatformInfo.SourceDir)
self._Macro["PLATFORM_OUTPUT_DIR" ] = self.PlatformInfo.OutputDir
return self._Macro return self._Macro
## Return the module build data object ## Return the module build data object

View File

@ -477,6 +477,17 @@ cleanlib:
# EdkII modules always use "_ModuleEntryPoint" as entry point # EdkII modules always use "_ModuleEntryPoint" as entry point
ImageEntryPoint = "_ModuleEntryPoint" ImageEntryPoint = "_ModuleEntryPoint"
for k, v in self._AutoGenObject.Module.Defines.iteritems():
if k not in self._AutoGenObject.Macros.keys():
self._AutoGenObject.Macros[k] = v
if 'MODULE_ENTRY_POINT' not in self._AutoGenObject.Macros.keys():
self._AutoGenObject.Macros['MODULE_ENTRY_POINT'] = ModuleEntryPoint
if 'ARCH_ENTRY_POINT' not in self._AutoGenObject.Macros.keys():
self._AutoGenObject.Macros['ARCH_ENTRY_POINT'] = ArchEntryPoint
if 'IMAGE_ENTRY_POINT' not in self._AutoGenObject.Macros.keys():
self._AutoGenObject.Macros['IMAGE_ENTRY_POINT'] = ImageEntryPoint
# tools definitions # tools definitions
ToolsDef = [] ToolsDef = []
IncPrefix = self._INC_FLAG_[self._AutoGenObject.ToolChainFamily] IncPrefix = self._INC_FLAG_[self._AutoGenObject.ToolChainFamily]
@ -504,10 +515,20 @@ cleanlib:
RespFileListContent = '' RespFileListContent = ''
for Resp in RespDict.keys(): for Resp in RespDict.keys():
RespFile = os.path.join(self._AutoGenObject.OutputDir, str(Resp).lower() + '.txt') RespFile = os.path.join(self._AutoGenObject.OutputDir, str(Resp).lower() + '.txt')
SaveFileOnChange(RespFile, RespDict[Resp], False) StrList = RespDict[Resp].split(' ')
ToolsDef.append("%s = %s" % (Resp, '@' + RespFile)) UnexpandMacro = []
NewStr = []
for Str in StrList:
if '$' in Str:
UnexpandMacro.append(Str)
else:
NewStr.append(Str)
UnexpandMacroStr = ' '.join(UnexpandMacro)
NewRespStr = ' '.join(NewStr)
SaveFileOnChange(RespFile, NewRespStr, False)
ToolsDef.append("%s = %s" % (Resp, UnexpandMacroStr + ' @' + RespFile))
RespFileListContent += '@' + RespFile + os.linesep RespFileListContent += '@' + RespFile + os.linesep
RespFileListContent += RespDict[Resp] + os.linesep RespFileListContent += NewRespStr + os.linesep
SaveFileOnChange(RespFileList, RespFileListContent, False) SaveFileOnChange(RespFileList, RespFileListContent, False)
else: else:
if os.path.exists(RespFileList): if os.path.exists(RespFileList):
@ -678,6 +699,10 @@ cleanlib:
for item in SingleCommandList[1:]: for item in SingleCommandList[1:]:
if FlagDict[Tool]['Macro'] in item: if FlagDict[Tool]['Macro'] in item:
Str = self._AutoGenObject._BuildOption[Tool]['FLAGS'] Str = self._AutoGenObject._BuildOption[Tool]['FLAGS']
for Option in self._AutoGenObject.BuildOption.keys():
for Attr in self._AutoGenObject.BuildOption[Option]:
if Str.find(Option + '_' + Attr) != -1:
Str = Str.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while(Str.find('$(') != -1): while(Str.find('$(') != -1):
for macro in self._AutoGenObject.Macros.keys(): for macro in self._AutoGenObject.Macros.keys():
MacroName = '$('+ macro + ')' MacroName = '$('+ macro + ')'
@ -685,7 +710,7 @@ cleanlib:
Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro]) Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])
break break
else: else:
EdkLogger.error("build", AUTOGEN_ERROR, "Not supported macro is found in make command : %s" % Str, ExtraData="[%s]" % str(self._AutoGenObject)) break
SingleCommandLength += len(Str) SingleCommandLength += len(Str)
elif '$(INC)' in item: elif '$(INC)' in item:
SingleCommandLength += self._AutoGenObject.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject._IncludePathList) SingleCommandLength += self._AutoGenObject.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject._IncludePathList)
@ -702,8 +727,7 @@ cleanlib:
Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro]) Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro])
break break
else: else:
EdkLogger.error("build", AUTOGEN_ERROR, "Not supported macro is found in make command : %s" % Str, ExtraData="[%s]" % str(self._AutoGenObject)) break
SingleCommandLength += len(Str) SingleCommandLength += len(Str)
if SingleCommandLength > GlobalData.gCommandMaxLength: if SingleCommandLength > GlobalData.gCommandMaxLength:
@ -717,6 +741,10 @@ cleanlib:
Value = self._AutoGenObject.BuildOption[Flag]['FLAGS'] Value = self._AutoGenObject.BuildOption[Flag]['FLAGS']
for inc in self._AutoGenObject._IncludePathList: for inc in self._AutoGenObject._IncludePathList:
Value += ' ' + IncPrefix + inc Value += ' ' + IncPrefix + inc
for Option in self._AutoGenObject.BuildOption.keys():
for Attr in self._AutoGenObject.BuildOption[Option]:
if Value.find(Option + '_' + Attr) != -1:
Value = Value.replace('$(' + Option + '_' + Attr + ')', self._AutoGenObject.BuildOption[Option][Attr])
while (Value.find('$(') != -1): while (Value.find('$(') != -1):
for macro in self._AutoGenObject.Macros.keys(): for macro in self._AutoGenObject.Macros.keys():
MacroName = '$('+ macro + ')' MacroName = '$('+ macro + ')'
@ -724,7 +752,7 @@ cleanlib:
Value = Value.replace(MacroName, self._AutoGenObject.Macros[macro]) Value = Value.replace(MacroName, self._AutoGenObject.Macros[macro])
break break
else: else:
EdkLogger.error("build", AUTOGEN_ERROR, "Not supported macro is found in make command : %s" % Str, ExtraData="[%s]" % str(self._AutoGenObject)) break
RespDict[Key] = Value RespDict[Key] = Value
for Target in BuildTargets: for Target in BuildTargets:
for i, SingleCommand in enumerate(BuildTargets[Target].Commands): for i, SingleCommand in enumerate(BuildTargets[Target].Commands):