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