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