From 3570e3324835ba08fa68a1d0bf59290750ff797d Mon Sep 17 00:00:00 2001 From: Yonghong Zhu Date: Wed, 23 Mar 2016 14:54:36 +0800 Subject: 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 Reviewed-by: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 6 +++++ BaseTools/Source/Python/AutoGen/GenMake.py | 42 +++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 4934c578fa..e9e46c29d7 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -2480,6 +2480,12 @@ class ModuleAutoGen(AutoGen): self._Macro["DEBUG_DIR" ] = self.DebugDir self._Macro["DEST_DIR_OUTPUT" ] = self.OutputDir 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 the module build data object diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 59ac2e8dda..a4844bec73 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -477,6 +477,17 @@ cleanlib: # EdkII modules always use "_ModuleEntryPoint" as entry point 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 ToolsDef = [] IncPrefix = self._INC_FLAG_[self._AutoGenObject.ToolChainFamily] @@ -504,10 +515,20 @@ cleanlib: RespFileListContent = '' for Resp in RespDict.keys(): RespFile = os.path.join(self._AutoGenObject.OutputDir, str(Resp).lower() + '.txt') - SaveFileOnChange(RespFile, RespDict[Resp], False) - ToolsDef.append("%s = %s" % (Resp, '@' + RespFile)) + StrList = RespDict[Resp].split(' ') + 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 += RespDict[Resp] + os.linesep + RespFileListContent += NewRespStr + os.linesep SaveFileOnChange(RespFileList, RespFileListContent, False) else: if os.path.exists(RespFileList): @@ -678,6 +699,10 @@ cleanlib: for item in SingleCommandList[1:]: if FlagDict[Tool]['Macro'] in item: 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): for macro in self._AutoGenObject.Macros.keys(): MacroName = '$('+ macro + ')' @@ -685,7 +710,7 @@ cleanlib: Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro]) break 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) elif '$(INC)' in item: SingleCommandLength += self._AutoGenObject.IncludePathLength + len(IncPrefix) * len(self._AutoGenObject._IncludePathList) @@ -702,8 +727,7 @@ cleanlib: Str = Str.replace(MacroName, self._AutoGenObject.Macros[macro]) break 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) if SingleCommandLength > GlobalData.gCommandMaxLength: @@ -717,6 +741,10 @@ cleanlib: Value = self._AutoGenObject.BuildOption[Flag]['FLAGS'] for inc in self._AutoGenObject._IncludePathList: 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): for macro in self._AutoGenObject.Macros.keys(): MacroName = '$('+ macro + ')' @@ -724,7 +752,7 @@ cleanlib: Value = Value.replace(MacroName, self._AutoGenObject.Macros[macro]) break 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 for Target in BuildTargets: for i, SingleCommand in enumerate(BuildTargets[Target].Commands): -- cgit v1.2.3