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