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