]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/baseobject.py
3 # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
5 # This program and the accompanying materials are licensed and made available
6 # under the terms and conditions of the BSD License which accompanies this
7 # distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 import plugins
.EdkPlugins
.basemodel
.ini
as ini
14 import plugins
.EdkPlugins
.edk2
.model
.dsc
as dsc
15 import plugins
.EdkPlugins
.edk2
.model
.inf
as inf
16 import plugins
.EdkPlugins
.edk2
.model
.dec
as dec
18 from plugins
.EdkPlugins
.basemodel
.message
import *
20 class SurfaceObject(object):
23 def __new__(cls
, *args
, **kwargs
):
24 """Maintain only a single instance of this object
25 @return: instance of this class
28 obj
= object.__new
__(cls
, *args
, **kwargs
)
29 if not cls
._objs
.has_key("None"):
30 cls
._objs
["None"] = []
31 cls
._objs
["None"].append(obj
)
35 def __init__(self
, parent
, workspace
):
38 self
._workspace
= workspace
39 self
._isModify
= False
40 self
._modifiedObjs
= []
46 key
= self
.GetRelativeFilename()
47 self
.GetFileObj().Destroy(self
)
49 # dereference self from _objs arrary
50 assert self
._objs
.has_key(key
), "when destory, object is not in obj list"
51 assert self
in self
._objs
[key
], "when destory, object is not in obj list"
52 self
._objs
[key
].remove(self
)
53 if len(self
._objs
[key
]) == 0:
59 def GetWorkspace(self
):
60 return self
._workspace
62 def GetFileObjectClass(self
):
63 return ini
.BaseINIFile
65 def GetFilename(self
):
66 return self
.GetFileObj().GetFilename()
71 def GetRelativeFilename(self
):
72 fullPath
= self
.GetFilename()
73 return fullPath
[len(self
._workspace
) + 1:]
75 def Load(self
, relativePath
):
76 # if has been loaded, directly return
77 if self
._fileObj
!= None: return True
79 relativePath
= os
.path
.normpath(relativePath
)
80 fullPath
= os
.path
.join(self
._workspace
, relativePath
)
81 fullPath
= os
.path
.normpath(fullPath
)
83 if not os
.path
.exists(fullPath
):
84 ErrorMsg("file does not exist!", fullPath
)
87 self
._fileObj
= self
.GetFileObjectClass()(fullPath
, self
)
89 if not self
._fileObj
.Parse():
90 ErrorMsg("Fail to parse file!", fullPath
)
93 # remove self from None list to list with filename as key
95 if self
not in cls
._objs
["None"]:
96 ErrorMsg("Sufrace object does not be create into None list")
97 cls
._objs
["None"].remove(self
)
98 if not cls
._objs
.has_key(relativePath
):
99 cls
._objs
[relativePath
] = []
100 cls
._objs
[relativePath
].append(self
)
104 def Reload(self
, force
=False):
106 # whether require must be update
108 ret
= self
.GetFileObj().Reload(True)
110 if self
.IsModified():
111 if self
.GetFileObj().IsModified():
112 ret
= self
.GetFileObj().Reload()
115 def Modify(self
, modify
=True, modifiedObj
=None):
117 #LogMsg("%s is modified, modified object is %s" % (self.GetFilename(), modifiedObj))
118 if issubclass(modifiedObj
.__class
__, ini
.BaseINIFile
) and self
._isModify
:
120 self
._isModify
= modify
121 self
.GetParent().Modify(modify
, self
)
123 self
._isModify
= modify
125 def IsModified(self
):
126 return self
._isModify
128 def GetModifiedObjs(self
):
129 return self
._modifiedObjs
131 def FilterObjsByArch(self
, objs
, arch
):
134 if obj
.GetArch().lower() == 'common':
137 if obj
.GetArch().lower() == arch
.lower():
142 class Platform(SurfaceObject
):
143 def __init__(self
, parent
, workspace
):
144 SurfaceObject
.__init
__(self
, parent
, workspace
)
149 for module
in self
._modules
:
153 del self
._packages
[:]
154 SurfaceObject
.Destroy(self
)
157 return self
.GetFileObj().GetDefine("PLATFORM_NAME")
159 def GetFileObjectClass(self
):
162 def GetModuleCount(self
):
163 if self
.GetFileObj() == None:
164 ErrorMsg("Fail to get module count because DSC file has not been load!")
166 return len(self
.GetFileObj().GetComponents())
168 def GetSupportArchs(self
):
169 return self
.GetFileObj().GetDefine("SUPPORTED_ARCHITECTURES").strip().split('#')[0].split('|')
171 def LoadModules(self
, precallback
=None, postcallback
=None):
172 for obj
in self
.GetFileObj().GetComponents():
173 mFilename
= obj
.GetFilename()
174 if precallback
!= None:
175 precallback(self
, mFilename
)
177 if arch
.lower() == 'common':
178 archarr
= self
.GetSupportArchs()
182 module
= Module(self
, self
.GetWorkspace())
183 if module
.Load(mFilename
, arch
, obj
.GetOveridePcds(), obj
.GetOverideLibs()):
184 self
._modules
.append(module
)
185 if postcallback
!= None:
186 postcallback(self
, module
)
189 ErrorMsg("Fail to load module %s" % mFilename
)
191 def GetModules(self
):
194 def GetLibraryPath(self
, classname
, arch
, type):
195 objs
= self
.GetFileObj().GetSectionObjectsByName("libraryclasses")
198 if classname
.lower() != obj
.GetClass().lower():
200 if obj
.GetArch().lower() != 'common' and \
201 obj
.GetArch().lower() != arch
.lower():
204 if obj
.GetModuleType().lower() != 'common' and \
205 obj
.GetModuleType().lower() != type.lower():
208 return obj
.GetInstance()
210 ErrorMsg("Fail to get library class %s [%s][%s] from platform %s" % (classname
, arch
, type, self
.GetFilename()))
213 def GetPackage(self
, path
):
214 package
= self
.GetParent().GetPackage(path
)
215 if package
not in self
._packages
:
216 self
._packages
.append(package
)
219 def GetPcdBuildObjs(self
, name
, arch
=None):
221 objs
= self
.GetFileObj().GetSectionObjectsByName('pcds')
223 if obj
.GetPcdName().lower() == name
.lower():
226 arr
= self
.FilterObjsByArch(arr
, arch
)
229 def Reload(self
, callback
=None):
230 # do not care force paramter for platform object
231 isFileChanged
= self
.GetFileObj().IsModified()
232 ret
= SurfaceObject
.Reload(self
, False)
233 if not ret
: return False
235 # destroy all modules and reload them again
236 for obj
in self
._modules
:
239 del self
._packages
[:]
240 self
.LoadModules(callback
)
242 for obj
in self
._modules
:
243 callback(self
, obj
.GetFilename())
249 def Modify(self
, modify
=True, modifiedObj
=None):
251 #LogMsg("%s is modified, modified object is %s" % (self.GetFilename(), modifiedObj))
252 if issubclass(modifiedObj
.__class
__, ini
.BaseINIFile
) and self
._isModify
:
254 self
._isModify
= modify
255 self
.GetParent().Modify(modify
, self
)
257 if self
.GetFileObj().IsModified():
259 for obj
in self
._modules
:
263 self
._isModify
= modify
264 self
.GetParent().Modify(modify
, self
)
266 def GetModuleObject(self
, relativePath
, arch
):
267 path
= os
.path
.normpath(relativePath
)
268 for obj
in self
._modules
:
269 if obj
.GetRelativeFilename() == path
:
270 if arch
.lower() == 'common':
272 if obj
.GetArch() == arch
:
276 def GenerateFullReferenceDsc(self
):
277 oldDsc
= self
.GetFileObj()
278 newDsc
= dsc
.DSCFile()
279 newDsc
.CopySectionsByName(oldDsc
, 'defines')
280 newDsc
.CopySectionsByName(oldDsc
, 'SkuIds')
283 # Dynamic common section should also be copied
285 newDsc
.CopySectionsByName(oldDsc
, 'PcdsDynamicDefault')
286 newDsc
.CopySectionsByName(oldDsc
, 'PcdsDynamicHii')
287 newDsc
.CopySectionsByName(oldDsc
, 'PcdsDynamicVpd')
288 newDsc
.CopySectionsByName(oldDsc
, 'PcdsDynamicEx')
290 sects
= oldDsc
.GetSectionByName('Components')
291 for oldSect
in sects
:
292 newSect
= newDsc
.AddNewSection(oldSect
.GetName())
293 for oldComObj
in oldSect
.GetObjects():
294 module
= self
.GetModuleObject(oldComObj
.GetFilename(), oldSect
.GetArch())
295 if module
== None: continue
297 newComObj
= dsc
.DSCComponentObject(newSect
)
298 newComObj
.SetFilename(oldComObj
.GetFilename())
300 # add all library instance for override section
301 libdict
= module
.GetLibraries()
302 for libclass
in libdict
.keys():
303 if libdict
[libclass
] != None:
304 newComObj
.AddOverideLib(libclass
, libdict
[libclass
].GetRelativeFilename().replace('\\', '/'))
306 # add all pcds for override section
307 pcddict
= module
.GetPcds()
308 for pcd
in pcddict
.values():
309 buildPcd
= pcd
.GetBuildObj()
310 buildType
= buildPcd
.GetPcdType()
312 if buildType
.lower() == 'pcdsdynamichii' or \
313 buildType
.lower() == 'pcdsdynamicvpd' or \
314 buildType
.lower() == 'pcdsdynamicdefault':
315 buildType
= 'PcdsDynamic'
316 if buildType
!= 'PcdsDynamic':
317 buildValue
= buildPcd
.GetPcdValue()
318 newComObj
.AddOveridePcd(buildPcd
.GetPcdName(),
321 newSect
.AddObject(newComObj
)
324 class Module(SurfaceObject
):
325 def __init__(self
, parent
, workspace
):
326 SurfaceObject
.__init
__(self
, parent
, workspace
)
327 self
._arch
= 'common'
328 self
._parent
= parent
329 self
._overidePcds
= {}
330 self
._overideLibs
= {}
340 for lib
in self
._libs
.values():
345 for pcd
in self
._pcds
.values():
349 for ppi
in self
._ppis
:
353 for protocol
in self
._protocols
:
356 del self
._protocols
[:]
358 for guid
in self
._guids
:
363 del self
._packages
[:]
365 SurfaceObject
.Destroy(self
)
367 def GetFileObjectClass(self
):
370 def GetLibraries(self
):
373 def Load(self
, filename
, arch
='common', overidePcds
=None, overideLibs
=None):
374 if not SurfaceObject
.Load(self
, filename
):
378 if overidePcds
!= None:
379 self
._overideLibs
= overideLibs
380 if overideLibs
!= None:
381 self
._overidePcds
= overidePcds
383 self
._SearchLibraries
()
384 self
._SearchPackage
()
385 self
._SearchSurfaceItems
()
391 def GetModuleName(self
):
392 return self
.GetFileObj().GetDefine("BASE_NAME")
394 def GetModuleType(self
):
395 return self
.GetFileObj().GetDefine("MODULE_TYPE")
397 def GetPlatform(self
):
398 return self
.GetParent()
400 def GetModuleObj(self
):
404 pcds
= self
._pcds
.copy()
405 for lib
in self
._libs
.values():
406 if lib
== None: continue
407 for name
in lib
._pcds
.keys():
408 pcds
[name
] = lib
._pcds
[name
]
414 for lib
in self
._libs
.values():
415 if lib
== None: continue
419 def GetProtocols(self
):
421 pros
= self
._protocols
422 for lib
in self
._libs
.values():
423 if lib
== None: continue
424 pros
+= lib
._protocols
430 for lib
in self
._libs
.values():
431 if lib
== None: continue
438 for lib
in self
._libs
.values():
439 if lib
== None: continue
444 return self
.GetFileObj().GetDefine("LIBRARY_CLASS") != None
446 def GetLibraryInstance(self
, classname
, arch
, type):
447 if classname
not in self
._libs
.keys():
448 # find in overide lib firstly
449 if classname
in self
._overideLibs
.keys():
450 self
._libs
[classname
] = Library(self
, self
.GetWorkspace())
451 self
._libs
[classname
].Load(self
._overideLibs
[classname
])
452 return self
._libs
[classname
]
454 parent
= self
.GetParent()
455 if issubclass(parent
.__class
__, Platform
):
456 path
= parent
.GetLibraryPath(classname
, arch
, type)
458 ErrorMsg('Fail to get library instance for %s' % classname
, self
.GetFilename())
460 self
._libs
[classname
] = Library(self
, self
.GetWorkspace())
461 if not self
._libs
[classname
].Load(path
, self
.GetArch()):
462 self
._libs
[classname
] = None
464 self
._libs
[classname
] = parent
.GetLibraryInstance(classname
, arch
, type)
465 return self
._libs
[classname
]
467 def GetSourceObjs(self
):
468 return self
.GetFileObj().GetSectionObjectsByName('source')
470 def _SearchLibraries(self
):
471 objs
= self
.GetFileObj().GetSectionObjectsByName('libraryclasses')
472 arch
= self
.GetArch()
473 type = self
.GetModuleType()
475 if obj
.GetArch().lower() != 'common' and \
476 obj
.GetArch().lower() not in self
.GetPlatform().GetSupportArchs():
478 classname
= obj
.GetClass()
479 instance
= self
.GetLibraryInstance(classname
, arch
, type)
480 if not self
.IsLibrary() and instance
!= None:
481 instance
._isInherit
= False
483 if classname
not in self
._libs
.keys():
484 self
._libs
[classname
] = instance
486 def _SearchSurfaceItems(self
):
487 # get surface item from self's inf
493 if self
.GetFileObj() != None:
494 pcds
= self
.FilterObjsByArch(self
.GetFileObj().GetSectionObjectsByName('pcd'),
497 if pcd
.GetPcdName() not in self
._pcds
.keys():
498 pcdItem
= PcdItem(pcd
.GetPcdName(), self
, pcd
)
499 self
._pcds
[pcd
.GetPcdName()] = ModulePcd(self
,
504 ppis
+= self
.FilterObjsByArch(self
.GetFileObj().GetSectionObjectsByName('ppis'),
508 item
= PpiItem(ppi
.GetName(), self
, ppi
)
509 if item
not in self
._ppis
:
510 self
._ppis
.append(item
)
512 pros
+= self
.FilterObjsByArch(self
.GetFileObj().GetSectionObjectsByName('protocols'),
516 item
= ProtocolItem(pro
.GetName(), self
, pro
)
517 if item
not in self
._protocols
:
518 self
._protocols
.append(item
)
520 deps
+= self
.FilterObjsByArch(self
.GetFileObj().GetSectionObjectsByName('depex'),
523 item
= DepexItem(self
, dep
)
524 self
._depexs
.append(item
)
526 guids
+= self
.FilterObjsByArch(self
.GetFileObj().GetSectionObjectsByName('guids'),
529 item
= GuidItem(guid
.GetName(), self
, guid
)
530 if item
not in self
._guids
:
531 self
._guids
.append(item
)
533 def _SearchPackage(self
):
534 objs
= self
.GetFileObj().GetSectionObjectsByName('packages')
536 package
= self
.GetPlatform().GetPackage(obj
.GetPath())
538 self
._packages
.append(package
)
540 def GetPackages(self
):
541 return self
._packages
543 def GetPcdObjects(self
):
544 if self
.GetFileObj() == None:
547 return self
.GetFileObj().GetSectionObjectsByName('pcd')
549 def GetLibraryClassHeaderFilePath(self
):
550 lcname
= self
.GetFileObj().GetProduceLibraryClass()
551 if lcname
== None: return None
553 pkgs
= self
.GetPackages()
555 path
= package
.GetLibraryClassHeaderPathByName(lcname
)
557 return os
.path
.realpath(os
.path
.join(package
.GetFileObj().GetPackageRootPath(), path
))
560 def Reload(self
, force
=False, callback
=None):
562 callback(self
, "Starting reload...")
564 ret
= SurfaceObject
.Reload(self
, force
)
565 if not ret
: return False
567 if not force
and not self
.IsModified():
570 for lib
in self
._libs
.values():
575 for pcd
in self
._pcds
.values():
579 for ppi
in self
._ppis
:
583 for protocol
in self
._protocols
:
585 del self
._protocols
[:]
587 for guid
in self
._guids
:
591 del self
._packages
[:]
595 callback(self
, "Searching libraries...")
596 self
._SearchLibraries
()
598 callback(self
, "Searching packages...")
599 self
._SearchPackage
()
601 callback(self
, "Searching surface items...")
602 self
._SearchSurfaceItems
()
607 def Modify(self
, modify
=True, modifiedObj
=None):
609 #LogMsg("%s is modified, modified object is %s" % (self.GetFilename(), modifiedObj))
610 if issubclass(modifiedObj
.__class
__, ini
.BaseINIFile
) and self
._isModify
:
612 self
._isModify
= modify
613 self
.GetParent().Modify(modify
, self
)
615 if self
.GetFileObj().IsModified():
618 self
._isModify
= modify
619 self
.GetParent().Modify(modify
, self
)
621 class Library(Module
):
622 def __init__(self
, parent
, workspace
):
623 Module
.__init
__(self
, parent
, workspace
)
624 self
._isInherit
= True
627 return self
._isInherit
629 def GetModuleType(self
):
630 return self
.GetParent().GetModuleType()
632 def GetPlatform(self
):
633 return self
.GetParent().GetParent()
635 def GetModuleObj(self
):
636 return self
.GetParent()
639 return self
.GetParent().GetArch()
644 SurfaceObject
.Destroy(self
)
646 class Package(SurfaceObject
):
647 def __init__(self
, parent
, workspace
):
648 SurfaceObject
.__init
__(self
, parent
, workspace
)
658 return self
._ppis
.values()
660 def GetProtocols(self
):
661 return self
._protocols
.values()
664 return self
._guids
.values()
667 for pcd
in self
._pcds
.values():
670 for guid
in self
._guids
.values():
673 for protocol
in self
._protocols
.values():
676 for ppi
in self
._ppis
.values():
681 self
._protocols
.clear()
684 SurfaceObject
.Destroy(self
)
686 def Load(self
, relativePath
):
687 ret
= SurfaceObject
.Load(self
, relativePath
)
688 if not ret
: return False
689 pcds
= self
.GetFileObj().GetSectionObjectsByName('pcds')
691 if pcd
.GetPcdName() in self
._pcds
.keys():
692 if self
._pcds
[pcd
.GetPcdName()] != None:
693 self
._pcds
[pcd
.GetPcdName()].AddDecObj(pcd
)
695 self
._pcds
[pcd
.GetPcdName()] = PcdItem(pcd
.GetPcdName(), self
, pcd
)
697 guids
= self
.GetFileObj().GetSectionObjectsByName('guids')
699 if guid
.GetName() not in self
._guids
.keys():
700 self
._guids
[guid
.GetName()] = GuidItem(guid
.GetName(), self
, guid
)
702 WarnMsg("Duplicate definition for %s" % guid
.GetName())
704 ppis
= self
.GetFileObj().GetSectionObjectsByName('ppis')
706 if ppi
.GetName() not in self
._ppis
.keys():
707 self
._ppis
[ppi
.GetName()] = PpiItem(ppi
.GetName(), self
, ppi
)
709 WarnMsg("Duplicate definition for %s" % ppi
.GetName())
711 protocols
= self
.GetFileObj().GetSectionObjectsByName('protocols')
712 for protocol
in protocols
:
713 if protocol
.GetName() not in self
._protocols
.keys():
714 self
._protocols
[protocol
.GetName()] = ProtocolItem(protocol
.GetName(), self
, protocol
)
716 WarnMsg("Duplicate definition for %s" % protocol
.GetName())
720 def GetFileObjectClass(self
):
724 return self
.GetFileObj().GetDefine("PACKAGE_NAME")
726 def GetPcdDefineObjs(self
, name
=None):
728 objs
= self
.GetFileObj().GetSectionObjectsByName('pcds')
729 if name
== None: return objs
732 if obj
.GetPcdName().lower() == name
.lower():
736 def GetLibraryClassObjs(self
):
737 return self
.GetFileObj().GetSectionObjectsByName('libraryclasses')
739 def Modify(self
, modify
=True, modifiedObj
=None):
741 self
._isModify
= modify
742 self
.GetParent().Modify(modify
, self
)
744 if self
.GetFileObj().IsModified():
747 self
._isModify
= modify
748 self
.GetParent().Modify(modify
, self
)
750 def GetLibraryClassHeaderPathByName(self
, clsname
):
751 objs
= self
.GetLibraryClassObjs()
753 if obj
.GetClassName() == clsname
:
754 return obj
.GetHeaderFile()
757 class DepexItem(object):
758 def __init__(self
, parent
, infObj
):
759 self
._parent
= parent
760 self
._infObj
= infObj
762 def GetDepexString(self
):
763 return str(self
._infObj
)
765 def GetInfObject(self
):
768 class ModulePcd(object):
769 _type_mapping
= {'FeaturePcd': 'PcdsFeatureFlag',
770 'FixedPcd': 'PcdsFixedAtBuild',
771 'PatchPcd': 'PcdsPatchableInModule'}
773 def __init__(self
, parent
, name
, infObj
, pcdItem
):
774 assert issubclass(parent
.__class
__, Module
), "Module's PCD's parent must be module!"
775 assert pcdItem
!= None, 'Pcd %s does not in some package!' % name
778 self
._parent
= parent
779 self
._pcdItem
= pcdItem
780 self
._infObj
= infObj
789 return self
._parent
.GetArch()
792 self
._pcdItem
.DeRef(self
._parent
)
795 def GetBuildObj(self
):
796 platformInfos
= self
._parent
.GetPlatform().GetPcdBuildObjs(self
._name
, self
.GetArch())
797 modulePcdType
= self
._infObj
.GetPcdType()
799 # if platform do not gives pcd's value, get default value from package
800 if len(platformInfos
) == 0:
801 if modulePcdType
.lower() == 'pcd':
802 return self
._pcdItem
.GetDecObject()
804 for obj
in self
._pcdItem
.GetDecObjects():
805 if modulePcdType
not in self
._type
_mapping
.keys():
806 ErrorMsg("Invalid PCD type %s" % modulePcdType
)
809 if self
._type
_mapping
[modulePcdType
] == obj
.GetPcdType():
811 ErrorMsg ('Module PCD type %s does not in valied range [%s] in package!' % \
814 if modulePcdType
.lower() == 'pcd':
815 if len(platformInfos
) > 1:
816 WarnMsg("Find more than one value for PCD %s in platform %s" % \
817 (self
._name
, self
._parent
.GetPlatform().GetFilename()))
818 return platformInfos
[0]
820 for obj
in platformInfos
:
821 if modulePcdType
not in self
._type
_mapping
.keys():
822 ErrorMsg("Invalid PCD type %s" % modulePcdType
)
825 if self
._type
_mapping
[modulePcdType
] == obj
.GetPcdType():
828 ErrorMsg('Can not find value for pcd %s in pcd type %s' % \
829 (self
._name
, modulePcdType
))
833 class SurfaceItem(object):
836 def __new__(cls
, *args
, **kwargs
):
837 """Maintain only a single instance of this object
838 @return: instance of this class
844 if issubclass(parent
.__class
__, Package
):
845 if name
in cls
._objs
.keys():
846 ErrorMsg("%s item is duplicated defined in packages: %s and %s" %
847 (name
, parent
.GetFilename(), cls
._objs
[name
].GetParent().GetFilename()))
849 obj
= object.__new
__(cls
, *args
, **kwargs
)
850 cls
._objs
[name
] = obj
852 elif issubclass(parent
.__class
__, Module
):
853 if name
not in cls
._objs
.keys():
854 ErrorMsg("%s item does not defined in any package! It is used by module %s" % \
855 (name
, parent
.GetFilename()))
857 return cls
._objs
[name
]
862 def __init__(self
, name
, parent
, fileObj
):
863 if issubclass(parent
.__class
__, Package
):
865 self
._parent
= parent
866 self
._decObj
= [fileObj
]
869 self
.RefModule(parent
, fileObj
)
872 def GetObjectDict(cls
):
878 def GetReference(self
):
881 def RefModule(self
, mObj
, infObj
):
882 if mObj
in self
._refMods
.keys():
884 self
._refMods
[mObj
] = infObj
886 def DeRef(self
, mObj
):
887 if mObj
not in self
._refMods
.keys():
888 WarnMsg("%s is not referenced by module %s" % (self
._name
, mObj
.GetFilename()))
890 del self
._refMods
[mObj
]
893 self
._refMods
.clear()
895 del cls
._objs
[self
._name
]
900 def GetDecObject(self
):
901 return self
._decObj
[0]
903 def GetDecObjects(self
):
906 class PcdItem(SurfaceItem
):
907 def AddDecObj(self
, fileObj
):
908 for decObj
in self
._decObj
:
909 if decObj
.GetFilename() != fileObj
.GetFilename():
910 ErrorMsg("Pcd %s defined in more than one packages : %s and %s" % \
911 (self
._name
, decObj
.GetFilename(), fileObj
.GetFilename()))
913 if decObj
.GetPcdType() == fileObj
.GetPcdType() and \
914 decObj
.GetArch().lower() == fileObj
.GetArch():
915 ErrorMsg("Pcd %s is duplicated defined in pcd type %s in package %s" % \
916 (self
._name
, decObj
.GetPcdType(), decObj
.GetFilename()))
918 self
._decObj
.append(fileObj
)
920 def GetValidPcdType(self
):
922 for obj
in self
._decObj
:
923 if obj
.GetPcdType() not in types
:
924 types
+= obj
.GetPcdType()
927 class GuidItem(SurfaceItem
):
930 class PpiItem(SurfaceItem
):
933 class ProtocolItem(SurfaceItem
):