]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
BaseTools: Handle the bytes and str difference
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / GenFdsGlobalVariable.py
... / ...
CommitLineData
1## @file\r
2# Global variables for GenFds\r
3#\r
4# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
5#\r
6# This program and the accompanying materials\r
7# are licensed and made available under the terms and conditions of the BSD License\r
8# which accompanies this distribution. The full text of the license may be found at\r
9# http://opensource.org/licenses/bsd-license.php\r
10#\r
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13#\r
14\r
15##\r
16# Import Modules\r
17#\r
18from __future__ import print_function\r
19from __future__ import absolute_import\r
20\r
21import Common.LongFilePathOs as os\r
22from sys import stdout\r
23from subprocess import PIPE,Popen\r
24from struct import Struct\r
25from array import array\r
26\r
27from Common.BuildToolError import COMMAND_FAILURE,GENFDS_ERROR\r
28from Common import EdkLogger\r
29from Common.Misc import SaveFileOnChange\r
30\r
31from Common.TargetTxtClassObject import TargetTxtClassObject\r
32from Common.ToolDefClassObject import ToolDefClassObject, ToolDefDict\r
33from AutoGen.BuildEngine import BuildRule\r
34import Common.DataType as DataType\r
35from Common.Misc import PathClass\r
36from Common.LongFilePathSupport import OpenLongFilePath as open\r
37from Common.MultipleWorkspace import MultipleWorkspace as mws\r
38\r
39## Global variables\r
40#\r
41#\r
42class GenFdsGlobalVariable:\r
43 FvDir = ''\r
44 OutputDirDict = {}\r
45 BinDir = ''\r
46 # will be FvDir + os.sep + 'Ffs'\r
47 FfsDir = ''\r
48 FdfParser = None\r
49 LibDir = ''\r
50 WorkSpace = None\r
51 WorkSpaceDir = ''\r
52 ConfDir = ''\r
53 OutputDirFromDscDict = {}\r
54 TargetName = ''\r
55 ToolChainTag = ''\r
56 RuleDict = {}\r
57 ArchList = None\r
58 ActivePlatform = None\r
59 FvAddressFileName = ''\r
60 VerboseMode = False\r
61 DebugLevel = -1\r
62 SharpCounter = 0\r
63 SharpNumberPerLine = 40\r
64 FdfFile = ''\r
65 FdfFileTimeStamp = 0\r
66 FixedLoadAddress = False\r
67 PlatformName = ''\r
68\r
69 BuildRuleFamily = DataType.TAB_COMPILER_MSFT\r
70 ToolChainFamily = DataType.TAB_COMPILER_MSFT\r
71 __BuildRuleDatabase = None\r
72 GuidToolDefinition = {}\r
73 FfsCmdDict = {}\r
74 SecCmdList = []\r
75 CopyList = []\r
76 ModuleFile = ''\r
77 EnableGenfdsMultiThread = False\r
78\r
79 #\r
80 # The list whose element are flags to indicate if large FFS or SECTION files exist in FV.\r
81 # At the beginning of each generation of FV, false flag is appended to the list,\r
82 # after the call to GenerateSection returns, check the size of the output file,\r
83 # if it is greater than 0xFFFFFF, the tail flag in list is set to true,\r
84 # and EFI_FIRMWARE_FILE_SYSTEM3_GUID is passed to C GenFv.\r
85 # At the end of generation of FV, pop the flag.\r
86 # List is used as a stack to handle nested FV generation.\r
87 #\r
88 LargeFileInFvFlags = []\r
89 EFI_FIRMWARE_FILE_SYSTEM3_GUID = '5473C07A-3DCB-4dca-BD6F-1E9689E7349A'\r
90 LARGE_FILE_SIZE = 0x1000000\r
91\r
92 SectionHeader = Struct("3B 1B")\r
93\r
94 # FvName, FdName, CapName in FDF, Image file name\r
95 ImageBinDict = {}\r
96\r
97 ## LoadBuildRule\r
98 #\r
99 @staticmethod\r
100 def _LoadBuildRule():\r
101 if GenFdsGlobalVariable.__BuildRuleDatabase:\r
102 return GenFdsGlobalVariable.__BuildRuleDatabase\r
103 BuildConfigurationFile = os.path.normpath(os.path.join(GenFdsGlobalVariable.ConfDir, "target.txt"))\r
104 TargetTxt = TargetTxtClassObject()\r
105 if os.path.isfile(BuildConfigurationFile) == True:\r
106 TargetTxt.LoadTargetTxtFile(BuildConfigurationFile)\r
107 if DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF in TargetTxt.TargetTxtDictionary:\r
108 BuildRuleFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF]\r
109 if not BuildRuleFile:\r
110 BuildRuleFile = 'Conf/build_rule.txt'\r
111 GenFdsGlobalVariable.__BuildRuleDatabase = BuildRule(BuildRuleFile)\r
112 ToolDefinitionFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]\r
113 if ToolDefinitionFile == '':\r
114 ToolDefinitionFile = "Conf/tools_def.txt"\r
115 if os.path.isfile(ToolDefinitionFile):\r
116 ToolDef = ToolDefClassObject()\r
117 ToolDef.LoadToolDefFile(ToolDefinitionFile)\r
118 ToolDefinition = ToolDef.ToolsDefTxtDatabase\r
119 if DataType.TAB_TOD_DEFINES_BUILDRULEFAMILY in ToolDefinition \\r
120 and GenFdsGlobalVariable.ToolChainTag in ToolDefinition[DataType.TAB_TOD_DEFINES_BUILDRULEFAMILY] \\r
121 and ToolDefinition[DataType.TAB_TOD_DEFINES_BUILDRULEFAMILY][GenFdsGlobalVariable.ToolChainTag]:\r
122 GenFdsGlobalVariable.BuildRuleFamily = ToolDefinition[DataType.TAB_TOD_DEFINES_BUILDRULEFAMILY][GenFdsGlobalVariable.ToolChainTag]\r
123\r
124 if DataType.TAB_TOD_DEFINES_FAMILY in ToolDefinition \\r
125 and GenFdsGlobalVariable.ToolChainTag in ToolDefinition[DataType.TAB_TOD_DEFINES_FAMILY] \\r
126 and ToolDefinition[DataType.TAB_TOD_DEFINES_FAMILY][GenFdsGlobalVariable.ToolChainTag]:\r
127 GenFdsGlobalVariable.ToolChainFamily = ToolDefinition[DataType.TAB_TOD_DEFINES_FAMILY][GenFdsGlobalVariable.ToolChainTag]\r
128 return GenFdsGlobalVariable.__BuildRuleDatabase\r
129\r
130 ## GetBuildRules\r
131 # @param Inf: object of InfBuildData\r
132 # @param Arch: current arch\r
133 #\r
134 @staticmethod\r
135 def GetBuildRules(Inf, Arch):\r
136 if not Arch:\r
137 Arch = DataType.TAB_COMMON\r
138\r
139 if not Arch in GenFdsGlobalVariable.OutputDirDict:\r
140 return {}\r
141\r
142 BuildRuleDatabase = GenFdsGlobalVariable._LoadBuildRule()\r
143 if not BuildRuleDatabase:\r
144 return {}\r
145\r
146 PathClassObj = PathClass(Inf.MetaFile.File,\r
147 GenFdsGlobalVariable.WorkSpaceDir)\r
148 BuildDir = os.path.join(\r
149 GenFdsGlobalVariable.OutputDirDict[Arch],\r
150 Arch,\r
151 PathClassObj.SubDir,\r
152 PathClassObj.BaseName\r
153 )\r
154 BinDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[Arch], Arch)\r
155 Macro = {\r
156 "WORKSPACE":GenFdsGlobalVariable.WorkSpaceDir,\r
157 "MODULE_NAME":Inf.BaseName,\r
158 "MODULE_GUID":Inf.Guid,\r
159 "MODULE_VERSION":Inf.Version,\r
160 "MODULE_TYPE":Inf.ModuleType,\r
161 "MODULE_FILE":str(PathClassObj),\r
162 "MODULE_FILE_BASE_NAME":PathClassObj.BaseName,\r
163 "MODULE_RELATIVE_DIR":PathClassObj.SubDir,\r
164 "MODULE_DIR":PathClassObj.SubDir,\r
165 "BASE_NAME":Inf.BaseName,\r
166 "ARCH":Arch,\r
167 "TOOLCHAIN":GenFdsGlobalVariable.ToolChainTag,\r
168 "TOOLCHAIN_TAG":GenFdsGlobalVariable.ToolChainTag,\r
169 "TOOL_CHAIN_TAG":GenFdsGlobalVariable.ToolChainTag,\r
170 "TARGET":GenFdsGlobalVariable.TargetName,\r
171 "BUILD_DIR":GenFdsGlobalVariable.OutputDirDict[Arch],\r
172 "BIN_DIR":BinDir,\r
173 "LIB_DIR":BinDir,\r
174 "MODULE_BUILD_DIR":BuildDir,\r
175 "OUTPUT_DIR":os.path.join(BuildDir, "OUTPUT"),\r
176 "DEBUG_DIR":os.path.join(BuildDir, "DEBUG")\r
177 }\r
178 \r
179 BuildRules = {}\r
180 for Type in BuildRuleDatabase.FileTypeList:\r
181 #first try getting build rule by BuildRuleFamily\r
182 RuleObject = BuildRuleDatabase[Type, Inf.BuildType, Arch, GenFdsGlobalVariable.BuildRuleFamily]\r
183 if not RuleObject:\r
184 # build type is always module type, but ...\r
185 if Inf.ModuleType != Inf.BuildType:\r
186 RuleObject = BuildRuleDatabase[Type, Inf.ModuleType, Arch, GenFdsGlobalVariable.BuildRuleFamily]\r
187 #second try getting build rule by ToolChainFamily\r
188 if not RuleObject:\r
189 RuleObject = BuildRuleDatabase[Type, Inf.BuildType, Arch, GenFdsGlobalVariable.ToolChainFamily]\r
190 if not RuleObject:\r
191 # build type is always module type, but ...\r
192 if Inf.ModuleType != Inf.BuildType:\r
193 RuleObject = BuildRuleDatabase[Type, Inf.ModuleType, Arch, GenFdsGlobalVariable.ToolChainFamily]\r
194 if not RuleObject:\r
195 continue\r
196 RuleObject = RuleObject.Instantiate(Macro)\r
197 BuildRules[Type] = RuleObject\r
198 for Ext in RuleObject.SourceFileExtList:\r
199 BuildRules[Ext] = RuleObject\r
200 return BuildRules\r
201\r
202 ## GetModuleCodaTargetList\r
203 #\r
204 # @param Inf: object of InfBuildData\r
205 # @param Arch: current arch\r
206 #\r
207 @staticmethod\r
208 def GetModuleCodaTargetList(Inf, Arch):\r
209 BuildRules = GenFdsGlobalVariable.GetBuildRules(Inf, Arch)\r
210 if not BuildRules:\r
211 return []\r
212\r
213 TargetList = set()\r
214 FileList = []\r
215\r
216 if not Inf.IsBinaryModule:\r
217 for File in Inf.Sources:\r
218 if File.TagName in {"", DataType.TAB_STAR, GenFdsGlobalVariable.ToolChainTag} and \\r
219 File.ToolChainFamily in {"", DataType.TAB_STAR, GenFdsGlobalVariable.ToolChainFamily}:\r
220 FileList.append((File, DataType.TAB_UNKNOWN_FILE))\r
221\r
222 for File in Inf.Binaries:\r
223 if File.Target in {DataType.TAB_COMMON, DataType.TAB_STAR, GenFdsGlobalVariable.TargetName}:\r
224 FileList.append((File, File.Type))\r
225\r
226 for File, FileType in FileList:\r
227 LastTarget = None\r
228 RuleChain = []\r
229 SourceList = [File]\r
230 Index = 0\r
231 while Index < len(SourceList):\r
232 Source = SourceList[Index]\r
233 Index = Index + 1\r
234\r
235 if File.IsBinary and File == Source and Inf.Binaries and File in Inf.Binaries:\r
236 # Skip all files that are not binary libraries\r
237 if not Inf.LibraryClass:\r
238 continue\r
239 RuleObject = BuildRules[DataType.TAB_DEFAULT_BINARY_FILE]\r
240 elif FileType in BuildRules:\r
241 RuleObject = BuildRules[FileType]\r
242 elif Source.Ext in BuildRules:\r
243 RuleObject = BuildRules[Source.Ext]\r
244 else:\r
245 # stop at no more rules\r
246 if LastTarget:\r
247 TargetList.add(str(LastTarget))\r
248 break\r
249\r
250 FileType = RuleObject.SourceFileType\r
251\r
252 # stop at STATIC_LIBRARY for library\r
253 if Inf.LibraryClass and FileType == DataType.TAB_STATIC_LIBRARY:\r
254 if LastTarget:\r
255 TargetList.add(str(LastTarget))\r
256 break\r
257\r
258 Target = RuleObject.Apply(Source)\r
259 if not Target:\r
260 if LastTarget:\r
261 TargetList.add(str(LastTarget))\r
262 break\r
263 elif not Target.Outputs:\r
264 # Only do build for target with outputs\r
265 TargetList.add(str(Target))\r
266\r
267 # to avoid cyclic rule\r
268 if FileType in RuleChain:\r
269 break\r
270\r
271 RuleChain.append(FileType)\r
272 SourceList.extend(Target.Outputs)\r
273 LastTarget = Target\r
274 FileType = DataType.TAB_UNKNOWN_FILE\r
275 for Cmd in Target.Commands:\r
276 if "$(CP)" == Cmd.split()[0]:\r
277 CpTarget = Cmd.split()[2]\r
278 TargetList.add(CpTarget)\r
279\r
280 return list(TargetList)\r
281\r
282 ## SetDir()\r
283 #\r
284 # @param OutputDir Output directory\r
285 # @param FdfParser FDF contents parser\r
286 # @param Workspace The directory of workspace\r
287 # @param ArchList The Arch list of platform\r
288 #\r
289 @staticmethod\r
290 def SetDir (OutputDir, FdfParser, WorkSpace, ArchList):\r
291 GenFdsGlobalVariable.VerboseLogger("GenFdsGlobalVariable.OutputDir:%s" % OutputDir)\r
292 GenFdsGlobalVariable.FdfParser = FdfParser\r
293 GenFdsGlobalVariable.WorkSpace = WorkSpace\r
294 GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], DataType.TAB_FV_DIRECTORY)\r
295 if not os.path.exists(GenFdsGlobalVariable.FvDir):\r
296 os.makedirs(GenFdsGlobalVariable.FvDir)\r
297 GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')\r
298 if not os.path.exists(GenFdsGlobalVariable.FfsDir):\r
299 os.makedirs(GenFdsGlobalVariable.FfsDir)\r
300\r
301 #\r
302 # Create FV Address inf file\r
303 #\r
304 GenFdsGlobalVariable.FvAddressFileName = os.path.join(GenFdsGlobalVariable.FfsDir, 'FvAddress.inf')\r
305 FvAddressFile = open(GenFdsGlobalVariable.FvAddressFileName, 'w')\r
306 #\r
307 # Add [Options]\r
308 #\r
309 FvAddressFile.writelines("[options]" + DataType.TAB_LINE_BREAK)\r
310 BsAddress = '0'\r
311 for Arch in ArchList:\r
312 if GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].BsBaseAddress:\r
313 BsAddress = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].BsBaseAddress\r
314 break\r
315\r
316 FvAddressFile.writelines("EFI_BOOT_DRIVER_BASE_ADDRESS = " + \\r
317 BsAddress + \\r
318 DataType.TAB_LINE_BREAK)\r
319\r
320 RtAddress = '0'\r
321 for Arch in reversed(ArchList):\r
322 temp = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].RtBaseAddress\r
323 if temp:\r
324 RtAddress = temp\r
325 break\r
326\r
327 FvAddressFile.writelines("EFI_RUNTIME_DRIVER_BASE_ADDRESS = " + \\r
328 RtAddress + \\r
329 DataType.TAB_LINE_BREAK)\r
330\r
331 FvAddressFile.close()\r
332\r
333 @staticmethod\r
334 def SetEnv(FdfParser, WorkSpace, ArchList, GlobalData):\r
335 GenFdsGlobalVariable.ModuleFile = WorkSpace.ModuleFile\r
336 GenFdsGlobalVariable.FdfParser = FdfParser\r
337 GenFdsGlobalVariable.WorkSpace = WorkSpace.Db\r
338 GenFdsGlobalVariable.ArchList = ArchList\r
339 GenFdsGlobalVariable.ToolChainTag = GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]\r
340 GenFdsGlobalVariable.TargetName = GlobalData.gGlobalDefines["TARGET"]\r
341 GenFdsGlobalVariable.ActivePlatform = GlobalData.gActivePlatform\r
342 GenFdsGlobalVariable.ConfDir = GlobalData.gConfDirectory\r
343 GenFdsGlobalVariable.EnableGenfdsMultiThread = GlobalData.gEnableGenfdsMultiThread\r
344 for Arch in ArchList:\r
345 GenFdsGlobalVariable.OutputDirDict[Arch] = os.path.normpath(\r
346 os.path.join(GlobalData.gWorkspace,\r
347 WorkSpace.Db.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GlobalData.gGlobalDefines['TARGET'],\r
348 GlobalData.gGlobalDefines['TOOLCHAIN']].OutputDirectory,\r
349 GlobalData.gGlobalDefines['TARGET'] +'_' + GlobalData.gGlobalDefines['TOOLCHAIN']))\r
350 GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = os.path.normpath(\r
351 WorkSpace.Db.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch,\r
352 GlobalData.gGlobalDefines['TARGET'], GlobalData.gGlobalDefines['TOOLCHAIN']].OutputDirectory)\r
353 GenFdsGlobalVariable.PlatformName = WorkSpace.Db.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch,\r
354 GlobalData.gGlobalDefines['TARGET'],\r
355 GlobalData.gGlobalDefines['TOOLCHAIN']].PlatformName\r
356 GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], DataType.TAB_FV_DIRECTORY)\r
357 if not os.path.exists(GenFdsGlobalVariable.FvDir):\r
358 os.makedirs(GenFdsGlobalVariable.FvDir)\r
359 GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')\r
360 if not os.path.exists(GenFdsGlobalVariable.FfsDir):\r
361 os.makedirs(GenFdsGlobalVariable.FfsDir)\r
362\r
363 #\r
364 # Create FV Address inf file\r
365 #\r
366 GenFdsGlobalVariable.FvAddressFileName = os.path.join(GenFdsGlobalVariable.FfsDir, 'FvAddress.inf')\r
367 FvAddressFile = open(GenFdsGlobalVariable.FvAddressFileName, 'w')\r
368 #\r
369 # Add [Options]\r
370 #\r
371 FvAddressFile.writelines("[options]" + DataType.TAB_LINE_BREAK)\r
372 BsAddress = '0'\r
373 for Arch in ArchList:\r
374 BsAddress = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch,\r
375 GlobalData.gGlobalDefines['TARGET'],\r
376 GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]].BsBaseAddress\r
377 if BsAddress:\r
378 break\r
379\r
380 FvAddressFile.writelines("EFI_BOOT_DRIVER_BASE_ADDRESS = " + \\r
381 BsAddress + \\r
382 DataType.TAB_LINE_BREAK)\r
383\r
384 RtAddress = '0'\r
385 for Arch in reversed(ArchList):\r
386 temp = GenFdsGlobalVariable.WorkSpace.BuildObject[\r
387 GenFdsGlobalVariable.ActivePlatform, Arch, GlobalData.gGlobalDefines['TARGET'],\r
388 GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]].RtBaseAddress\r
389 if temp:\r
390 RtAddress = temp\r
391 break\r
392\r
393 FvAddressFile.writelines("EFI_RUNTIME_DRIVER_BASE_ADDRESS = " + \\r
394 RtAddress + \\r
395 DataType.TAB_LINE_BREAK)\r
396\r
397 FvAddressFile.close()\r
398\r
399 ## ReplaceWorkspaceMacro()\r
400 #\r
401 # @param String String that may contain macro\r
402 #\r
403 @staticmethod\r
404 def ReplaceWorkspaceMacro(String):\r
405 String = mws.handleWsMacro(String)\r
406 Str = String.replace('$(WORKSPACE)', GenFdsGlobalVariable.WorkSpaceDir)\r
407 if os.path.exists(Str):\r
408 if not os.path.isabs(Str):\r
409 Str = os.path.abspath(Str)\r
410 else:\r
411 Str = mws.join(GenFdsGlobalVariable.WorkSpaceDir, String)\r
412 return os.path.normpath(Str)\r
413\r
414 ## Check if the input files are newer than output files\r
415 #\r
416 # @param Output Path of output file\r
417 # @param Input Path list of input files\r
418 #\r
419 # @retval True if Output doesn't exist, or any Input is newer\r
420 # @retval False if all Input is older than Output\r
421 #\r
422 @staticmethod\r
423 def NeedsUpdate(Output, Input):\r
424 if not os.path.exists(Output):\r
425 return True\r
426 # always update "Output" if no "Input" given\r
427 if not Input:\r
428 return True\r
429\r
430 # if fdf file is changed after the 'Output" is generated, update the 'Output'\r
431 OutputTime = os.path.getmtime(Output)\r
432 if GenFdsGlobalVariable.FdfFileTimeStamp > OutputTime:\r
433 return True\r
434\r
435 for F in Input:\r
436 # always update "Output" if any "Input" doesn't exist\r
437 if not os.path.exists(F):\r
438 return True\r
439 # always update "Output" if any "Input" is newer than "Output"\r
440 if os.path.getmtime(F) > OutputTime:\r
441 return True\r
442 return False\r
443\r
444 @staticmethod\r
445 def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None,\r
446 GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=[], BuildNumber=None, DummyFile=None, IsMakefile=False):\r
447 Cmd = ["GenSec"]\r
448 if Type:\r
449 Cmd += ("-s", Type)\r
450 if CompressionType:\r
451 Cmd += ("-c", CompressionType)\r
452 if Guid:\r
453 Cmd += ("-g", Guid)\r
454 if DummyFile:\r
455 Cmd += ("--dummy", DummyFile)\r
456 if GuidHdrLen:\r
457 Cmd += ("-l", GuidHdrLen)\r
458 #Add each guided attribute\r
459 for Attr in GuidAttr:\r
460 Cmd += ("-r", Attr)\r
461 #Section Align is only for dummy section without section type\r
462 for SecAlign in InputAlign:\r
463 Cmd += ("--sectionalign", SecAlign)\r
464\r
465 CommandFile = Output + '.txt'\r
466 if Ui:\r
467 if IsMakefile:\r
468 if Ui == "$(MODULE_NAME)":\r
469 Cmd += ('-n', Ui)\r
470 else:\r
471 Cmd += ("-n", '"' + Ui + '"')\r
472 Cmd += ("-o", Output)\r
473 if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
474 GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())\r
475 else:\r
476 SectionData = array('B', [0, 0, 0, 0])\r
477 SectionData.fromstring(Ui.encode("utf_16_le"))\r
478 SectionData.append(0)\r
479 SectionData.append(0)\r
480 Len = len(SectionData)\r
481 GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15)\r
482 SaveFileOnChange(Output, SectionData.tostring())\r
483\r
484 elif Ver:\r
485 Cmd += ("-n", Ver)\r
486 if BuildNumber:\r
487 Cmd += ("-j", BuildNumber)\r
488 Cmd += ("-o", Output)\r
489\r
490 SaveFileOnChange(CommandFile, ' '.join(Cmd), False)\r
491 if IsMakefile:\r
492 if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
493 GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())\r
494 else:\r
495 if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):\r
496 return\r
497 GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")\r
498 else:\r
499 Cmd += ("-o", Output)\r
500 Cmd += Input\r
501\r
502 SaveFileOnChange(CommandFile, ' '.join(Cmd), False)\r
503 if IsMakefile:\r
504 if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
505 GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip())\r
506 elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):\r
507 GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))\r
508 GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")\r
509 if (os.path.getsize(Output) >= GenFdsGlobalVariable.LARGE_FILE_SIZE and\r
510 GenFdsGlobalVariable.LargeFileInFvFlags):\r
511 GenFdsGlobalVariable.LargeFileInFvFlags[-1] = True\r
512\r
513 @staticmethod\r
514 def GetAlignment (AlignString):\r
515 if not AlignString:\r
516 return 0\r
517 if AlignString.endswith('K'):\r
518 return int (AlignString.rstrip('K')) * 1024\r
519 if AlignString.endswith('M'):\r
520 return int (AlignString.rstrip('M')) * 1024 * 1024\r
521 if AlignString.endswith('G'):\r
522 return int (AlignString.rstrip('G')) * 1024 * 1024 * 1024\r
523 return int (AlignString)\r
524\r
525 @staticmethod\r
526 def GenerateFfs(Output, Input, Type, Guid, Fixed=False, CheckSum=False, Align=None,\r
527 SectionAlign=None, MakefilePath=None):\r
528 Cmd = ["GenFfs", "-t", Type, "-g", Guid]\r
529 mFfsValidAlign = ["0", "8", "16", "128", "512", "1K", "4K", "32K", "64K", "128K", "256K", "512K", "1M", "2M", "4M", "8M", "16M"]\r
530 if Fixed == True:\r
531 Cmd.append("-x")\r
532 if CheckSum:\r
533 Cmd.append("-s")\r
534 if Align:\r
535 if Align not in mFfsValidAlign:\r
536 Align = GenFdsGlobalVariable.GetAlignment (Align)\r
537 for index in range(0, len(mFfsValidAlign) - 1):\r
538 if ((Align > GenFdsGlobalVariable.GetAlignment(mFfsValidAlign[index])) and (Align <= GenFdsGlobalVariable.GetAlignment(mFfsValidAlign[index + 1]))):\r
539 break\r
540 Align = mFfsValidAlign[index + 1]\r
541 Cmd += ("-a", Align)\r
542\r
543 Cmd += ("-o", Output)\r
544 for I in range(0, len(Input)):\r
545 Cmd += ("-i", Input[I])\r
546 if SectionAlign and SectionAlign[I]:\r
547 Cmd += ("-n", SectionAlign[I])\r
548\r
549 CommandFile = Output + '.txt'\r
550 SaveFileOnChange(CommandFile, ' '.join(Cmd), False)\r
551\r
552 GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))\r
553 if MakefilePath:\r
554 if (tuple(Cmd), tuple(GenFdsGlobalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict:\r
555 GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple(GenFdsGlobalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)] = MakefilePath\r
556 GenFdsGlobalVariable.SecCmdList = []\r
557 GenFdsGlobalVariable.CopyList = []\r
558 else:\r
559 if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]):\r
560 return\r
561 GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FFS")\r
562\r
563 @staticmethod\r
564 def GenerateFirmwareVolume(Output, Input, BaseAddress=None, ForceRebase=None, Capsule=False, Dump=False,\r
565 AddressFile=None, MapFile=None, FfsList=[], FileSystemGuid=None):\r
566 if not GenFdsGlobalVariable.NeedsUpdate(Output, Input+FfsList):\r
567 return\r
568 GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))\r
569\r
570 Cmd = ["GenFv"]\r
571 if BaseAddress:\r
572 Cmd += ("-r", BaseAddress)\r
573\r
574 if ForceRebase == False:\r
575 Cmd += ("-F", "FALSE")\r
576 elif ForceRebase == True:\r
577 Cmd += ("-F", "TRUE")\r
578\r
579 if Capsule:\r
580 Cmd.append("-c")\r
581 if Dump:\r
582 Cmd.append("-p")\r
583 if AddressFile:\r
584 Cmd += ("-a", AddressFile)\r
585 if MapFile:\r
586 Cmd += ("-m", MapFile)\r
587 if FileSystemGuid:\r
588 Cmd += ("-g", FileSystemGuid)\r
589 Cmd += ("-o", Output)\r
590 for I in Input:\r
591 Cmd += ("-i", I)\r
592\r
593 GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FV")\r
594\r
595 @staticmethod\r
596 def GenerateFirmwareImage(Output, Input, Type="efi", SubType=None, Zero=False,\r
597 Strip=False, Replace=False, TimeStamp=None, Join=False,\r
598 Align=None, Padding=None, Convert=False, IsMakefile=False):\r
599 if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsMakefile:\r
600 return\r
601 GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))\r
602\r
603 Cmd = ["GenFw"]\r
604 if Type.lower() == "te":\r
605 Cmd.append("-t")\r
606 if SubType:\r
607 Cmd += ("-e", SubType)\r
608 if TimeStamp:\r
609 Cmd += ("-s", TimeStamp)\r
610 if Align:\r
611 Cmd += ("-a", Align)\r
612 if Padding:\r
613 Cmd += ("-p", Padding)\r
614 if Zero:\r
615 Cmd.append("-z")\r
616 if Strip:\r
617 Cmd.append("-l")\r
618 if Replace:\r
619 Cmd.append("-r")\r
620 if Join:\r
621 Cmd.append("-j")\r
622 if Convert:\r
623 Cmd.append("-m")\r
624 Cmd += ("-o", Output)\r
625 Cmd += Input\r
626 if IsMakefile:\r
627 if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
628 GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip())\r
629 else:\r
630 GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate firmware image")\r
631\r
632 @staticmethod\r
633 def GenerateOptionRom(Output, EfiInput, BinaryInput, Compress=False, ClassCode=None,\r
634 Revision=None, DeviceId=None, VendorId=None, IsMakefile=False):\r
635 InputList = []\r
636 Cmd = ["EfiRom"]\r
637 if EfiInput:\r
638\r
639 if Compress:\r
640 Cmd.append("-ec")\r
641 else:\r
642 Cmd.append("-e")\r
643\r
644 for EfiFile in EfiInput:\r
645 Cmd.append(EfiFile)\r
646 InputList.append (EfiFile)\r
647\r
648 if BinaryInput:\r
649 Cmd.append("-b")\r
650 for BinFile in BinaryInput:\r
651 Cmd.append(BinFile)\r
652 InputList.append (BinFile)\r
653\r
654 # Check List\r
655 if not GenFdsGlobalVariable.NeedsUpdate(Output, InputList) and not IsMakefile:\r
656 return\r
657 GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, InputList))\r
658\r
659 if ClassCode:\r
660 Cmd += ("-l", ClassCode)\r
661 if Revision:\r
662 Cmd += ("-r", Revision)\r
663 if DeviceId:\r
664 Cmd += ("-i", DeviceId)\r
665 if VendorId:\r
666 Cmd += ("-f", VendorId)\r
667\r
668 Cmd += ("-o", Output)\r
669 if IsMakefile:\r
670 if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
671 GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip())\r
672 else:\r
673 GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate option rom")\r
674\r
675 @staticmethod\r
676 def GuidTool(Output, Input, ToolPath, Options='', returnValue=[], IsMakefile=False):\r
677 if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsMakefile:\r
678 return\r
679 GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))\r
680\r
681 Cmd = [ToolPath, ]\r
682 Cmd += Options.split(' ')\r
683 Cmd += ("-o", Output)\r
684 Cmd += Input\r
685 if IsMakefile:\r
686 if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:\r
687 GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip())\r
688 else:\r
689 GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to call " + ToolPath, returnValue)\r
690\r
691 @staticmethod\r
692 def CallExternalTool (cmd, errorMess, returnValue=[]):\r
693\r
694 if type(cmd) not in (tuple, list):\r
695 GenFdsGlobalVariable.ErrorLogger("ToolError! Invalid parameter type in call to CallExternalTool")\r
696\r
697 if GenFdsGlobalVariable.DebugLevel != -1:\r
698 cmd += ('--debug', str(GenFdsGlobalVariable.DebugLevel))\r
699 GenFdsGlobalVariable.InfLogger (cmd)\r
700\r
701 if GenFdsGlobalVariable.VerboseMode:\r
702 cmd += ('-v',)\r
703 GenFdsGlobalVariable.InfLogger (cmd)\r
704 else:\r
705 stdout.write ('#')\r
706 stdout.flush()\r
707 GenFdsGlobalVariable.SharpCounter = GenFdsGlobalVariable.SharpCounter + 1\r
708 if GenFdsGlobalVariable.SharpCounter % GenFdsGlobalVariable.SharpNumberPerLine == 0:\r
709 stdout.write('\n')\r
710\r
711 try:\r
712 PopenObject = Popen(' '.join(cmd), stdout=PIPE, stderr=PIPE, shell=True)\r
713 except Exception as X:\r
714 EdkLogger.error("GenFds", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))\r
715 (out, error) = PopenObject.communicate()\r
716\r
717 while PopenObject.returncode is None:\r
718 PopenObject.wait()\r
719 if returnValue != [] and returnValue[0] != 0:\r
720 #get command return value\r
721 returnValue[0] = PopenObject.returncode\r
722 return\r
723 if PopenObject.returncode != 0 or GenFdsGlobalVariable.VerboseMode or GenFdsGlobalVariable.DebugLevel != -1:\r
724 GenFdsGlobalVariable.InfLogger ("Return Value = %d" % PopenObject.returncode)\r
725 GenFdsGlobalVariable.InfLogger(out.decode(encoding='utf-8', errors='ignore'))\r
726 GenFdsGlobalVariable.InfLogger(error.decode(encoding='utf-8', errors='ignore'))\r
727 if PopenObject.returncode != 0:\r
728 print("###", cmd)\r
729 EdkLogger.error("GenFds", COMMAND_FAILURE, errorMess)\r
730\r
731 @staticmethod\r
732 def VerboseLogger (msg):\r
733 EdkLogger.verbose(msg)\r
734\r
735 @staticmethod\r
736 def InfLogger (msg):\r
737 EdkLogger.info(msg)\r
738\r
739 @staticmethod\r
740 def ErrorLogger (msg, File=None, Line=None, ExtraData=None):\r
741 EdkLogger.error('GenFds', GENFDS_ERROR, msg, File, Line, ExtraData)\r
742\r
743 @staticmethod\r
744 def DebugLogger (Level, msg):\r
745 EdkLogger.debug(Level, msg)\r
746\r
747 ## MacroExtend()\r
748 #\r
749 # @param Str String that may contain macro\r
750 # @param MacroDict Dictionary that contains macro value pair\r
751 #\r
752 @staticmethod\r
753 def MacroExtend (Str, MacroDict={}, Arch=DataType.TAB_COMMON):\r
754 if Str is None:\r
755 return None\r
756\r
757 Dict = {'$(WORKSPACE)': GenFdsGlobalVariable.WorkSpaceDir,\r
758# '$(OUTPUT_DIRECTORY)': GenFdsGlobalVariable.OutputDirFromDsc,\r
759 '$(TARGET)': GenFdsGlobalVariable.TargetName,\r
760 '$(TOOL_CHAIN_TAG)': GenFdsGlobalVariable.ToolChainTag,\r
761 '$(SPACE)': ' '\r
762 }\r
763\r
764 if Arch != DataType.TAB_COMMON and Arch in GenFdsGlobalVariable.ArchList:\r
765 OutputDir = GenFdsGlobalVariable.OutputDirFromDscDict[Arch]\r
766 else:\r
767 OutputDir = GenFdsGlobalVariable.OutputDirFromDscDict[GenFdsGlobalVariable.ArchList[0]]\r
768\r
769 Dict['$(OUTPUT_DIRECTORY)'] = OutputDir\r
770\r
771 if MacroDict:\r
772 Dict.update(MacroDict)\r
773\r
774 for key in Dict:\r
775 if Str.find(key) >= 0:\r
776 Str = Str.replace (key, Dict[key])\r
777\r
778 if Str.find('$(ARCH)') >= 0:\r
779 if len(GenFdsGlobalVariable.ArchList) == 1:\r
780 Str = Str.replace('$(ARCH)', GenFdsGlobalVariable.ArchList[0])\r
781 else:\r
782 EdkLogger.error("GenFds", GENFDS_ERROR, "No way to determine $(ARCH) for %s" % Str)\r
783\r
784 return Str\r
785\r
786 ## GetPcdValue()\r
787 #\r
788 # @param PcdPattern pattern that labels a PCD.\r
789 #\r
790 @staticmethod\r
791 def GetPcdValue (PcdPattern):\r
792 if PcdPattern is None:\r
793 return None\r
794 PcdPair = PcdPattern.lstrip('PCD(').rstrip(')').strip().split('.')\r
795 TokenSpace = PcdPair[0]\r
796 TokenCName = PcdPair[1]\r
797\r
798 for Arch in GenFdsGlobalVariable.ArchList:\r
799 Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
800 PcdDict = Platform.Pcds\r
801 for Key in PcdDict:\r
802 PcdObj = PcdDict[Key]\r
803 if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):\r
804 if PcdObj.Type != DataType.TAB_PCDS_FIXED_AT_BUILD:\r
805 EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)\r
806 if PcdObj.DatumType != DataType.TAB_VOID:\r
807 EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern)\r
808\r
809 return PcdObj.DefaultValue\r
810\r
811 for Package in GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform,\r
812 Arch,\r
813 GenFdsGlobalVariable.TargetName,\r
814 GenFdsGlobalVariable.ToolChainTag):\r
815 PcdDict = Package.Pcds\r
816 for Key in PcdDict:\r
817 PcdObj = PcdDict[Key]\r
818 if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):\r
819 if PcdObj.Type != DataType.TAB_PCDS_FIXED_AT_BUILD:\r
820 EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)\r
821 if PcdObj.DatumType != DataType.TAB_VOID:\r
822 EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern)\r
823\r
824 return PcdObj.DefaultValue\r
825\r
826 return ''\r
827\r
828## FindExtendTool()\r
829#\r
830# Find location of tools to process data\r
831#\r
832# @param KeyStringList Filter for inputs of section generation\r
833# @param CurrentArchList Arch list\r
834# @param NameGuid The Guid name\r
835#\r
836def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):\r
837 ToolDb = ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDatabase\r
838 # if user not specify filter, try to deduce it from global data.\r
839 if KeyStringList is None or KeyStringList == []:\r
840 Target = GenFdsGlobalVariable.TargetName\r
841 ToolChain = GenFdsGlobalVariable.ToolChainTag\r
842 if ToolChain not in ToolDb['TOOL_CHAIN_TAG']:\r
843 EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external tool because tool tag %s is not defined in tools_def.txt!" % ToolChain)\r
844 KeyStringList = [Target + '_' + ToolChain + '_' + CurrentArchList[0]]\r
845 for Arch in CurrentArchList:\r
846 if Target + '_' + ToolChain + '_' + Arch not in KeyStringList:\r
847 KeyStringList.append(Target + '_' + ToolChain + '_' + Arch)\r
848\r
849 if GenFdsGlobalVariable.GuidToolDefinition:\r
850 if NameGuid in GenFdsGlobalVariable.GuidToolDefinition:\r
851 return GenFdsGlobalVariable.GuidToolDefinition[NameGuid]\r
852\r
853 ToolDefinition = ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary\r
854 ToolPathTmp = None\r
855 ToolOption = None\r
856 ToolPathKey = None\r
857 ToolOptionKey = None\r
858 KeyList = None\r
859 for ToolDef in ToolDefinition.items():\r
860 if NameGuid.lower() == ToolDef[1].lower():\r
861 KeyList = ToolDef[0].split('_')\r
862 Key = KeyList[0] + \\r
863 '_' + \\r
864 KeyList[1] + \\r
865 '_' + \\r
866 KeyList[2]\r
867 if Key in KeyStringList and KeyList[4] == DataType.TAB_GUID:\r
868 ToolPathKey = Key + '_' + KeyList[3] + '_PATH'\r
869 ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'\r
870 ToolPath = ToolDefinition.get(ToolPathKey)\r
871 ToolOption = ToolDefinition.get(ToolOptionKey)\r
872 if ToolPathTmp is None:\r
873 ToolPathTmp = ToolPath\r
874 else:\r
875 if ToolPathTmp != ToolPath:\r
876 EdkLogger.error("GenFds", GENFDS_ERROR, "Don't know which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath))\r
877\r
878 BuildOption = {}\r
879 for Arch in CurrentArchList:\r
880 Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
881 # key is (ToolChainFamily, ToolChain, CodeBase)\r
882 for item in Platform.BuildOptions:\r
883 if '_PATH' in item[1] or '_FLAGS' in item[1] or '_GUID' in item[1]:\r
884 if not item[0] or (item[0] and GenFdsGlobalVariable.ToolChainFamily== item[0]):\r
885 if item[1] not in BuildOption:\r
886 BuildOption[item[1]] = Platform.BuildOptions[item]\r
887 if BuildOption:\r
888 ToolList = [DataType.TAB_TOD_DEFINES_TARGET, DataType.TAB_TOD_DEFINES_TOOL_CHAIN_TAG, DataType.TAB_TOD_DEFINES_TARGET_ARCH]\r
889 for Index in range(2, -1, -1):\r
890 for Key in list(BuildOption.keys()):\r
891 List = Key.split('_')\r
892 if List[Index] == DataType.TAB_STAR:\r
893 for String in ToolDb[ToolList[Index]]:\r
894 if String in [Arch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]:\r
895 List[Index] = String\r
896 NewKey = '%s_%s_%s_%s_%s' % tuple(List)\r
897 if NewKey not in BuildOption:\r
898 BuildOption[NewKey] = BuildOption[Key]\r
899 continue\r
900 del BuildOption[Key]\r
901 elif List[Index] not in ToolDb[ToolList[Index]]:\r
902 del BuildOption[Key]\r
903 if BuildOption:\r
904 if not KeyList:\r
905 for Op in BuildOption:\r
906 if NameGuid == BuildOption[Op]:\r
907 KeyList = Op.split('_')\r
908 Key = KeyList[0] + '_' + KeyList[1] +'_' + KeyList[2]\r
909 if Key in KeyStringList and KeyList[4] == DataType.TAB_GUID:\r
910 ToolPathKey = Key + '_' + KeyList[3] + '_PATH'\r
911 ToolOptionKey = Key + '_' + KeyList[3] + '_FLAGS'\r
912 if ToolPathKey in BuildOption:\r
913 ToolPathTmp = BuildOption[ToolPathKey]\r
914 if ToolOptionKey in BuildOption:\r
915 ToolOption = BuildOption[ToolOptionKey]\r
916\r
917 GenFdsGlobalVariable.GuidToolDefinition[NameGuid] = (ToolPathTmp, ToolOption)\r
918 return ToolPathTmp, ToolOption\r