BaseTools: Fix bug for GUIDED tool path override by DSC [BuildOptions]

Current the GUIDED tool path can't be override to the different path in
the [BuildOptions] of DSC file. This patch fix the bug.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=283
Cc: Liming Gao <liming.gao@intel.com>
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 2017-02-15 14:47:47 +08:00
parent b173ad7851
commit 958163561e
2 changed files with 68 additions and 22 deletions

View File

@ -1718,7 +1718,10 @@ class PlatformAutoGen(AutoGen):
if self.BuildOption[Tool][Attr].startswith('='):
Value = self.BuildOption[Tool][Attr][1:]
else:
Value += " " + self.BuildOption[Tool][Attr]
if Attr != 'PATH':
Value += " " + self.BuildOption[Tool][Attr]
else:
Value = self.BuildOption[Tool][Attr]
if Attr == "PATH":
# Don't put MAKE definition in the file
@ -2381,8 +2384,11 @@ class PlatformAutoGen(AutoGen):
if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or Options[Key].startswith('='):
BuildOptions[Tool][Attr] = Options[Key]
else:
# append options for the same tool
BuildOptions[Tool][Attr] += " " + Options[Key]
# append options for the same tool except PATH
if Attr != 'PATH':
BuildOptions[Tool][Attr] += " " + Options[Key]
else:
BuildOptions[Tool][Attr] = Options[Key]
# Build Option Family has been checked, which need't to be checked again for family.
if FamilyMatch or FamilyIsNull:
return BuildOptions
@ -2413,8 +2419,11 @@ class PlatformAutoGen(AutoGen):
if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or Options[Key].startswith('='):
BuildOptions[Tool][Attr] = Options[Key]
else:
# append options for the same tool
BuildOptions[Tool][Attr] += " " + Options[Key]
# append options for the same tool except PATH
if Attr != 'PATH':
BuildOptions[Tool][Attr] += " " + Options[Key]
else:
BuildOptions[Tool][Attr] = Options[Key]
return BuildOptions
## Append build options in platform to a module
@ -2473,7 +2482,10 @@ class PlatformAutoGen(AutoGen):
BuildOptions[Tool][Attr] = ToolPath
else:
Value = mws.handleWsMacro(Value)
BuildOptions[Tool][Attr] += " " + Value
if Attr != 'PATH':
BuildOptions[Tool][Attr] += " " + Value
else:
BuildOptions[Tool][Attr] = Value
if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag != None:
#
# Override UNI flag only for EDK module.

View File

@ -1,7 +1,7 @@
## @file
# generate flash image
#
# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -30,7 +30,7 @@ from EfiSection import EfiSection
import StringIO
import Common.TargetTxtClassObject as TargetTxtClassObject
import Common.ToolDefClassObject as ToolDefClassObject
import Common.DataType
from Common.DataType import *
import Common.GlobalData as GlobalData
from Common import EdkLogger
from Common.String import *
@ -45,7 +45,7 @@ from Common.MultipleWorkspace import MultipleWorkspace as mws
## Version and Copyright
versionNumber = "1.0" + ' ' + gBUILD_VERSION
__version__ = "%prog Version " + versionNumber
__copyright__ = "Copyright (c) 2007 - 2016, Intel Corporation All rights reserved."
__copyright__ = "Copyright (c) 2007 - 2017, Intel Corporation All rights reserved."
## Tool entrance method
#
@ -424,11 +424,11 @@ def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Val
# @param NameGuid The Guid name
#
def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
ToolDb = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDatabase
# if user not specify filter, try to deduce it from global data.
if KeyStringList == None or KeyStringList == []:
Target = GenFdsGlobalVariable.TargetName
ToolChain = GenFdsGlobalVariable.ToolChainTag
ToolDb = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDatabase
if ToolChain not in ToolDb['TOOL_CHAIN_TAG']:
EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external tool because tool tag %s is not defined in tools_def.txt!" % ToolChain)
KeyStringList = [Target + '_' + ToolChain + '_' + CurrentArchList[0]]
@ -443,6 +443,9 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary
ToolPathTmp = None
ToolOption = None
ToolPathKey = None
ToolOptionKey = None
KeyList = None
for ToolDef in ToolDefinition.items():
if NameGuid == ToolDef[1]:
KeyList = ToolDef[0].split('_')
@ -452,24 +455,55 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
'_' + \
KeyList[2]
if Key in KeyStringList and KeyList[4] == 'GUID':
ToolPath = ToolDefinition.get(Key + \
'_' + \
KeyList[3] + \
'_' + \
'PATH')
ToolOption = ToolDefinition.get(Key + \
'_' + \
KeyList[3] + \
'_' + \
'FLAGS')
ToolPathKey = Key + '_' + KeyList[3] + '_PATH'
ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
ToolPath = ToolDefinition.get(ToolPathKey)
ToolOption = ToolDefinition.get(ToolOptionKey)
if ToolPathTmp == None:
ToolPathTmp = ToolPath
else:
if ToolPathTmp != ToolPath:
EdkLogger.error("GenFds", GENFDS_ERROR, "Don't know which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath))
BuildOption = {}
for Arch in CurrentArchList:
Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
# key is (ToolChainFamily, ToolChain, CodeBase)
for item in Platform.BuildOptions:
if '_PATH' in item[1] or '_FLAGS' in item[1] or '_GUID' in item[1]:
if not item[0] or (item[0] and GenFdsGlobalVariable.ToolChainFamily== item[0]):
if item[1] not in BuildOption:
BuildOption[item[1]] = Platform.BuildOptions[item]
if BuildOption:
ToolList = [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG, TAB_TOD_DEFINES_TARGET_ARCH]
for Index in range(2, -1, -1):
for Key in dict(BuildOption):
List = Key.split('_')
if List[Index] == '*':
for String in ToolDb[ToolList[Index]]:
if String in [Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]:
List[Index] = String
NewKey = '%s_%s_%s_%s_%s' % tuple(List)
if NewKey not in BuildOption:
BuildOption[NewKey] = BuildOption[Key]
continue
del BuildOption[Key]
elif List[Index] not in ToolDb[ToolList[Index]]:
del BuildOption[Key]
if BuildOption:
if not KeyList:
for Op in BuildOption:
if NameGuid == BuildOption[Op]:
KeyList = Op.split('_')
Key = KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2]
if Key in KeyStringList and KeyList[4] == 'GUID':
ToolPathKey = Key + '_' + KeyList[3] + '_PATH'
ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'
if ToolPathKey in BuildOption.keys():
ToolPathTmp = BuildOption.get(ToolPathKey)
if ToolOptionKey in BuildOption.keys():
ToolOption = BuildOption.get(ToolOptionKey)
GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption)
return ToolPathTmp, ToolOption