]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Workspace/InfBuildData.py
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / InfBuildData.py
1 ## @file
2 # This file is used to create a database used by build tool
3 #
4 # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
5 # (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6 # SPDX-License-Identifier: BSD-2-Clause-Patent
7 #
8
9 from __future__ import absolute_import
10 from Common.DataType import *
11 from Common.Misc import *
12 from Common.caching import cached_property, cached_class_function
13 from types import *
14 from .MetaFileParser import *
15 from collections import OrderedDict
16 from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
17 from Common.Expression import ValueExpressionEx, PcdPattern
18
19 ## Get Protocol value from given packages
20 #
21 # @param CName The CName of the GUID
22 # @param PackageList List of packages looking-up in
23 # @param Inffile The driver file
24 #
25 # @retval GuidValue if the CName is found in any given package
26 # @retval None if the CName is not found in all given packages
27 #
28 def _ProtocolValue(CName, PackageList, Inffile = None):
29 for P in PackageList:
30 ProtocolKeys = list(P.Protocols.keys())
31 if Inffile and P._PrivateProtocols:
32 if not Inffile.startswith(P.MetaFile.Dir):
33 ProtocolKeys = [x for x in P.Protocols if x not in P._PrivateProtocols]
34 if CName in ProtocolKeys:
35 return P.Protocols[CName]
36 return None
37
38 ## Get PPI value from given packages
39 #
40 # @param CName The CName of the GUID
41 # @param PackageList List of packages looking-up in
42 # @param Inffile The driver file
43 #
44 # @retval GuidValue if the CName is found in any given package
45 # @retval None if the CName is not found in all given packages
46 #
47 def _PpiValue(CName, PackageList, Inffile = None):
48 for P in PackageList:
49 PpiKeys = list(P.Ppis.keys())
50 if Inffile and P._PrivatePpis:
51 if not Inffile.startswith(P.MetaFile.Dir):
52 PpiKeys = [x for x in P.Ppis if x not in P._PrivatePpis]
53 if CName in PpiKeys:
54 return P.Ppis[CName]
55 return None
56
57 ## Module build information from INF file
58 #
59 # This class is used to retrieve information stored in database and convert them
60 # into ModuleBuildClassObject form for easier use for AutoGen.
61 #
62 class InfBuildData(ModuleBuildClassObject):
63
64 # dict used to convert part of [Defines] to members of InfBuildData directly
65 _PROPERTY_ = {
66 #
67 # Required Fields
68 #
69 TAB_INF_DEFINES_BASE_NAME : "_BaseName",
70 TAB_INF_DEFINES_FILE_GUID : "_Guid",
71 TAB_INF_DEFINES_MODULE_TYPE : "_ModuleType",
72 #
73 # Optional Fields
74 #
75 # TAB_INF_DEFINES_INF_VERSION : "_AutoGenVersion",
76 TAB_INF_DEFINES_COMPONENT_TYPE : "_ComponentType",
77 TAB_INF_DEFINES_MAKEFILE_NAME : "_MakefileName",
78 # TAB_INF_DEFINES_CUSTOM_MAKEFILE : "_CustomMakefile",
79 TAB_INF_DEFINES_DPX_SOURCE :"_DxsFile",
80 TAB_INF_DEFINES_VERSION_NUMBER : "_Version",
81 TAB_INF_DEFINES_VERSION_STRING : "_Version",
82 TAB_INF_DEFINES_VERSION : "_Version",
83 TAB_INF_DEFINES_PCD_IS_DRIVER : "_PcdIsDriver",
84 TAB_INF_DEFINES_SHADOW : "_Shadow"
85 }
86
87 # regular expression for converting XXX_FLAGS in [nmake] section to new type
88 _NMAKE_FLAG_PATTERN_ = re.compile("(?:EBC_)?([A-Z]+)_(?:STD_|PROJ_|ARCH_)?FLAGS(?:_DLL|_ASL|_EXE)?", re.UNICODE)
89 # dict used to convert old tool name used in [nmake] section to new ones
90 _TOOL_CODE_ = {
91 "C" : "CC",
92 BINARY_FILE_TYPE_LIB : "SLINK",
93 "LINK" : "DLINK",
94 }
95
96
97 ## Constructor of InfBuildData
98 #
99 # Initialize object of InfBuildData
100 #
101 # @param FilePath The path of platform description file
102 # @param RawData The raw data of DSC file
103 # @param BuildDataBase Database used to retrieve module/package information
104 # @param Arch The target architecture
105 # @param Platform The name of platform employing this module
106 # @param Macros Macros used for replacement in DSC file
107 #
108 def __init__(self, FilePath, RawData, BuildDatabase, Arch=TAB_ARCH_COMMON, Target=None, Toolchain=None):
109 self.MetaFile = FilePath
110 self._ModuleDir = FilePath.Dir
111 self._RawData = RawData
112 self._Bdb = BuildDatabase
113 self._Arch = Arch
114 self._Target = Target
115 self._Toolchain = Toolchain
116 self._Platform = TAB_COMMON
117 self._TailComments = None
118 self._BaseName = None
119 self._DxsFile = None
120 self._ModuleType = None
121 self._ComponentType = None
122 self._BuildType = None
123 self._Guid = None
124 self._Version = None
125 self._PcdIsDriver = None
126 self._BinaryModule = None
127 self._Shadow = None
128 self._MakefileName = None
129 self._CustomMakefile = None
130 self._Specification = None
131 self._LibraryClass = None
132 self._ModuleEntryPointList = None
133 self._ModuleUnloadImageList = None
134 self._ConstructorList = None
135 self._DestructorList = None
136 self._Defs = OrderedDict()
137 self._ProtocolComments = None
138 self._PpiComments = None
139 self._GuidsUsedByPcd = OrderedDict()
140 self._GuidComments = None
141 self._PcdComments = None
142 self._BuildOptions = None
143 self._DependencyFileList = None
144 self.UpdatePcdTypeDict()
145 self.LibInstances = []
146 self.ReferenceModules = set()
147
148 def SetReferenceModule(self,Module):
149 self.ReferenceModules.add(Module)
150 return self
151
152 ## XXX[key] = value
153 def __setitem__(self, key, value):
154 self.__dict__[self._PROPERTY_[key]] = value
155
156 ## value = XXX[key]
157 def __getitem__(self, key):
158 return self.__dict__[self._PROPERTY_[key]]
159
160 ## "in" test support
161 def __contains__(self, key):
162 return key in self._PROPERTY_
163
164 ## Get current effective macros
165 @cached_property
166 def _Macros(self):
167 RetVal = {}
168 return RetVal
169
170 ## Get architecture
171 @cached_property
172 def Arch(self):
173 return self._Arch
174
175 ## Return the name of platform employing this module
176 @cached_property
177 def Platform(self):
178 return self._Platform
179
180 @cached_property
181 def HeaderComments(self):
182 return [a[0] for a in self._RawData[MODEL_META_DATA_HEADER_COMMENT]]
183
184 @cached_property
185 def TailComments(self):
186 return [a[0] for a in self._RawData[MODEL_META_DATA_TAIL_COMMENT]]
187
188 ## Retrieve all information in [Defines] section
189 #
190 # (Retrieving all [Defines] information in one-shot is just to save time.)
191 #
192 @cached_class_function
193 def _GetHeaderInfo(self):
194 RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, self._Platform]
195 for Record in RecordList:
196 Name, Value = Record[1], ReplaceMacro(Record[2], self._Macros, False)
197 # items defined _PROPERTY_ don't need additional processing
198 if Name in self:
199 self[Name] = Value
200 self._Defs[Name] = Value
201 self._Macros[Name] = Value
202 # some special items in [Defines] section need special treatment
203 elif Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION', 'EDK_RELEASE_VERSION', 'PI_SPECIFICATION_VERSION'):
204 if Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'):
205 Name = 'UEFI_SPECIFICATION_VERSION'
206 if self._Specification is None:
207 self._Specification = OrderedDict()
208 self._Specification[Name] = GetHexVerValue(Value)
209 if self._Specification[Name] is None:
210 EdkLogger.error("build", FORMAT_NOT_SUPPORTED,
211 "'%s' format is not supported for %s" % (Value, Name),
212 File=self.MetaFile, Line=Record[-1])
213 elif Name == 'LIBRARY_CLASS':
214 if self._LibraryClass is None:
215 self._LibraryClass = []
216 ValueList = GetSplitValueList(Value)
217 LibraryClass = ValueList[0]
218 if len(ValueList) > 1:
219 SupModuleList = GetSplitValueList(ValueList[1], ' ')
220 else:
221 SupModuleList = SUP_MODULE_LIST
222 self._LibraryClass.append(LibraryClassObject(LibraryClass, SupModuleList))
223 elif Name == 'ENTRY_POINT':
224 if self._ModuleEntryPointList is None:
225 self._ModuleEntryPointList = []
226 self._ModuleEntryPointList.append(Value)
227 elif Name == 'UNLOAD_IMAGE':
228 if self._ModuleUnloadImageList is None:
229 self._ModuleUnloadImageList = []
230 if not Value:
231 continue
232 self._ModuleUnloadImageList.append(Value)
233 elif Name == 'CONSTRUCTOR':
234 if self._ConstructorList is None:
235 self._ConstructorList = []
236 if not Value:
237 continue
238 self._ConstructorList.append(Value)
239 elif Name == 'DESTRUCTOR':
240 if self._DestructorList is None:
241 self._DestructorList = []
242 if not Value:
243 continue
244 self._DestructorList.append(Value)
245 elif Name == TAB_INF_DEFINES_CUSTOM_MAKEFILE:
246 TokenList = GetSplitValueList(Value)
247 if self._CustomMakefile is None:
248 self._CustomMakefile = {}
249 if len(TokenList) < 2:
250 self._CustomMakefile[TAB_COMPILER_MSFT] = TokenList[0]
251 self._CustomMakefile['GCC'] = TokenList[0]
252 else:
253 if TokenList[0] not in [TAB_COMPILER_MSFT, 'GCC']:
254 EdkLogger.error("build", FORMAT_NOT_SUPPORTED,
255 "No supported family [%s]" % TokenList[0],
256 File=self.MetaFile, Line=Record[-1])
257 self._CustomMakefile[TokenList[0]] = TokenList[1]
258 else:
259 self._Defs[Name] = Value
260 self._Macros[Name] = Value
261
262 #
263 # Retrieve information in sections specific to Edk.x modules
264 #
265 if not self._ModuleType:
266 EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE,
267 "MODULE_TYPE is not given", File=self.MetaFile)
268 if self._ModuleType not in SUP_MODULE_LIST:
269 RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, self._Platform]
270 for Record in RecordList:
271 Name = Record[1]
272 if Name == "MODULE_TYPE":
273 LineNo = Record[6]
274 break
275 EdkLogger.error("build", FORMAT_NOT_SUPPORTED,
276 "MODULE_TYPE %s is not supported for EDK II, valid values are:\n %s" % (self._ModuleType, ' '.join(l for l in SUP_MODULE_LIST)),
277 File=self.MetaFile, Line=LineNo)
278 if (self._Specification is None) or (not 'PI_SPECIFICATION_VERSION' in self._Specification) or (int(self._Specification['PI_SPECIFICATION_VERSION'], 16) < 0x0001000A):
279 if self._ModuleType == SUP_MODULE_SMM_CORE:
280 EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "SMM_CORE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x0001000A", File=self.MetaFile)
281 if (self._Specification is None) or (not 'PI_SPECIFICATION_VERSION' in self._Specification) or (int(self._Specification['PI_SPECIFICATION_VERSION'], 16) < 0x00010032):
282 if self._ModuleType == SUP_MODULE_MM_CORE_STANDALONE:
283 EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_CORE_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile)
284 if self._ModuleType == SUP_MODULE_MM_STANDALONE:
285 EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile)
286 if 'PCI_DEVICE_ID' in self._Defs and 'PCI_VENDOR_ID' in self._Defs \
287 and 'PCI_CLASS_CODE' in self._Defs and 'PCI_REVISION' in self._Defs:
288 self._BuildType = 'UEFI_OPTIONROM'
289 if 'PCI_COMPRESS' in self._Defs:
290 if self._Defs['PCI_COMPRESS'] not in ('TRUE', 'FALSE'):
291 EdkLogger.error("build", FORMAT_INVALID, "Expected TRUE/FALSE for PCI_COMPRESS: %s" % self.MetaFile)
292
293 elif 'UEFI_HII_RESOURCE_SECTION' in self._Defs \
294 and self._Defs['UEFI_HII_RESOURCE_SECTION'] == 'TRUE':
295 self._BuildType = 'UEFI_HII'
296 else:
297 self._BuildType = self._ModuleType.upper()
298
299 if self._DxsFile:
300 File = PathClass(NormPath(self._DxsFile), self._ModuleDir, Arch=self._Arch)
301 # check the file validation
302 ErrorCode, ErrorInfo = File.Validate(".dxs", CaseSensitive=False)
303 if ErrorCode != 0:
304 EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo,
305 File=self.MetaFile, Line=LineNo)
306 if not self._DependencyFileList:
307 self._DependencyFileList = []
308 self._DependencyFileList.append(File)
309
310 ## Retrieve file version
311 @cached_property
312 def AutoGenVersion(self):
313 RetVal = 0x00010000
314 RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, self._Platform]
315 for Record in RecordList:
316 if Record[1] == TAB_INF_DEFINES_INF_VERSION:
317 if '.' in Record[2]:
318 ValueList = Record[2].split('.')
319 Major = '%04o' % int(ValueList[0], 0)
320 Minor = '%04o' % int(ValueList[1], 0)
321 RetVal = int('0x' + Major + Minor, 0)
322 else:
323 RetVal = int(Record[2], 0)
324 break
325 return RetVal
326
327 ## Retrieve BASE_NAME
328 @cached_property
329 def BaseName(self):
330 if self._BaseName is None:
331 self._GetHeaderInfo()
332 if self._BaseName is None:
333 EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No BASE_NAME name", File=self.MetaFile)
334 return self._BaseName
335
336 ## Retrieve DxsFile
337 @cached_property
338 def DxsFile(self):
339 if self._DxsFile is None:
340 self._GetHeaderInfo()
341 if self._DxsFile is None:
342 self._DxsFile = ''
343 return self._DxsFile
344
345 ## Retrieve MODULE_TYPE
346 @cached_property
347 def ModuleType(self):
348 if self._ModuleType is None:
349 self._GetHeaderInfo()
350 if self._ModuleType is None:
351 self._ModuleType = SUP_MODULE_BASE
352 if self._ModuleType not in SUP_MODULE_LIST:
353 self._ModuleType = SUP_MODULE_USER_DEFINED
354 return self._ModuleType
355
356 ## Retrieve COMPONENT_TYPE
357 @cached_property
358 def ComponentType(self):
359 if self._ComponentType is None:
360 self._GetHeaderInfo()
361 if self._ComponentType is None:
362 self._ComponentType = SUP_MODULE_USER_DEFINED
363 return self._ComponentType
364
365 ## Retrieve "BUILD_TYPE"
366 @cached_property
367 def BuildType(self):
368 if self._BuildType is None:
369 self._GetHeaderInfo()
370 if not self._BuildType:
371 self._BuildType = SUP_MODULE_BASE
372 return self._BuildType
373
374 ## Retrieve file guid
375 @cached_property
376 def Guid(self):
377 if self._Guid is None:
378 self._GetHeaderInfo()
379 if self._Guid is None:
380 self._Guid = '00000000-0000-0000-0000-000000000000'
381 return self._Guid
382
383 ## Retrieve module version
384 @cached_property
385 def Version(self):
386 if self._Version is None:
387 self._GetHeaderInfo()
388 if self._Version is None:
389 self._Version = '0.0'
390 return self._Version
391
392 ## Retrieve PCD_IS_DRIVER
393 @cached_property
394 def PcdIsDriver(self):
395 if self._PcdIsDriver is None:
396 self._GetHeaderInfo()
397 if self._PcdIsDriver is None:
398 self._PcdIsDriver = ''
399 return self._PcdIsDriver
400
401 ## Retrieve SHADOW
402 @cached_property
403 def Shadow(self):
404 if self._Shadow is None:
405 self._GetHeaderInfo()
406 if self._Shadow and self._Shadow.upper() == 'TRUE':
407 self._Shadow = True
408 else:
409 self._Shadow = False
410 return self._Shadow
411
412 ## Retrieve CUSTOM_MAKEFILE
413 @cached_property
414 def CustomMakefile(self):
415 if self._CustomMakefile is None:
416 self._GetHeaderInfo()
417 if self._CustomMakefile is None:
418 self._CustomMakefile = {}
419 return self._CustomMakefile
420
421 ## Retrieve EFI_SPECIFICATION_VERSION
422 @cached_property
423 def Specification(self):
424 if self._Specification is None:
425 self._GetHeaderInfo()
426 if self._Specification is None:
427 self._Specification = {}
428 return self._Specification
429
430 ## Retrieve LIBRARY_CLASS
431 @cached_property
432 def LibraryClass(self):
433 if self._LibraryClass is None:
434 self._GetHeaderInfo()
435 if self._LibraryClass is None:
436 self._LibraryClass = []
437 return self._LibraryClass
438
439 ## Retrieve ENTRY_POINT
440 @cached_property
441 def ModuleEntryPointList(self):
442 if self._ModuleEntryPointList is None:
443 self._GetHeaderInfo()
444 if self._ModuleEntryPointList is None:
445 self._ModuleEntryPointList = []
446 return self._ModuleEntryPointList
447
448 ## Retrieve UNLOAD_IMAGE
449 @cached_property
450 def ModuleUnloadImageList(self):
451 if self._ModuleUnloadImageList is None:
452 self._GetHeaderInfo()
453 if self._ModuleUnloadImageList is None:
454 self._ModuleUnloadImageList = []
455 return self._ModuleUnloadImageList
456
457 ## Retrieve CONSTRUCTOR
458 @cached_property
459 def ConstructorList(self):
460 if self._ConstructorList is None:
461 self._GetHeaderInfo()
462 if self._ConstructorList is None:
463 self._ConstructorList = []
464 return self._ConstructorList
465
466 ## Retrieve DESTRUCTOR
467 @cached_property
468 def DestructorList(self):
469 if self._DestructorList is None:
470 self._GetHeaderInfo()
471 if self._DestructorList is None:
472 self._DestructorList = []
473 return self._DestructorList
474
475 ## Retrieve definies other than above ones
476 @cached_property
477 def Defines(self):
478 self._GetHeaderInfo()
479 return self._Defs
480
481 ## Retrieve binary files
482 @cached_class_function
483 def _GetBinaries(self):
484 RetVal = []
485 RecordList = self._RawData[MODEL_EFI_BINARY_FILE, self._Arch, self._Platform]
486 Macros = self._Macros
487 Macros['PROCESSOR'] = self._Arch
488 for Record in RecordList:
489 FileType = Record[0]
490 LineNo = Record[-1]
491 Target = TAB_COMMON
492 FeatureFlag = []
493 if Record[2]:
494 TokenList = GetSplitValueList(Record[2], TAB_VALUE_SPLIT)
495 if TokenList:
496 Target = TokenList[0]
497 if len(TokenList) > 1:
498 FeatureFlag = Record[1:]
499
500 File = PathClass(NormPath(Record[1], Macros), self._ModuleDir, '', FileType, True, self._Arch, '', Target)
501 # check the file validation
502 ErrorCode, ErrorInfo = File.Validate()
503 if ErrorCode != 0:
504 EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo, File=self.MetaFile, Line=LineNo)
505 RetVal.append(File)
506 return RetVal
507
508 ## Retrieve binary files with error check.
509 @cached_property
510 def Binaries(self):
511 RetVal = self._GetBinaries()
512 if GlobalData.gIgnoreSource and not RetVal:
513 ErrorInfo = "The INF file does not contain any RetVal to use in creating the image\n"
514 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, ExtraData=ErrorInfo, File=self.MetaFile)
515
516 return RetVal
517
518 ## Retrieve source files
519 @cached_property
520 def Sources(self):
521 self._GetHeaderInfo()
522 # Ignore all source files in a binary build mode
523 if GlobalData.gIgnoreSource:
524 return []
525
526 RetVal = []
527 RecordList = self._RawData[MODEL_EFI_SOURCE_FILE, self._Arch, self._Platform]
528 Macros = self._Macros
529 for Record in RecordList:
530 LineNo = Record[-1]
531 ToolChainFamily = Record[1]
532 # OptionsList := [TagName, ToolCode, FeatureFlag]
533 OptionsList = ['', '', '']
534 TokenList = GetSplitValueList(Record[2], TAB_VALUE_SPLIT)
535 for Index in range(len(TokenList)):
536 OptionsList[Index] = TokenList[Index]
537 if OptionsList[2]:
538 FeaturePcdExpression = self.CheckFeatureFlagPcd(OptionsList[2])
539 if not FeaturePcdExpression:
540 continue
541 File = PathClass(NormPath(Record[0], Macros), self._ModuleDir, '',
542 '', False, self._Arch, ToolChainFamily, '', OptionsList[0], OptionsList[1])
543 # check the file validation
544 ErrorCode, ErrorInfo = File.Validate()
545 if ErrorCode != 0:
546 EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo, File=self.MetaFile, Line=LineNo)
547
548 RetVal.append(File)
549 # add any previously found dependency files to the source list
550 if self._DependencyFileList:
551 RetVal.extend(self._DependencyFileList)
552 return RetVal
553
554 ## Retrieve library classes employed by this module
555 @cached_property
556 def LibraryClasses(self):
557 RetVal = OrderedDict()
558 RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch, self._Platform]
559 for Record in RecordList:
560 Lib = Record[0]
561 Instance = Record[1]
562 if Instance:
563 Instance = NormPath(Instance, self._Macros)
564 RetVal[Lib] = Instance
565 else:
566 RetVal[Lib] = None
567 return RetVal
568
569 ## Retrieve library names (for Edk.x style of modules)
570 @cached_property
571 def Libraries(self):
572 RetVal = []
573 RecordList = self._RawData[MODEL_EFI_LIBRARY_INSTANCE, self._Arch, self._Platform]
574 for Record in RecordList:
575 LibraryName = ReplaceMacro(Record[0], self._Macros, False)
576 # in case of name with '.lib' extension, which is unusual in Edk.x inf
577 LibraryName = os.path.splitext(LibraryName)[0]
578 if LibraryName not in RetVal:
579 RetVal.append(LibraryName)
580 return RetVal
581
582 @cached_property
583 def ProtocolComments(self):
584 self.Protocols
585 return self._ProtocolComments
586
587 ## Retrieve protocols consumed/produced by this module
588 @cached_property
589 def Protocols(self):
590 RetVal = OrderedDict()
591 self._ProtocolComments = OrderedDict()
592 RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform]
593 for Record in RecordList:
594 CName = Record[0]
595 Value = _ProtocolValue(CName, self.Packages, self.MetaFile.Path)
596 if Value is None:
597 PackageList = "\n\t".join(str(P) for P in self.Packages)
598 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
599 "Value of Protocol [%s] is not found under [Protocols] section in" % CName,
600 ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
601 RetVal[CName] = Value
602 CommentRecords = self._RawData[MODEL_META_DATA_COMMENT, self._Arch, self._Platform, Record[5]]
603 self._ProtocolComments[CName] = [a[0] for a in CommentRecords]
604 return RetVal
605
606 @cached_property
607 def PpiComments(self):
608 self.Ppis
609 return self._PpiComments
610
611 ## Retrieve PPIs consumed/produced by this module
612 @cached_property
613 def Ppis(self):
614 RetVal = OrderedDict()
615 self._PpiComments = OrderedDict()
616 RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform]
617 for Record in RecordList:
618 CName = Record[0]
619 Value = _PpiValue(CName, self.Packages, self.MetaFile.Path)
620 if Value is None:
621 PackageList = "\n\t".join(str(P) for P in self.Packages)
622 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
623 "Value of PPI [%s] is not found under [Ppis] section in " % CName,
624 ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
625 RetVal[CName] = Value
626 CommentRecords = self._RawData[MODEL_META_DATA_COMMENT, self._Arch, self._Platform, Record[5]]
627 self._PpiComments[CName] = [a[0] for a in CommentRecords]
628 return RetVal
629
630 @cached_property
631 def GuidComments(self):
632 self.Guids
633 return self._GuidComments
634
635 ## Retrieve GUIDs consumed/produced by this module
636 @cached_property
637 def Guids(self):
638 RetVal = OrderedDict()
639 self._GuidComments = OrderedDict()
640 RecordList = self._RawData[MODEL_EFI_GUID, self._Arch, self._Platform]
641 for Record in RecordList:
642 CName = Record[0]
643 Value = GuidValue(CName, self.Packages, self.MetaFile.Path)
644 if Value is None:
645 PackageList = "\n\t".join(str(P) for P in self.Packages)
646 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
647 "Value of Guid [%s] is not found under [Guids] section in" % CName,
648 ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
649 RetVal[CName] = Value
650 CommentRecords = self._RawData[MODEL_META_DATA_COMMENT, self._Arch, self._Platform, Record[5]]
651 self._GuidComments[CName] = [a[0] for a in CommentRecords]
652
653 for Type in [MODEL_PCD_FIXED_AT_BUILD,MODEL_PCD_PATCHABLE_IN_MODULE,MODEL_PCD_FEATURE_FLAG,MODEL_PCD_DYNAMIC,MODEL_PCD_DYNAMIC_EX]:
654 RecordList = self._RawData[Type, self._Arch, self._Platform]
655 for TokenSpaceGuid, _, _, _, _, _, LineNo in RecordList:
656 # get the guid value
657 if TokenSpaceGuid not in RetVal:
658 Value = GuidValue(TokenSpaceGuid, self.Packages, self.MetaFile.Path)
659 if Value is None:
660 PackageList = "\n\t".join(str(P) for P in self.Packages)
661 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
662 "Value of Guid [%s] is not found under [Guids] section in" % TokenSpaceGuid,
663 ExtraData=PackageList, File=self.MetaFile, Line=LineNo)
664 RetVal[TokenSpaceGuid] = Value
665 self._GuidsUsedByPcd[TokenSpaceGuid] = Value
666 return RetVal
667
668 ## Retrieve include paths necessary for this module (for Edk.x style of modules)
669 @cached_property
670 def Includes(self):
671 RetVal = []
672 Macros = self._Macros
673 Macros['PROCESSOR'] = GlobalData.gEdkGlobal.get('PROCESSOR', self._Arch)
674 RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch, self._Platform]
675 for Record in RecordList:
676 File = NormPath(Record[0], Macros)
677 if File[0] == '.':
678 File = os.path.join(self._ModuleDir, File)
679 else:
680 File = mws.join(GlobalData.gWorkspace, File)
681 File = RealPath(os.path.normpath(File))
682 if File:
683 RetVal.append(File)
684 return RetVal
685
686 ## Retrieve packages this module depends on
687 @cached_property
688 def Packages(self):
689 RetVal = []
690 RecordList = self._RawData[MODEL_META_DATA_PACKAGE, self._Arch, self._Platform]
691 Macros = self._Macros
692 for Record in RecordList:
693 File = PathClass(NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch=self._Arch)
694 # check the file validation
695 ErrorCode, ErrorInfo = File.Validate('.dec')
696 if ErrorCode != 0:
697 LineNo = Record[-1]
698 EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo, File=self.MetaFile, Line=LineNo)
699 # parse this package now. we need it to get protocol/ppi/guid value
700 RetVal.append(self._Bdb[File, self._Arch, self._Target, self._Toolchain])
701 return RetVal
702
703 ## Retrieve PCD comments
704 @cached_property
705 def PcdComments(self):
706 self.Pcds
707 return self._PcdComments
708
709 ## Retrieve PCDs used in this module
710 @cached_property
711 def Pcds(self):
712 self._PcdComments = OrderedDict()
713 RetVal = OrderedDict()
714 RetVal.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
715 RetVal.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))
716 RetVal.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))
717 RetVal.update(self._GetPcd(MODEL_PCD_DYNAMIC))
718 RetVal.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX))
719 return RetVal
720
721 @cached_property
722 def ModulePcdList(self):
723 RetVal = self.Pcds
724 return RetVal
725 @cached_property
726 def LibraryPcdList(self):
727 if bool(self.LibraryClass):
728 return []
729 RetVal = {}
730 Pcds = set()
731 for Library in self.LibInstances:
732 PcdsInLibrary = OrderedDict()
733 for Key in Library.Pcds:
734 if Key in self.Pcds or Key in Pcds:
735 continue
736 Pcds.add(Key)
737 PcdsInLibrary[Key] = copy.copy(Library.Pcds[Key])
738 RetVal[Library] = PcdsInLibrary
739 return RetVal
740 @cached_property
741 def PcdsName(self):
742 PcdsName = set()
743 for Type in (MODEL_PCD_FIXED_AT_BUILD,MODEL_PCD_PATCHABLE_IN_MODULE,MODEL_PCD_FEATURE_FLAG,MODEL_PCD_DYNAMIC,MODEL_PCD_DYNAMIC_EX):
744 RecordList = self._RawData[Type, self._Arch, self._Platform]
745 for TokenSpaceGuid, PcdCName, _, _, _, _, _ in RecordList:
746 PcdsName.add((PcdCName, TokenSpaceGuid))
747 return PcdsName
748
749 ## Retrieve build options specific to this module
750 @cached_property
751 def BuildOptions(self):
752 if self._BuildOptions is None:
753 self._BuildOptions = OrderedDict()
754 RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, self._Platform]
755 for Record in RecordList:
756 ToolChainFamily = Record[0]
757 ToolChain = Record[1]
758 Option = Record[2]
759 if (ToolChainFamily, ToolChain) not in self._BuildOptions or Option.startswith('='):
760 self._BuildOptions[ToolChainFamily, ToolChain] = Option
761 else:
762 # concatenate the option string if they're for the same tool
763 OptionString = self._BuildOptions[ToolChainFamily, ToolChain]
764 self._BuildOptions[ToolChainFamily, ToolChain] = OptionString + " " + Option
765 return self._BuildOptions
766
767 ## Retrieve dependency expression
768 @cached_property
769 def Depex(self):
770 RetVal = tdict(False, 2)
771
772 # If the module has only Binaries and no Sources, then ignore [Depex]
773 if not self.Sources and self.Binaries:
774 return RetVal
775
776 RecordList = self._RawData[MODEL_EFI_DEPEX, self._Arch]
777 # PEIM and DXE drivers must have a valid [Depex] section
778 if len(self.LibraryClass) == 0 and len(RecordList) == 0:
779 if self.ModuleType == SUP_MODULE_DXE_DRIVER or self.ModuleType == SUP_MODULE_PEIM or self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER or \
780 self.ModuleType == SUP_MODULE_DXE_SAL_DRIVER or self.ModuleType == SUP_MODULE_DXE_RUNTIME_DRIVER:
781 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "No [Depex] section or no valid expression in [Depex] section for [%s] module" \
782 % self.ModuleType, File=self.MetaFile)
783
784 if len(RecordList) != 0 and (self.ModuleType == SUP_MODULE_USER_DEFINED or self.ModuleType == SUP_MODULE_HOST_APPLICATION):
785 for Record in RecordList:
786 if Record[4] not in [SUP_MODULE_PEIM, SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SMM_DRIVER]:
787 EdkLogger.error('build', FORMAT_INVALID,
788 "'%s' module must specify the type of [Depex] section" % self.ModuleType,
789 File=self.MetaFile)
790
791 TemporaryDictionary = OrderedDict()
792 for Record in RecordList:
793 DepexStr = ReplaceMacro(Record[0], self._Macros, False)
794 Arch = Record[3]
795 ModuleType = Record[4]
796 TokenList = DepexStr.split()
797 if (Arch, ModuleType) not in TemporaryDictionary:
798 TemporaryDictionary[Arch, ModuleType] = []
799 DepexList = TemporaryDictionary[Arch, ModuleType]
800 for Token in TokenList:
801 if Token in DEPEX_SUPPORTED_OPCODE_SET:
802 DepexList.append(Token)
803 elif Token.endswith(".inf"): # module file name
804 ModuleFile = os.path.normpath(Token)
805 Module = self.BuildDatabase[ModuleFile]
806 if Module is None:
807 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "Module is not found in active platform",
808 ExtraData=Token, File=self.MetaFile, Line=Record[-1])
809 DepexList.append(Module.Guid)
810 else:
811 # it use the Fixed PCD format
812 if '.' in Token:
813 if tuple(Token.split('.')[::-1]) not in self.Pcds:
814 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "PCD [{}] used in [Depex] section should be listed in module PCD section".format(Token), File=self.MetaFile, Line=Record[-1])
815 else:
816 if self.Pcds[tuple(Token.split('.')[::-1])].DatumType != TAB_VOID:
817 EdkLogger.error('build', FORMAT_INVALID, "PCD [{}] used in [Depex] section should be VOID* datum type".format(Token), File=self.MetaFile, Line=Record[-1])
818 Value = Token
819 else:
820 # get the GUID value now
821 Value = _ProtocolValue(Token, self.Packages, self.MetaFile.Path)
822 if Value is None:
823 Value = _PpiValue(Token, self.Packages, self.MetaFile.Path)
824 if Value is None:
825 Value = GuidValue(Token, self.Packages, self.MetaFile.Path)
826
827 if Value is None:
828 PackageList = "\n\t".join(str(P) for P in self.Packages)
829 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,
830 "Value of [%s] is not found in" % Token,
831 ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
832 DepexList.append(Value)
833 for Arch, ModuleType in TemporaryDictionary:
834 RetVal[Arch, ModuleType] = TemporaryDictionary[Arch, ModuleType]
835 return RetVal
836
837 ## Retrieve dependency expression
838 @cached_property
839 def DepexExpression(self):
840 RetVal = tdict(False, 2)
841 RecordList = self._RawData[MODEL_EFI_DEPEX, self._Arch]
842 TemporaryDictionary = OrderedDict()
843 for Record in RecordList:
844 DepexStr = ReplaceMacro(Record[0], self._Macros, False)
845 Arch = Record[3]
846 ModuleType = Record[4]
847 TokenList = DepexStr.split()
848 if (Arch, ModuleType) not in TemporaryDictionary:
849 TemporaryDictionary[Arch, ModuleType] = ''
850 for Token in TokenList:
851 TemporaryDictionary[Arch, ModuleType] = TemporaryDictionary[Arch, ModuleType] + Token.strip() + ' '
852 for Arch, ModuleType in TemporaryDictionary:
853 RetVal[Arch, ModuleType] = TemporaryDictionary[Arch, ModuleType]
854 return RetVal
855 def LocalPkg(self):
856 module_path = self.MetaFile.File
857 subdir = os.path.split(module_path)[0]
858 TopDir = ""
859 while subdir:
860 subdir,TopDir = os.path.split(subdir)
861
862 for file_name in os.listdir(os.path.join(self.MetaFile.Root,TopDir)):
863 if file_name.upper().endswith("DEC"):
864 pkg = os.path.join(TopDir,file_name)
865 return pkg
866 @cached_class_function
867 def GetGuidsUsedByPcd(self):
868 self.Guid
869 return self._GuidsUsedByPcd
870
871 ## Retrieve PCD for given type
872 def _GetPcd(self, Type):
873 Pcds = OrderedDict()
874 PcdDict = tdict(True, 4)
875 PcdList = []
876 RecordList = self._RawData[Type, self._Arch, self._Platform]
877 for TokenSpaceGuid, PcdCName, Setting, Arch, Platform, Id, LineNo in RecordList:
878 PcdDict[Arch, Platform, PcdCName, TokenSpaceGuid] = (Setting, LineNo)
879 PcdList.append((PcdCName, TokenSpaceGuid))
880 CommentRecords = self._RawData[MODEL_META_DATA_COMMENT, self._Arch, self._Platform, Id]
881 Comments = []
882 for CmtRec in CommentRecords:
883 Comments.append(CmtRec[0])
884 self._PcdComments[TokenSpaceGuid, PcdCName] = Comments
885
886 # resolve PCD type, value, datum info, etc. by getting its definition from package
887 _GuidDict = self.Guids.copy()
888 for PcdCName, TokenSpaceGuid in PcdList:
889 PcdRealName = PcdCName
890 Setting, LineNo = PcdDict[self._Arch, self.Platform, PcdCName, TokenSpaceGuid]
891 if Setting is None:
892 continue
893 ValueList = AnalyzePcdData(Setting)
894 DefaultValue = ValueList[0]
895 Pcd = PcdClassObject(
896 PcdCName,
897 TokenSpaceGuid,
898 '',
899 '',
900 DefaultValue,
901 '',
902 '',
903 {},
904 False,
905 self.Guids[TokenSpaceGuid]
906 )
907 if Type == MODEL_PCD_PATCHABLE_IN_MODULE and ValueList[1]:
908 # Patch PCD: TokenSpace.PcdCName|Value|Offset
909 Pcd.Offset = ValueList[1]
910
911 if (PcdRealName, TokenSpaceGuid) in GlobalData.MixedPcd:
912 for Package in self.Packages:
913 for key in Package.Pcds:
914 if (Package.Pcds[key].TokenCName, Package.Pcds[key].TokenSpaceGuidCName) == (PcdRealName, TokenSpaceGuid):
915 for item in GlobalData.MixedPcd[(PcdRealName, TokenSpaceGuid)]:
916 Pcd_Type = item[0].split('_')[-1]
917 if Pcd_Type == Package.Pcds[key].Type:
918 Value = Package.Pcds[key]
919 Value.TokenCName = Package.Pcds[key].TokenCName + '_' + Pcd_Type
920 if len(key) == 2:
921 newkey = (Value.TokenCName, key[1])
922 elif len(key) == 3:
923 newkey = (Value.TokenCName, key[1], key[2])
924 del Package.Pcds[key]
925 Package.Pcds[newkey] = Value
926 break
927 else:
928 pass
929 else:
930 pass
931
932 # get necessary info from package declaring this PCD
933 for Package in self.Packages:
934 #
935 # 'dynamic' in INF means its type is determined by platform;
936 # if platform doesn't give its type, use 'lowest' one in the
937 # following order, if any
938 #
939 # TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE, TAB_PCDS_FEATURE_FLAG, TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_EX
940 #
941 _GuidDict.update(Package.Guids)
942 PcdType = self._PCD_TYPE_STRING_[Type]
943 if Type == MODEL_PCD_DYNAMIC:
944 Pcd.Pending = True
945 for T in PCD_TYPE_LIST:
946 if (PcdRealName, TokenSpaceGuid) in GlobalData.MixedPcd:
947 for item in GlobalData.MixedPcd[(PcdRealName, TokenSpaceGuid)]:
948 if str(item[0]).endswith(T) and (item[0], item[1], T) in Package.Pcds:
949 PcdType = T
950 PcdCName = item[0]
951 break
952 else:
953 pass
954 break
955 else:
956 if (PcdRealName, TokenSpaceGuid, T) in Package.Pcds:
957 PcdType = T
958 break
959
960 else:
961 Pcd.Pending = False
962 if (PcdRealName, TokenSpaceGuid) in GlobalData.MixedPcd:
963 for item in GlobalData.MixedPcd[(PcdRealName, TokenSpaceGuid)]:
964 Pcd_Type = item[0].split('_')[-1]
965 if Pcd_Type == PcdType:
966 PcdCName = item[0]
967 break
968 else:
969 pass
970 else:
971 pass
972
973 if (PcdCName, TokenSpaceGuid, PcdType) in Package.Pcds:
974 PcdInPackage = Package.Pcds[PcdCName, TokenSpaceGuid, PcdType]
975 Pcd.Type = PcdType
976 Pcd.TokenValue = PcdInPackage.TokenValue
977
978 #
979 # Check whether the token value exist or not.
980 #
981 if Pcd.TokenValue is None or Pcd.TokenValue == "":
982 EdkLogger.error(
983 'build',
984 FORMAT_INVALID,
985 "No TokenValue for PCD [%s.%s] in [%s]!" % (TokenSpaceGuid, PcdRealName, str(Package)),
986 File=self.MetaFile, Line=LineNo,
987 ExtraData=None
988 )
989 #
990 # Check hexadecimal token value length and format.
991 #
992 ReIsValidPcdTokenValue = re.compile(r"^[0][x|X][0]*[0-9a-fA-F]{1,8}$", re.DOTALL)
993 if Pcd.TokenValue.startswith("0x") or Pcd.TokenValue.startswith("0X"):
994 if ReIsValidPcdTokenValue.match(Pcd.TokenValue) is None:
995 EdkLogger.error(
996 'build',
997 FORMAT_INVALID,
998 "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid:" % (Pcd.TokenValue, TokenSpaceGuid, PcdRealName, str(Package)),
999 File=self.MetaFile, Line=LineNo,
1000 ExtraData=None
1001 )
1002
1003 #
1004 # Check decimal token value length and format.
1005 #
1006 else:
1007 try:
1008 TokenValueInt = int (Pcd.TokenValue, 10)
1009 if (TokenValueInt < 0 or TokenValueInt > 4294967295):
1010 EdkLogger.error(
1011 'build',
1012 FORMAT_INVALID,
1013 "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid, as a decimal it should between: 0 - 4294967295!" % (Pcd.TokenValue, TokenSpaceGuid, PcdRealName, str(Package)),
1014 File=self.MetaFile, Line=LineNo,
1015 ExtraData=None
1016 )
1017 except:
1018 EdkLogger.error(
1019 'build',
1020 FORMAT_INVALID,
1021 "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid, it should be hexadecimal or decimal!" % (Pcd.TokenValue, TokenSpaceGuid, PcdRealName, str(Package)),
1022 File=self.MetaFile, Line=LineNo,
1023 ExtraData=None
1024 )
1025
1026 Pcd.DatumType = PcdInPackage.DatumType
1027 Pcd.MaxDatumSize = PcdInPackage.MaxDatumSize
1028 Pcd.InfDefaultValue = Pcd.DefaultValue
1029 if not Pcd.DefaultValue:
1030 Pcd.DefaultValue = PcdInPackage.DefaultValue
1031 else:
1032 try:
1033 Pcd.DefaultValue = ValueExpressionEx(Pcd.DefaultValue, Pcd.DatumType, _GuidDict)(True)
1034 except BadExpression as Value:
1035 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %(TokenSpaceGuid, PcdRealName, Pcd.DefaultValue, Value),
1036 File=self.MetaFile, Line=LineNo)
1037 break
1038 else:
1039 EdkLogger.error(
1040 'build',
1041 FORMAT_INVALID,
1042 "PCD [%s.%s] in [%s] is not found in dependent packages:" % (TokenSpaceGuid, PcdRealName, self.MetaFile),
1043 File=self.MetaFile, Line=LineNo,
1044 ExtraData="\t%s" % '\n\t'.join(str(P) for P in self.Packages)
1045 )
1046 Pcds[PcdCName, TokenSpaceGuid] = Pcd
1047
1048 return Pcds
1049
1050 ## check whether current module is binary module
1051 @property
1052 def IsBinaryModule(self):
1053 if (self.Binaries and not self.Sources) or GlobalData.gIgnoreSource:
1054 return True
1055 return False
1056 def CheckFeatureFlagPcd(self,Instance):
1057 Pcds = GlobalData.gPlatformFinalPcds.copy()
1058 if PcdPattern.search(Instance):
1059 PcdTuple = tuple(Instance.split('.')[::-1])
1060 if PcdTuple in self.Pcds:
1061 if not (self.Pcds[PcdTuple].Type == 'FeatureFlag' or self.Pcds[PcdTuple].Type == 'FixedAtBuild'):
1062 EdkLogger.error('build', FORMAT_INVALID,
1063 "\nFeatureFlagPcd must be defined in a [PcdsFeatureFlag] or [PcdsFixedAtBuild] section of Dsc or Dec file",
1064 File=str(self), ExtraData=Instance)
1065 if not Instance in Pcds:
1066 Pcds[Instance] = self.Pcds[PcdTuple].DefaultValue
1067 else: #if PcdTuple not in self.Pcds:
1068 EdkLogger.error('build', FORMAT_INVALID,
1069 "\nFeatureFlagPcd must be defined in [FeaturePcd] or [FixedPcd] of Inf file",
1070 File=str(self), ExtraData=Instance)
1071 if Instance in Pcds:
1072 if Pcds[Instance] == '0':
1073 return False
1074 elif Pcds[Instance] == '1':
1075 return True
1076 try:
1077 Value = ValueExpression(Instance, Pcds)()
1078 if Value == True:
1079 return True
1080 return False
1081 except:
1082 EdkLogger.warn('build', FORMAT_INVALID,"The FeatureFlagExpression cannot be evaluated", File=str(self), ExtraData=Instance)
1083 return False
1084 else:
1085 for Name, Guid in self.Pcds:
1086 if self.Pcds[(Name, Guid)].Type == 'FeatureFlag' or self.Pcds[(Name, Guid)].Type == 'FixedAtBuild':
1087 PcdFullName = '%s.%s' % (Guid, Name);
1088 if not PcdFullName in Pcds:
1089 Pcds[PcdFullName] = self.Pcds[(Name, Guid)].DefaultValue
1090 try:
1091 Value = ValueExpression(Instance, Pcds)()
1092 if Value == True:
1093 return True
1094 return False
1095 except:
1096 EdkLogger.warn('build', FORMAT_INVALID, "The FeatureFlagExpression cannot be evaluated", File=str(self), ExtraData=Instance)
1097 return False
1098 def ExtendCopyDictionaryLists(CopyToDict, CopyFromDict):
1099 for Key in CopyFromDict:
1100 CopyToDict[Key].extend(CopyFromDict[Key])