-def CheckBuildOptionPcd():\r
- for Arch in GenFdsGlobalVariable.ArchList:\r
- PkgList = GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag)\r
- for i, pcd in enumerate(GlobalData.BuildOptionPcd):\r
- if type(pcd) is tuple:\r
- continue\r
- (pcdname, pcdvalue) = pcd.split('=')\r
- if not pcdvalue:\r
- EdkLogger.error('GenFds', OPTION_MISSING, "No Value specified for the PCD %s." % (pcdname))\r
- if '.' in pcdname:\r
- (TokenSpaceGuidCName, TokenCName) = pcdname.split('.')\r
- HasTokenSpace = True\r
- else:\r
- TokenCName = pcdname\r
- TokenSpaceGuidCName = ''\r
- HasTokenSpace = False\r
- TokenSpaceGuidCNameList = []\r
- FoundFlag = False\r
- PcdDatumType = ''\r
- NewValue = ''\r
- for package in PkgList:\r
- for key in package.Pcds:\r
- PcdItem = package.Pcds[key]\r
- if HasTokenSpace:\r
- if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName):\r
- PcdDatumType = PcdItem.DatumType\r
- NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
- FoundFlag = True\r
- else:\r
- if PcdItem.TokenCName == TokenCName:\r
- if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList:\r
- if len (TokenSpaceGuidCNameList) < 1:\r
- TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName)\r
- PcdDatumType = PcdItem.DatumType\r
- TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName\r
- NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
- FoundFlag = True\r
- else:\r
- EdkLogger.error(\r
- 'GenFds',\r
- PCD_VALIDATION_INFO_ERROR,\r
- "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (TokenCName, PcdItem.TokenSpaceGuidCName, TokenSpaceGuidCNameList[0])\r
- )\r
-\r
- GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, NewValue)\r
-\r
-def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Value):\r
- if PcdDatumType == 'VOID*':\r
- if Value.startswith('L'):\r
- if not Value[1]:\r
- EdkLogger.error('GenFds', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"')\r
- Value = Value[0] + '"' + Value[1:] + '"'\r
- elif Value.startswith('B'):\r
- if not Value[1]:\r
- EdkLogger.error('GenFds', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"')\r
- Value = Value[1:]\r
- else:\r
- if not Value[0]:\r
- EdkLogger.error('GenFds', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"')\r
- Value = '"' + Value + '"'\r
-\r
- IsValid, Cause = CheckPcdDatum(PcdDatumType, Value)\r
- if not IsValid:\r
- EdkLogger.error('build', FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName))\r
- if PcdDatumType == 'BOOLEAN':\r
- Value = Value.upper()\r
- if Value == 'TRUE' or Value == '1':\r
- Value = '1'\r
- elif Value == 'FALSE' or Value == '0':\r
- Value = '0'\r
- return Value\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.keys():\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] == '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 dict(BuildOption):\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] == 'GUID':\r
+ ToolPathKey = Key + '_' + KeyList[3] + '_PATH'\r
+ ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'\r
+ if ToolPathKey in BuildOption.keys():\r
+ ToolPathTmp = BuildOption.get(ToolPathKey)\r
+ if ToolOptionKey in BuildOption.keys():\r
+ ToolOption = BuildOption.get(ToolOptionKey)\r
+\r
+ GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption)\r
+ return ToolPathTmp, ToolOption\r