else:\r
parser.error("Option %s only allows one instance in command line!" % option)\r
\r
-## FindExtendTool()\r
-#\r
-# Find location of tools to process data\r
-#\r
-# @param KeyStringList Filter for inputs of section generation\r
-# @param CurrentArchList Arch list\r
-# @param NameGuid The Guid name\r
-#\r
-def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):\r
- ToolDb = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDatabase\r
- # if user not specify filter, try to deduce it from global data.\r
- if KeyStringList is None or KeyStringList == []:\r
- Target = GenFdsGlobalVariable.TargetName\r
- ToolChain = GenFdsGlobalVariable.ToolChainTag\r
- if ToolChain not in ToolDb['TOOL_CHAIN_TAG']:\r
- EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external tool because tool tag %s is not defined in tools_def.txt!" % ToolChain)\r
- KeyStringList = [Target + '_' + ToolChain + '_' + CurrentArchList[0]]\r
- for Arch in CurrentArchList:\r
- if Target + '_' + ToolChain + '_' + Arch not in KeyStringList:\r
- KeyStringList.append(Target + '_' + ToolChain + '_' + Arch)\r
-\r
- if GenFdsGlobalVariable.GuidToolDefinition:\r
- if NameGuid in GenFdsGlobalVariable.GuidToolDefinition:\r
- return GenFdsGlobalVariable.GuidToolDefinition[NameGuid]\r
-\r
- ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary\r
- ToolPathTmp = None\r
- ToolOption = None\r
- ToolPathKey = None\r
- ToolOptionKey = None\r
- KeyList = None\r
- for ToolDef in ToolDefinition.items():\r
- if NameGuid.lower() == ToolDef[1].lower() :\r
- KeyList = ToolDef[0].split('_')\r
- Key = KeyList[0] + \\r
- '_' + \\r
- KeyList[1] + \\r
- '_' + \\r
- KeyList[2]\r
- if Key in KeyStringList and KeyList[4] == TAB_GUID:\r
- ToolPathKey = Key + '_' + KeyList[3] + '_PATH'\r
- ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'\r
- ToolPath = ToolDefinition.get(ToolPathKey)\r
- ToolOption = ToolDefinition.get(ToolOptionKey)\r
- if ToolPathTmp is None:\r
- ToolPathTmp = ToolPath\r
- else:\r
- if ToolPathTmp != ToolPath:\r
- EdkLogger.error("GenFds", GENFDS_ERROR, "Don't know which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath))\r
-\r
- BuildOption = {}\r
- for Arch in CurrentArchList:\r
- Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
- # key is (ToolChainFamily, ToolChain, CodeBase)\r
- for item in Platform.BuildOptions:\r
- if '_PATH' in item[1] or '_FLAGS' in item[1] or '_GUID' in item[1]:\r
- if not item[0] or (item[0] and GenFdsGlobalVariable.ToolChainFamily== item[0]):\r
- if item[1] not in BuildOption:\r
- BuildOption[item[1]] = Platform.BuildOptions[item]\r
- if BuildOption:\r
- ToolList = [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG, TAB_TOD_DEFINES_TARGET_ARCH]\r
- for Index in range(2, -1, -1):\r
- for Key in list(BuildOption.keys()):\r
- List = Key.split('_')\r
- if List[Index] == '*':\r
- for String in ToolDb[ToolList[Index]]:\r
- if String in [Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]:\r
- List[Index] = String\r
- NewKey = '%s_%s_%s_%s_%s' % tuple(List)\r
- if NewKey not in BuildOption:\r
- BuildOption[NewKey] = BuildOption[Key]\r
- continue\r
- del BuildOption[Key]\r
- elif List[Index] not in ToolDb[ToolList[Index]]:\r
- del BuildOption[Key]\r
- if BuildOption:\r
- if not KeyList:\r
- for Op in BuildOption:\r
- if NameGuid == BuildOption[Op]:\r
- KeyList = Op.split('_')\r
- Key = KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2]\r
- if Key in KeyStringList and KeyList[4] == TAB_GUID:\r
- ToolPathKey = Key + '_' + KeyList[3] + '_PATH'\r
- ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'\r
- if ToolPathKey in BuildOption:\r
- ToolPathTmp = BuildOption[ToolPathKey]\r
- if ToolOptionKey in BuildOption:\r
- ToolOption = BuildOption[ToolOptionKey]\r
-\r
- GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption)\r
- return ToolPathTmp, ToolOption\r
-\r
## Parse command line options\r
#\r
# Using standard Python module optparse to parse command line option of this tool.\r