]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Workspace/BuildClassObject.py
Check In tool source code based on Build tool project revision r1655.
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / BuildClassObject.py
1 ## @file
2 # This file is used to define each component of the build database
3 #
4 # Copyright (c) 2007 ~ 2008, Intel Corporation
5 # All rights reserved. This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
9 #
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.
12 #
13
14 import os
15
16 from Common.Misc import sdict
17 from Common.Misc import RealPath2
18 from Common.BuildToolError import *
19
20 ## PcdClassObject
21 #
22 # This Class is used for PcdObject
23 #
24 # @param object: Inherited from object class
25 # @param Name: Input value for Name of Pcd, default is None
26 # @param Guid: Input value for Guid of Pcd, default is None
27 # @param Type: Input value for Type of Pcd, default is None
28 # @param DatumType: Input value for DatumType of Pcd, default is None
29 # @param Value: Input value for Value of Pcd, default is None
30 # @param Token: Input value for Token of Pcd, default is None
31 # @param MaxDatumSize: Input value for MaxDatumSize of Pcd, default is None
32 # @param SkuInfoList: Input value for SkuInfoList of Pcd, default is {}
33 # @param IsOverrided: Input value for IsOverrided of Pcd, default is False
34 #
35 # @var TokenCName: To store value for TokenCName
36 # @var TokenSpaceGuidCName: To store value for TokenSpaceGuidCName
37 # @var Type: To store value for Type
38 # @var DatumType: To store value for DatumType
39 # @var TokenValue: To store value for TokenValue
40 # @var MaxDatumSize: To store value for MaxDatumSize
41 # @var SkuInfoList: To store value for SkuInfoList
42 # @var IsOverrided: To store value for IsOverrided
43 # @var Phase: To store value for Phase, default is "DXE"
44 #
45 class PcdClassObject(object):
46 def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}, GuidValue = None):
47 self.TokenCName = Name
48 self.TokenSpaceGuidCName = Guid
49 self.TokenSpaceGuidValue = GuidValue
50 self.Type = Type
51 self.DatumType = DatumType
52 self.DefaultValue = Value
53 self.TokenValue = Token
54 self.MaxDatumSize = MaxDatumSize
55 self.SkuInfoList = SkuInfoList
56 self.Phase = "DXE"
57 self.Pending = False
58
59 ## Convert the class to a string
60 #
61 # Convert each member of the class to string
62 # Organize to a signle line format string
63 #
64 # @retval Rtn Formatted String
65 #
66 def __str__(self):
67 Rtn = '\tTokenCName=' + str(self.TokenCName) + ', ' + \
68 'TokenSpaceGuidCName=' + str(self.TokenSpaceGuidCName) + ', ' + \
69 'Type=' + str(self.Type) + ', ' + \
70 'DatumType=' + str(self.DatumType) + ', ' + \
71 'DefaultValue=' + str(self.DefaultValue) + ', ' + \
72 'TokenValue=' + str(self.TokenValue) + ', ' + \
73 'MaxDatumSize=' + str(self.MaxDatumSize) + ', '
74 for Item in self.SkuInfoList.values():
75 Rtn = Rtn + 'SkuId=' + Item.SkuId + ', ' + 'SkuIdName=' + Item.SkuIdName
76 Rtn = Rtn + str(self.IsOverrided)
77
78 return Rtn
79
80 ## Override __eq__ function
81 #
82 # Check whether pcds are the same
83 #
84 # @retval False The two pcds are different
85 # @retval True The two pcds are the same
86 #
87 def __eq__(self, Other):
88 return Other and self.TokenCName == Other.TokenCName and self.TokenSpaceGuidCName == Other.TokenSpaceGuidCName
89
90 ## Override __hash__ function
91 #
92 # Use (TokenCName, TokenSpaceGuidCName) as key in hash table
93 #
94 # @retval truple() Key for hash table
95 #
96 def __hash__(self):
97 return hash((self.TokenCName, self.TokenSpaceGuidCName))
98
99 ## LibraryClassObject
100 #
101 # This Class defines LibraryClassObject used in BuildDatabase
102 #
103 # @param object: Inherited from object class
104 # @param Name: Input value for LibraryClassName, default is None
105 # @param SupModList: Input value for SupModList, default is []
106 # @param Type: Input value for Type, default is None
107 #
108 # @var LibraryClass: To store value for LibraryClass
109 # @var SupModList: To store value for SupModList
110 # @var Type: To store value for Type
111 #
112 class LibraryClassObject(object):
113 def __init__(self, Name = None, SupModList = [], Type = None):
114 self.LibraryClass = Name
115 self.SupModList = SupModList
116 if Type != None:
117 self.SupModList = CleanString(Type).split(DataType.TAB_SPACE_SPLIT)
118
119 ## ModuleBuildClassObject
120 #
121 # This Class defines ModuleBuildClass
122 #
123 # @param object: Inherited from object class
124 #
125 # @var MetaFile: To store value for module meta file path
126 # @var BaseName: To store value for BaseName
127 # @var ModuleType: To store value for ModuleType
128 # @var Guid: To store value for Guid
129 # @var Version: To store value for Version
130 # @var PcdIsDriver: To store value for PcdIsDriver
131 # @var BinaryModule: To store value for BinaryModule
132 # @var CustomMakefile: To store value for CustomMakefile
133 # @var Specification: To store value for Specification
134 # @var Shadow To store value for Shadow
135 # @var LibraryClass: To store value for LibraryClass, it is a list structure as
136 # [ LibraryClassObject, ...]
137 # @var ModuleEntryPointList: To store value for ModuleEntryPointList
138 # @var ModuleUnloadImageList: To store value for ModuleUnloadImageList
139 # @var ConstructorList: To store value for ConstructorList
140 # @var DestructorList: To store value for DestructorList
141 # @var Binaries: To store value for Binaries, it is a list structure as
142 # [ ModuleBinaryClassObject, ...]
143 # @var Sources: To store value for Sources, it is a list structure as
144 # [ ModuleSourceFilesClassObject, ... ]
145 # @var LibraryClasses: To store value for LibraryClasses, it is a set structure as
146 # { [LibraryClassName, ModuleType] : LibraryClassInfFile }
147 # @var Protocols: To store value for Protocols, it is a list structure as
148 # [ ProtocolName, ... ]
149 # @var Ppis: To store value for Ppis, it is a list structure as
150 # [ PpiName, ... ]
151 # @var Guids: To store value for Guids, it is a list structure as
152 # [ GuidName, ... ]
153 # @var Includes: To store value for Includes, it is a list structure as
154 # [ IncludePath, ... ]
155 # @var Packages: To store value for Packages, it is a list structure as
156 # [ DecFileName, ... ]
157 # @var Pcds: To store value for Pcds, it is a set structure as
158 # { [(PcdCName, PcdGuidCName)] : PcdClassObject}
159 # @var BuildOptions: To store value for BuildOptions, it is a set structure as
160 # { [BuildOptionKey] : BuildOptionValue}
161 # @var Depex: To store value for Depex
162 #
163 class ModuleBuildClassObject(object):
164 def __init__(self):
165 self.AutoGenVersion = 0
166 self.MetaFile = ''
167 self.BaseName = ''
168 self.ModuleType = ''
169 self.Guid = ''
170 self.Version = ''
171 self.PcdIsDriver = ''
172 self.BinaryModule = ''
173 self.Shadow = ''
174 self.SourceOverridePath = ''
175 self.CustomMakefile = {}
176 self.Specification = {}
177 self.LibraryClass = []
178 self.ModuleEntryPointList = []
179 self.ModuleUnloadImageList = []
180 self.ConstructorList = []
181 self.DestructorList = []
182
183 self.Binaries = []
184 self.Sources = []
185 self.LibraryClasses = sdict()
186 self.Libraries = []
187 self.Protocols = []
188 self.Ppis = []
189 self.Guids = []
190 self.Includes = []
191 self.Packages = []
192 self.Pcds = {}
193 self.BuildOptions = {}
194 self.Depex = {}
195
196 ## Convert the class to a string
197 #
198 # Convert member MetaFile of the class to a string
199 #
200 # @retval string Formatted String
201 #
202 def __str__(self):
203 return str(self.MetaFile)
204
205 ## Override __eq__ function
206 #
207 # Check whether ModuleBuildClassObjects are the same
208 #
209 # @retval False The two ModuleBuildClassObjects are different
210 # @retval True The two ModuleBuildClassObjects are the same
211 #
212 def __eq__(self, Other):
213 return self.MetaFile == Other
214
215 ## Override __hash__ function
216 #
217 # Use MetaFile as key in hash table
218 #
219 # @retval string Key for hash table
220 #
221 def __hash__(self):
222 return hash(self.MetaFile)
223
224 ## PackageBuildClassObject
225 #
226 # This Class defines PackageBuildClass
227 #
228 # @param object: Inherited from object class
229 #
230 # @var MetaFile: To store value for package meta file path
231 # @var PackageName: To store value for PackageName
232 # @var Guid: To store value for Guid
233 # @var Version: To store value for Version
234 # @var Protocols: To store value for Protocols, it is a set structure as
235 # { [ProtocolName] : Protocol Guid, ... }
236 # @var Ppis: To store value for Ppis, it is a set structure as
237 # { [PpiName] : Ppi Guid, ... }
238 # @var Guids: To store value for Guids, it is a set structure as
239 # { [GuidName] : Guid, ... }
240 # @var Includes: To store value for Includes, it is a list structure as
241 # [ IncludePath, ... ]
242 # @var LibraryClasses: To store value for LibraryClasses, it is a set structure as
243 # { [LibraryClassName] : LibraryClassInfFile }
244 # @var Pcds: To store value for Pcds, it is a set structure as
245 # { [(PcdCName, PcdGuidCName)] : PcdClassObject}
246 #
247 class PackageBuildClassObject(object):
248 def __init__(self):
249 self.MetaFile = ''
250 self.PackageName = ''
251 self.Guid = ''
252 self.Version = ''
253
254 self.Protocols = {}
255 self.Ppis = {}
256 self.Guids = {}
257 self.Includes = []
258 self.LibraryClasses = {}
259 self.Pcds = {}
260
261 ## Convert the class to a string
262 #
263 # Convert member MetaFile of the class to a string
264 #
265 # @retval string Formatted String
266 #
267 def __str__(self):
268 return str(self.MetaFile)
269
270 ## Override __eq__ function
271 #
272 # Check whether PackageBuildClassObjects are the same
273 #
274 # @retval False The two PackageBuildClassObjects are different
275 # @retval True The two PackageBuildClassObjects are the same
276 #
277 def __eq__(self, Other):
278 return self.MetaFile == Other
279
280 ## Override __hash__ function
281 #
282 # Use MetaFile as key in hash table
283 #
284 # @retval string Key for hash table
285 #
286 def __hash__(self):
287 return hash(self.MetaFile)
288
289 ## PlatformBuildClassObject
290 #
291 # This Class defines PlatformBuildClass
292 #
293 # @param object: Inherited from object class
294 #
295 # @var MetaFile: To store value for platform meta-file path
296 # @var PlatformName: To store value for PlatformName
297 # @var Guid: To store value for Guid
298 # @var Version: To store value for Version
299 # @var DscSpecification: To store value for DscSpecification
300 # @var OutputDirectory: To store value for OutputDirectory
301 # @var FlashDefinition: To store value for FlashDefinition
302 # @var BuildNumber: To store value for BuildNumber
303 # @var MakefileName: To store value for MakefileName
304 # @var SkuIds: To store value for SkuIds, it is a set structure as
305 # { 'SkuName' : SkuId, '!include' : includefilename, ...}
306 # @var Modules: To store value for Modules, it is a list structure as
307 # [ InfFileName, ... ]
308 # @var Libraries: To store value for Libraries, it is a list structure as
309 # [ InfFileName, ... ]
310 # @var LibraryClasses: To store value for LibraryClasses, it is a set structure as
311 # { (LibraryClassName, ModuleType) : LibraryClassInfFile }
312 # @var Pcds: To store value for Pcds, it is a set structure as
313 # { [(PcdCName, PcdGuidCName)] : PcdClassObject }
314 # @var BuildOptions: To store value for BuildOptions, it is a set structure as
315 # { [BuildOptionKey] : BuildOptionValue }
316 #
317 class PlatformBuildClassObject(object):
318 def __init__(self):
319 self.MetaFile = ''
320 self.PlatformName = ''
321 self.Guid = ''
322 self.Version = ''
323 self.DscSpecification = ''
324 self.OutputDirectory = ''
325 self.FlashDefinition = ''
326 self.BuildNumber = ''
327 self.MakefileName = ''
328
329 self.SkuIds = {}
330 self.Modules = []
331 self.LibraryInstances = []
332 self.LibraryClasses = {}
333 self.Libraries = {}
334 self.Pcds = {}
335 self.BuildOptions = {}
336
337 ## Convert the class to a string
338 #
339 # Convert member MetaFile of the class to a string
340 #
341 # @retval string Formatted String
342 #
343 def __str__(self):
344 return str(self.MetaFile)
345
346 ## Override __eq__ function
347 #
348 # Check whether PlatformBuildClassObjects are the same
349 #
350 # @retval False The two PlatformBuildClassObjects are different
351 # @retval True The two PlatformBuildClassObjects are the same
352 #
353 def __eq__(self, Other):
354 return self.MetaFile == Other
355
356 ## Override __hash__ function
357 #
358 # Use MetaFile as key in hash table
359 #
360 # @retval string Key for hash table
361 #
362 def __hash__(self):
363 return hash(self.MetaFile)
364