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