git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@417 7335b...
[people/mcb30/basetools.git] / Source / Python / Common / EdkIIWorkspaceBuild.py
1 # Copyright (c) 2007, Intel Corporation\r
2 # All rights reserved. This program and the accompanying materials\r
3 # are licensed and made available under the terms and conditions of the BSD License\r
4 # which accompanies this distribution.    The full text of the license may be found at\r
5 # http://opensource.org/licenses/bsd-license.php\r
6 #\r
7 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
8 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
9 \r
10 #\r
11 # This file is used to define each component of the build database\r
12 #\r
13 \r
14 #\r
15 # Import Modules\r
16 #\r
17 import os, string, copy, pdb\r
18 import EdkLogger\r
19 import DataType\r
20 from InfClassObject import *\r
21 from DecClassObject import *\r
22 from DscClassObject import *\r
23 from String import *\r
24 from BuildToolError import *\r
25 from CommonDataClass.CommonClass import *\r
26 \r
27 class ModuleSourceFilesClassObject(object):\r
28     def __init__(self, SourceFile = '', PcdFeatureFlag = '', TagName = '', ToolCode = '', ToolChainFamily = '', String = ''):\r
29         self.SourceFile         = SourceFile\r
30         self.TagName            = TagName\r
31         self.ToolCode           = ToolCode\r
32         self.ToolChainFamily    = ToolChainFamily\r
33         self.String             = String\r
34         self.PcdFeatureFlag     = PcdFeatureFlag\r
35     \r
36     def __str__(self):\r
37         return self.SourceFile\r
38     \r
39     def __repr__(self):\r
40         rtn = self.SourceFile + DataType.TAB_VALUE_SPLIT + \\r
41               self.PcdFeatureFlag + DataType.TAB_VALUE_SPLIT + \\r
42               self.ToolChainFamily +  DataType.TAB_VALUE_SPLIT + \\r
43               self.TagName + DataType.TAB_VALUE_SPLIT + \\r
44               self.ToolCode + DataType.TAB_VALUE_SPLIT + \\r
45               self.String\r
46         return rtn\r
47 \r
48 class ModuleBinaryFilesClassObject(object):\r
49     def __init__(self, BinaryFile = '', FileType = '', Target = '', PcdFeatureFlag = ''):\r
50         self.BinaryFile = BinaryFile\r
51         self.FileType =FileType\r
52         self.Target = Target\r
53         self.PcdFeatureFlag = PcdFeatureFlag\r
54     \r
55     def __str__(self):\r
56         rtn = self.BinaryFile + DataType.TAB_VALUE_SPLIT + \\r
57               self.FileType + DataType.TAB_VALUE_SPLIT + \\r
58               self.Target +  DataType.TAB_VALUE_SPLIT + \\r
59               self.PcdFeatureFlag\r
60         return rtn\r
61         \r
62 class PcdClassObject(object):\r
63     def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = []):\r
64         self.TokenCName = Name\r
65         self.TokenSpaceGuidCName = Guid\r
66         self.Type = Type\r
67         self.DatumType = DatumType\r
68         self.DefaultValue = Value\r
69         self.TokenValue = Token\r
70         self.MaxDatumSize = MaxDatumSize\r
71         self.SkuInfoList = SkuInfoList\r
72         self.Phase = "DXE"\r
73         \r
74     def __str__(self):\r
75         rtn = str(self.TokenCName) + DataType.TAB_VALUE_SPLIT + \\r
76               str(self.TokenSpaceGuidCName) + DataType.TAB_VALUE_SPLIT + \\r
77               str(self.Type) + DataType.TAB_VALUE_SPLIT + \\r
78               str(self.DatumType) + DataType.TAB_VALUE_SPLIT + \\r
79               str(self.DefaultValue) + DataType.TAB_VALUE_SPLIT + \\r
80               str(self.TokenValue) + DataType.TAB_VALUE_SPLIT + \\r
81               str(self.MaxDatumSize) + DataType.TAB_VALUE_SPLIT\r
82         for Item in self.SkuInfoList:\r
83             rtn = rtn + str(Item)\r
84         return rtn\r
85 \r
86     def __eq__(self, other):\r
87         return other != None and self.TokenCName == other.TokenCName and self.TokenSpaceGuidCName == other.TokenSpaceGuidCName\r
88 \r
89     def __hash__(self):\r
90         return hash((self.TokenCName, self.TokenSpaceGuidCName))\r
91 \r
92 class LibraryClassObject(object):\r
93     def __init__(self, Name = None, Type = None):\r
94         self.LibraryClass = Name\r
95         self.SupModList = []\r
96         if Type != None:\r
97             self.SupModList = CleanString(Type).split(DataType.TAB_SPACE_SPLIT)\r
98         \r
99 class ModuleBuildClassObject(object):\r
100     def __init__(self):\r
101         self.DescFilePath            = ''\r
102         self.BaseName                = ''\r
103         self.ModuleType              = ''\r
104         self.Guid                    = ''\r
105         self.Version                 = ''\r
106         self.PcdIsDriver             = ''\r
107         self.BinaryModule            = ''\r
108         self.CustomMakefile          = {}\r
109         self.Specification           = {}\r
110         self.LibraryClass            = None      # LibraryClassObject\r
111         self.ModuleEntryPointList    = []\r
112         self.ModuleUnloadImageList   = []\r
113         self.ConstructorList         = []\r
114         self.DestructorList          = []\r
115         \r
116         self.Binaries                = []        #[ ModuleBinaryClassObject, ...]\r
117         self.Sources                 = []        #[ ModuleSourceFilesClassObject, ... ]\r
118         self.LibraryClasses          = {}        #{ [LibraryClassName, ModuleType] : LibraryClassInfFile }\r
119         self.Protocols               = []        #[ ProtocolName, ... ]\r
120         self.Ppis                    = []        #[ PpiName, ... ]\r
121         self.Guids                   = []        #[ GuidName, ... ]\r
122         self.Includes                = []        #[ IncludePath, ... ]\r
123         self.Packages                = []        #[ DecFileName, ... ]\r
124         self.Pcds                    = {}        #{ [(PcdCName, PcdGuidCName)] : PcdClassObject}\r
125         self.BuildOptions            = {}        #{ [BuildOptionKey] : BuildOptionValue}\r
126         self.Depex                   = ''\r
127 \r
128     def __str__(self):\r
129         return self.DescFilePath\r
130 \r
131     def __eq__(self, other):\r
132         return self.DescFilePath == str(other)\r
133 \r
134     def __hash__(self):\r
135         return hash(self.DescFilePath)\r
136 \r
137 class PackageBuildClassObject(object):\r
138     def __init__(self):\r
139         self.DescFilePath            = ''\r
140         self.PackageName             = ''\r
141         self.Guid                    = ''\r
142         self.Version                 = ''\r
143         \r
144         self.Protocols               = {}       #{ [ProtocolName] : Protocol Guid, ... }\r
145         self.Ppis                    = {}       #{ [PpiName] : Ppi Guid, ... }\r
146         self.Guids                   = {}       #{ [GuidName] : Guid, ... }\r
147         self.Includes                = []       #[ IncludePath, ... ]        \r
148         self.LibraryClasses          = {}       #{ [LibraryClassName] : LibraryClassInfFile }\r
149         self.Pcds                    = {}       #{ [(PcdCName, PcdGuidCName)] : PcdClassObject}\r
150         \r
151     def __str__(self):\r
152         return self.DescFilePath\r
153 \r
154     def __eq__(self, other):\r
155         return self.DescFilePath == str(other)\r
156 \r
157     def __hash__(self):\r
158         return hash(self.DescFilePath)\r
159 \r
160 class PlatformBuildClassObject(object):\r
161     def __init__(self):\r
162         self.DescFilePath            = ''\r
163         self.PlatformName            = ''\r
164         self.Guid                    = ''\r
165         self.Version                 = ''\r
166         self.DscSpecification        = ''\r
167         self.OutputDirectory         = ''\r
168         self.FlashDefinition         = ''\r
169         self.BuildNumber             = ''\r
170         self.MakefileName            = ''\r
171                 \r
172         self.SkuIds                  = {}       #{ 'SkuName' : SkuId, '!include' : includefilename, ...}\r
173         self.Modules                 = []       #[ InfFileName, ... ]\r
174         self.LibraryClasses          = {}       #{ (LibraryClassName, ModuleType) : LibraryClassInfFile }\r
175         self.Pcds                    = {}       #{ [(PcdCName, PcdGuidCName)] : PcdClassObject }\r
176         self.BuildOptions            = {}       #{ [BuildOptionKey] : BuildOptionValue }    \r
177 \r
178     def __str__(self):\r
179         return self.DescFilePath\r
180 \r
181     def __eq__(self, other):\r
182         return self.DescFilePath == str(other)\r
183 \r
184     def __hash__(self):\r
185         return hash(self.DescFilePath)\r
186 \r
187 class ItemBuild(object):\r
188     def __init__(self, Arch, Platform = None, Package = None, Module = None):\r
189         self.Arch                    = Arch\r
190         self.PlatformDatabase        = {}        #{ [DscFileName] : PlatformBuildClassObject, ...}\r
191         self.PackageDatabase         = {}        #{ [DecFileName] : PacakgeBuildClassObject, ...}\r
192         self.ModuleDatabase          = {}        #{ [InfFileName] : ModuleBuildClassObject, ...}\r
193         \r
194 class WorkspaceBuild(object):\r
195     def __init__(self, ActivePlatform, WorkspaceDir):\r
196         self.WorkspaceDir            = NormPath(WorkspaceDir)\r
197         self.SupArchList             = []        #[ 'IA32', 'X64', ...]\r
198         self.BuildTarget             = []        #[ 'RELEASE', 'DEBUG']\r
199         self.SkuId                   = ''\r
200         self.Fdf                     = ''\r
201         self.TargetTxt               = None\r
202         self.ToolDef                 = None\r
203         \r
204         self.InfDatabase             = {}        #{ [InfFileName] : InfClassObject}\r
205         self.DecDatabase             = {}        #{ [DecFileName] : DecClassObject}\r
206         self.DscDatabase             = {}        #{ [DscFileName] : DscClassObject}\r
207         \r
208         self.Build                   = {}\r
209         for Arch in DataType.ARCH_LIST:\r
210             self.Build[Arch] = ItemBuild(Arch)\r
211         \r
212         #\r
213         # Get active platform\r
214         #\r
215         DscFileName = ActivePlatform\r
216         File = self.WorkspaceFile(NormPath(DscFileName))\r
217         if os.path.exists(File) and os.path.isfile(File):\r
218             self.DscDatabase[DscFileName] = Dsc(File, True, True)\r
219         else:\r
220             raise ParserError(FILE_NOT_FOUND, name = File)\r
221         \r
222         #\r
223         # parse platform to get module\r
224         #\r
225         for DscFile in self.DscDatabase.keys():\r
226             Platform = self.DscDatabase[DscFile].Platform\r
227             \r
228             #\r
229             # Get global information\r
230             #\r
231             self.SupArchList = Platform.Header.SupArchList\r
232             self.BuildTarget = Platform.Header.BuildTargets\r
233             self.SkuId = Platform.Header.SkuIdName\r
234             self.Fdf = Platform.FlashDefinitionFile.FilePath\r
235             \r
236             #\r
237             # Get all inf files\r
238             #\r
239             for Item in Platform.Libraries.LibraryList:\r
240                 for Arch in Item.SupArchList:\r
241                     self.AddToInfDatabase(Item.FilePath)\r
242             \r
243             for Item in Platform.Modules.ModuleList:\r
244                 for Arch in Item.SupArchList:\r
245                     #\r
246                     # Add modules\r
247                     #\r
248                     Module = Item.FilePath\r
249                     self.AddToInfDatabase(Module)\r
250                     #\r
251                     # Add library used in modules\r
252                     #\r
253                     for Lib in Item.LibraryClasses.LibraryList:\r
254                         self.AddToInfDatabase(Lib.FilePath)\r
255                         self.UpdateLibraryClassOfModule(Module, Lib.Name, Arch)\r
256         #End For of Dsc\r
257         \r
258         #parse module to get package\r
259         for InfFile in self.InfDatabase.keys():\r
260             Module = self.InfDatabase[InfFile].Module\r
261             #Get all dec\r
262             for Item in Module.PackageDependencies:\r
263                 for Arch in Item.SupArchList:\r
264                     self.AddToDecDatabase(Item.FilePath)\r
265 #            for key in DataType.ARCH_LIST:\r
266 #                for index in range(len(infObj.Contents[key].Packages)):\r
267 #                    self.AddToDecDatabase(infObj.Contents[key].Packages[index])\r
268     #End of self.Init()\r
269     \r
270     #\r
271     # Return a full path with workspace dir\r
272     #\r
273     def WorkspaceFile(self, Filename):\r
274         return os.path.join(os.path.normpath(self.WorkspaceDir), os.path.normpath(Filename))\r
275     \r
276     def GenBuildDatabase(self, PcdsSet = {}):\r
277         #Build databases\r
278         #Build PlatformDatabase\r
279         for dsc in self.DscDatabase.keys():\r
280             dscObj = self.DscDatabase[dsc]\r
281             \r
282             for key in DataType.ARCH_LIST:\r
283                 pb = PlatformBuildClassObject()\r
284                 pb.DescFilePath = dsc\r
285                 pb.PlatformName = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_PLATFORM_NAME][0]\r
286                 pb.Guid = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_PLATFORM_GUID][0]\r
287                 pb.Version = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_PLATFORM_VERSION][0]\r
288                 pb.DscSpecification = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_DSC_SPECIFICATION][0]\r
289                 pb.OutputDirectory = NormPath(dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_OUTPUT_DIRECTORY][0])\r
290                 pb.FlashDefinition = NormPath(dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_FLASH_DEFINITION][0])\r
291                 pb.BuildNumber = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_BUILD_NUMBER][0]\r
292                 pb.MakefileName = NormPath(dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_MAKEFILE_NAME][0])\r
293                 \r
294                 #SkuId\r
295                 for index in range(len(dscObj.Contents[key].SkuIds)):\r
296                     SkuInfo = dscObj.Contents[key].SkuIds[index]\r
297                     SkuName = ''\r
298                     SkuId = ''\r
299                     if SkuInfo.find('!include') > -1:\r
300                         SkuName = '!include'\r
301                         SkuId = NormPath(CleanString(SkuInfo[SkuInfo.find('!include') + len('!include'):]))\r
302                     elif len(SkuInfo.split(DataType.TAB_VALUE_SPLIT)) == 2:\r
303                         SkuName = CleanString(SkuInfo.split(DataType.TAB_VALUE_SPLIT)[1])\r
304                         SkuId = CleanString(SkuInfo.split(DataType.TAB_VALUE_SPLIT)[0])\r
305                     else:\r
306                         raise ParseError('Wrong defintion for SkuId: %s' % SkuInfo)\r
307                     pb.SkuIds[SkuName] = SkuId\r
308                 \r
309                 #Module\r
310                 for index in range(len(dscObj.Contents[key].Components)):\r
311                     pb.Modules.append(NormPath(dscObj.Contents[key].Components[index][0]))\r
312                 \r
313                 #BuildOptions\r
314                 for index in range(len(dscObj.Contents[key].BuildOptions)):\r
315                     b = dscObj.Contents[key].BuildOptions[index].split(DataType.TAB_EQUAL_SPLIT, 1)\r
316                     Family = ''\r
317                     ToolChain = ''\r
318                     Flag = ''\r
319                     if b[0].find(':') > -1:\r
320                         Family = CleanString(b[0][ : b[0].find(':')])\r
321                         ToolChain = CleanString(b[0][b[0].find(':') + 1 : ])\r
322                     else:\r
323                         ToolChain = CleanString(b[0])\r
324                     Flag = CleanString(b[1])\r
325                     pb.BuildOptions[(Family, ToolChain)] = Flag\r
326                     \r
327                 #LibraryClass\r
328                 for index in range(len(dscObj.Contents[key].LibraryClasses)):\r
329                     #['DebugLib|MdePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf', ['DXE_CORE']]\r
330                     list = dscObj.Contents[key].LibraryClasses[index][0].split(DataType.TAB_VALUE_SPLIT, 1)\r
331                     type = dscObj.Contents[key].LibraryClasses[index][1][0]\r
332                     pb.LibraryClasses[(list[0], type)] = NormPath(list[1])\r
333 \r
334                 #Pcds\r
335                 for index in range(len(dscObj.Contents[key].PcdsFixedAtBuild)):\r
336                     pcd = dscObj.Contents[key].PcdsFixedAtBuild[index].split(DataType.TAB_VALUE_SPLIT)\r
337                     pcd.append(None)\r
338                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_FIXED_AT_BUILD, None, pcd[2], None, pcd[3])\r
339                 for index in range(len(dscObj.Contents[key].PcdsPatchableInModule)):\r
340                     pcd = dscObj.Contents[key].PcdsPatchableInModule[index].split(DataType.TAB_VALUE_SPLIT)\r
341                     pcd.append(None)\r
342                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_PATCHABLE_IN_MODULE, None, pcd[2], None, pcd[3])\r
343                 for index in range(len(dscObj.Contents[key].PcdsFeatureFlag)):\r
344                     pcd = dscObj.Contents[key].PcdsFeatureFlag[index].split(DataType.TAB_VALUE_SPLIT)\r
345                     pcd.append(None)                    \r
346                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_FEATURE_FLAG, None, pcd[2], None, pcd[3])\r
347                 #\r
348                 # PcdsDynamic\r
349                 #\r
350                 for index in range(len(dscObj.Contents[key].PcdsDynamicDefault)):\r
351                     pcd = dscObj.Contents[key].PcdsDynamicDefault[index][0].split(DataType.TAB_VALUE_SPLIT)\r
352                     pcd.append(None)\r
353                     SkuName = dscObj.Contents[key].PcdsDynamicDefault[index][1]\r
354                     SkuInfoList = []\r
355                     if SkuName == None or SkuName == [] or SkuName == ['']:\r
356                         SkuName = ['DEFAULT']\r
357                     SkuNameList = map(lambda l: l.strip(), SkuName[0].split(DataType.TAB_VALUE_SPLIT))\r
358                     for Item in SkuNameList:\r
359                         SkuInfo = SkuInfoClass()\r
360                         SkuInfo.SkuId = Item[1]\r
361                         SkuInfo.DefaultValue = pcd[2]\r
362                         SkuInfoList.append(SkuInfo)\r
363                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_DEFAULT, None, None, None, pcd[3], SkuInfoList)\r
364                 for index in range(len(dscObj.Contents[key].PcdsDynamicVpd)):\r
365                     pcd = dscObj.Contents[key].PcdsDynamicVpd[index][0].split(DataType.TAB_VALUE_SPLIT)\r
366                     pcd.append(None)\r
367                     SkuId = dscObj.Contents[key].PcdsDynamicVpd[index][1]\r
368                     SkuInfoList = []\r
369                     if SkuId == None:\r
370                         SkuId = 'DEFAULT'\r
371                     SkuIdList = map(lambda l: l.strip(), SkuId.split(DataType.TAB_VALUE_SPLIT))\r
372                     for Item in SkuIdList:\r
373                         SkuInfo = SkuInfoClassObject()\r
374                         SkuInfo.SkuId = Item\r
375                         SkuInfo.VpdOffset = pcd[2]\r
376                         SkuInfoList.append(SkuInfo)\r
377                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_VPD, None, None, None, pcd[3], SkuInfoList)\r
378                 for index in range(len(dscObj.Contents[key].PcdsDynamicHii)):\r
379                     pcd = dscObj.Contents[key].PcdsDynamicHii[index][0].split(DataType.TAB_VALUE_SPLIT)\r
380                     pcd.append(None)\r
381                     SkuId = dscObj.Contents[key].PcdsDynamicHii[index][1]\r
382                     SkuInfoList = []\r
383                     if SkuId == None:\r
384                         SkuId = 'DEFAULT'\r
385                     SkuIdList = map(lambda l: l.strip(), SkuId.split(DataType.TAB_VALUE_SPLIT))\r
386                     for Item in SkuIdList:\r
387                         SkuInfo = SkuInfoClassObject()\r
388                         SkuInfo.SkuId = Item\r
389                         SkuInfo.VariableName = pcd[2]\r
390                         SkuInfo.VariableGuid = pcd[3]\r
391                         SkuInfo.VariableOffset = pcd[4]\r
392                         SkuInfo.HiiDefaultValue = pcd[5]                                                \r
393                         SkuInfoList.append(SkuInfo)\r
394                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_HII, None, None, None, pcd[6], SkuInfoList)\r
395                 #\r
396                 # PcdsDynamicEx\r
397                 #\r
398                 for index in range(len(dscObj.Contents[key].PcdsDynamicExDefault)):\r
399                     pcd = dscObj.Contents[key].PcdsDynamicExDefault[index][0].split(DataType.TAB_VALUE_SPLIT)\r
400                     pcd.append(None)\r
401                     SkuId = dscObj.Contents[key].PcdsDynamicExDefault[index][1]\r
402                     SkuInfoList = []\r
403                     if SkuId == None:\r
404                         SkuId = 'DEFAULT'\r
405                     SkuIdList = map(lambda l: l.strip(), SkuId.split(DataType.TAB_VALUE_SPLIT))\r
406                     for Item in SkuIdList:\r
407                         SkuInfo = SkuInfoClassObject()\r
408                         SkuInfo.SkuId = Item\r
409                         SkuInfo.DefaultValue = pcd[2]\r
410                         SkuInfoList.append(SkuInfo)\r
411                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_EX_DEFAULT, None, None, None, pcd[3], SkuInfoList)\r
412                 for index in range(len(dscObj.Contents[key].PcdsDynamicExVpd)):\r
413                     pcd = dscObj.Contents[key].PcdsDynamicExVpd[index][0].split(DataType.TAB_VALUE_SPLIT)\r
414                     pcd.append(None)\r
415                     SkuId = dscObj.Contents[key].PcdsDynamicExVpd[index][1]\r
416                     SkuInfoList = []\r
417                     if SkuId == None:\r
418                         SkuId = 'DEFAULT'\r
419                     SkuIdList = map(lambda l: l.strip(), SkuId.split(DataType.TAB_VALUE_SPLIT))\r
420                     for Item in SkuIdList:\r
421                         SkuInfo = SkuInfoClassObject()\r
422                         SkuInfo.SkuId = Item\r
423                         SkuInfo.VpdOffset = pcd[2]\r
424                         SkuInfoList.append(SkuInfo)\r
425                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_EX_VPD, None, None, None, pcd[3], SkuInfoList)\r
426                 for index in range(len(dscObj.Contents[key].PcdsDynamicExHii)):\r
427                     pcd = dscObj.Contents[key].PcdsDynamicExHii[index][0].split(DataType.TAB_VALUE_SPLIT)\r
428                     pcd.append(None)\r
429                     SkuId = dscObj.Contents[key].PcdsDynamicExHii[index][1]\r
430                     SkuInfoList = []\r
431                     if SkuId == None:\r
432                         SkuId = 'DEFAULT'\r
433                     SkuIdList = map(lambda l: l.strip(), SkuId.split(DataType.TAB_VALUE_SPLIT))\r
434                     for Item in SkuIdList:\r
435                         SkuInfo = SkuInfoClassObject()\r
436                         SkuInfo.SkuId = Item\r
437                         SkuInfo.VariableName = pcd[2]\r
438                         SkuInfo.VariableGuid = pcd[3]\r
439                         SkuInfo.VariableOffset = pcd[4]\r
440                         SkuInfo.HiiDefaultValue = pcd[5]                                                \r
441                         SkuInfoList.append(SkuInfo)\r
442                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_EX_HII, None, None, None, pcd[6], SkuInfoList)\r
443               \r
444                 self.Build[key].PlatformDatabase[dsc] = pb\r
445                 pb = None    \r
446             #End of Arch List Go Through    \r
447                 \r
448         #End of Dsc Go Through\r
449         \r
450         #End of build PlatformDatabase\r
451         \r
452         #Build PackageDatabase\r
453         for dec in self.DecDatabase.keys():\r
454             decObj = self.DecDatabase[dec]\r
455 \r
456             for key in DataType.ARCH_LIST:\r
457                 pb = PackageBuildClassObject()\r
458                 #Defines\r
459                 pb.DescFilePath = dec\r
460                 pb.PackageName = decObj.Defines.DefinesDictionary[TAB_DEC_DEFINES_PACKAGE_NAME][0]\r
461                 pb.Guid = decObj.Defines.DefinesDictionary[TAB_DEC_DEFINES_PACKAGE_GUID][0]\r
462                 pb.Version = decObj.Defines.DefinesDictionary[TAB_DEC_DEFINES_PACKAGE_VERSION][0]\r
463                 \r
464                 #Protocols\r
465                 for index in range(len(decObj.Contents[key].Protocols)):\r
466                     list = decObj.Contents[key].Protocols[index].split(DataType.TAB_EQUAL_SPLIT)\r
467                     pb.Protocols[CleanString(list[0])] = CleanString(list[1])\r
468 \r
469                 #Ppis\r
470                 for index in range(len(decObj.Contents[key].Ppis)):\r
471                     list = decObj.Contents[key].Ppis[index].split(DataType.TAB_EQUAL_SPLIT)\r
472                     pb.Ppis[CleanString(list[0])] = CleanString(list[1])            \r
473 \r
474                 #Guids\r
475                 for index in range(len(decObj.Contents[key].Guids)):\r
476                     list = decObj.Contents[key].Guids[index].split(DataType.TAB_EQUAL_SPLIT)\r
477                     pb.Guids[CleanString(list[0])] = CleanString(list[1])        \r
478                 \r
479                 #Includes\r
480                 for index in range(len(decObj.Contents[key].Includes)):\r
481                     pb.Includes.append(NormPath(decObj.Contents[key].Includes[index]))\r
482             \r
483                 #LibraryClasses\r
484                 for index in range(len(decObj.Contents[key].LibraryClasses)):\r
485                     list = decObj.Contents[key].LibraryClasses[index].split(DataType.TAB_VALUE_SPLIT)\r
486                     pb.LibraryClasses[CleanString(list[0])] = NormPath(CleanString(list[1]))\r
487                                                 \r
488                 #Pcds\r
489                 for index in range(len(decObj.Contents[key].PcdsFixedAtBuild)):\r
490                     pcd = decObj.Contents[key].PcdsFixedAtBuild[index].split(DataType.TAB_VALUE_SPLIT)\r
491                     pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_FIXED_AT_BUILD, pcd[3], pcd[4], pcd[1], None)\r
492                 for index in range(len(decObj.Contents[key].PcdsPatchableInModule)):\r
493                     pcd = decObj.Contents[key].PcdsPatchableInModule[index].split(DataType.TAB_VALUE_SPLIT)\r
494                     pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_PATCHABLE_IN_MODULE, pcd[3], pcd[4], pcd[1], None)\r
495                 for index in range(len(decObj.Contents[key].PcdsFeatureFlag)):\r
496                     pcd = decObj.Contents[key].PcdsFeatureFlag[index].split(DataType.TAB_VALUE_SPLIT)\r
497                     pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_FEATURE_FLAG, pcd[3], pcd[4], pcd[1], None)\r
498                 for index in range(len(decObj.Contents[key].PcdsDynamic)):\r
499                     pcd = decObj.Contents[key].PcdsDynamic[index].split(DataType.TAB_VALUE_SPLIT)\r
500                     pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_DYNAMIC, pcd[3], pcd[4], pcd[1], None)\r
501                 for index in range(len(decObj.Contents[key].PcdsDynamicEx)):\r
502                     pcd = decObj.Contents[key].PcdsDynamicEx[index].split(DataType.TAB_VALUE_SPLIT)\r
503                     pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_DYNAMIC_EX, pcd[3], pcd[4], pcd[1], None)\r
504             \r
505                 #Add to database\r
506                 self.Build[key].PackageDatabase[dec] = pb\r
507                 pb = None    \r
508             #End of Arch List Go Through\r
509         \r
510         #End of Dec Go Through    \r
511         \r
512         #End of build PackageDatabase\r
513     \r
514         #Build ModuleDatabase\r
515         for inf in self.InfDatabase.keys():\r
516             infObj = self.InfDatabase[inf]\r
517             \r
518             for key in DataType.ARCH_LIST:\r
519                 #Defines\r
520                 pb = ModuleBuildClassObject()\r
521                 pb.DescFilePath = inf\r
522                 pb.BaseName = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_BASE_NAME][0]\r
523                 pb.Guid = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_FILE_GUID][0]\r
524                 pb.Version = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_VERSION_STRING][0]\r
525                 pb.ModuleType = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_MODULE_TYPE][0]\r
526                 pb.PcdIsDriver = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_PCD_IS_DRIVER][0]\r
527                 pb.BinaryModule = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_BINARY_MODULE][0]\r
528                 \r
529                 for Index in range(len(infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_CUSTOM_MAKEFILE])):\r
530                     Makefile = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_CUSTOM_MAKEFILE][Index]\r
531                     if Makefile != '':\r
532                         MakefileList = Makefile.split(DataType.TAB_VALUE_SPLIT)\r
533                         if len(MakefileList) == 2:\r
534                             pb.CustomMakefile[CleanString(MakefileList[0])] = CleanString(MakefileList[1])\r
535                         else:\r
536                             raise ParseError('Wrong custom makefile defined in file ' + inf + ', correct format is CUSTOM_MAKEFILE = Family|Filename')\r
537                 \r
538                 if infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_EDK_RELEASE_VERSION][0] != '':\r
539                     pb.Specification[TAB_INF_DEFINES_EDK_RELEASE_VERSION] = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_EDK_RELEASE_VERSION][0]\r
540                 if infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION][0] != '':\r
541                     pb.Specification[TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION] = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION][0]                \r
542                 \r
543                 LibraryClass = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_LIBRARY_CLASS][0]\r
544                 if LibraryClass != '':\r
545                     l = LibraryClass.split(DataType.TAB_VALUE_SPLIT, 1)\r
546                     if len(l) == 1:\r
547                         pb.LibraryClass = LibraryClassObject(l[0], DataType.SUP_MODULE_LIST_STRING)\r
548                     else:\r
549                         pb.LibraryClass = LibraryClassObject(l[0], l[1])\r
550 \r
551                 pb.ModuleEntryPointList.extend(infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_ENTRY_POINT])\r
552                 pb.ModuleUnloadImageList.extend(infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_UNLOAD_IMAGE])\r
553                 pb.ConstructorList.extend(infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_CONSTRUCTOR])\r
554                 pb.DestructorList.extend(infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_DESTRUCTOR])\r
555 \r
556                 #Binaries\r
557                 for index in range(len(infObj.Contents[key].Binaries)):\r
558                     BinaryFile = infObj.Contents[key].Binaries[index].split(DataType.TAB_VALUE_SPLIT)\r
559                     BinaryFile.append('')\r
560                     FileType = BinaryFile[0].strip()\r
561                     Target = BinaryFile[1].strip()\r
562                     FileName = NormPath(BinaryFile[2].strip())\r
563                     PcdFeatureFlag = BinaryFile[3].strip()\r
564                     pb.Binaries.append(ModuleBinaryFilesClassObject(FileName, FileType, Target, PcdFeatureFlag))\r
565                     \r
566                 #Sources\r
567                 for index in range(len(infObj.Contents[key].Sources)):\r
568                     SourceFile = infObj.Contents[key].Sources[index].split(DataType.TAB_VALUE_SPLIT)\r
569                     if len(SourceFile) == 6:\r
570                         FileName = NormPath(SourceFile[0].strip())\r
571                         PcdFeatureFlag = SourceFile[1].strip()\r
572                         TagName = SourceFile[3].strip()\r
573                         ToolCode = SourceFile[4].strip()\r
574                         ToolChainFamily = SourceFile[2].strip()\r
575                         String = SourceFile[5].strip()\r
576                         pb.Sources.append(ModuleSourceFilesClassObject(FileName, PcdFeatureFlag, TagName, ToolCode, ToolChainFamily, String))\r
577                     elif len(SourceFile) == 1:\r
578                         pb.Sources.append(ModuleSourceFilesClassObject(NormPath(infObj.Contents[key].Sources[index])))\r
579                     else:\r
580                         raise ParseError("Inconsistent '|' value defined in SourceFiles." + key + " section in file " + inf)\r
581 \r
582                 #Protocols\r
583                 for index in range(len(infObj.Contents[key].Protocols)):\r
584                     pb.Protocols.append(infObj.Contents[key].Protocols[index])\r
585             \r
586                 #Ppis\r
587                 for index in range(len(infObj.Contents[key].Ppis)):\r
588                     pb.Ppis.append(infObj.Contents[key].Ppis[index])\r
589                                 \r
590                 #Guids\r
591                 for index in range(len(infObj.Contents[key].Guids)):\r
592                     pb.Guids.append(infObj.Contents[key].Guids[index])\r
593             \r
594                 #Includes\r
595                 for index in range(len(infObj.Contents[key].Includes)):\r
596                     pb.Includes.append(NormPath(infObj.Contents[key].Includes[index]))\r
597             \r
598                 #Packages\r
599                 for index in range(len(infObj.Contents[key].Packages)):\r
600                     pb.Packages.append(NormPath(infObj.Contents[key].Packages[index]))\r
601                     \r
602                 #BuildOptions\r
603                 for index in range(len(infObj.Contents[key].BuildOptions)):\r
604                     b = infObj.Contents[key].BuildOptions[index].split(DataType.TAB_EQUAL_SPLIT, 1)\r
605                     Family = ''\r
606                     ToolChain = ''\r
607                     Flag = ''\r
608                     if b[0].find(':') > -1:\r
609                         Family = CleanString(b[0][ : b[0].find(':')])\r
610                         ToolChain = CleanString(b[0][b[0].find(':') + 1 : ])\r
611                     else:\r
612                         ToolChain = CleanString(b[0])\r
613                     Flag = CleanString(b[1])\r
614                     pb.BuildOptions[(Family, ToolChain)] = Flag\r
615                 self.FindBuildOptions(key, inf, pb.BuildOptions)\r
616                 \r
617                 #Depex\r
618                 pb.Depex = ' '.join(infObj.Contents[key].Depex)\r
619                 \r
620                 #LibraryClasses\r
621                 for index in range(len(infObj.Contents[key].LibraryClasses)):\r
622                     #Get LibraryClass name and default instance if existing\r
623                     list = infObj.Contents[key].LibraryClasses[index][0].split(DataType.TAB_VALUE_SPLIT)\r
624                     if len(list) < 2:\r
625                         v = ''\r
626                     else:\r
627                         v = list[1]\r
628                     \r
629                     if pb.LibraryClass != None:\r
630                         #For Library\r
631                         for type in pb.LibraryClass.SupModList:\r
632                             instance = self.FindLibraryClassInstanceOfLibrary(CleanString(list[0]), key, type)\r
633                             if instance != None:\r
634                                 v = instance\r
635                                 pb.LibraryClasses[(CleanString(list[0]), type)] = NormPath(CleanString(v))\r
636                     else:\r
637                         #For Module                        \r
638                         instance = self.FindLibraryClassInstanceOfModule(CleanString(list[0]), key, pb.ModuleType, inf) \r
639                         if instance != None:\r
640                             v = instance\r
641                             pb.LibraryClasses[(CleanString(list[0]), pb.ModuleType)] = NormPath(CleanString(v))\r
642 \r
643                 #Pcds\r
644                 for index in range(len(infObj.Contents[key].PcdsFixedAtBuild)):\r
645                     pcd = infObj.Contents[key].PcdsFixedAtBuild[index].split(DataType.TAB_VALUE_SPLIT)\r
646                     pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_FIXED_AT_BUILD)\r
647                 for index in range(len(infObj.Contents[key].PcdsPatchableInModule)):\r
648                     pcd = infObj.Contents[key].PcdsPatchableInModule[index].split(DataType.TAB_VALUE_SPLIT)\r
649                     pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_PATCHABLE_IN_MODULE)\r
650                     #pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_PATCHABLE_IN_MODULE, None, None, None, None)                    \r
651                 for index in range(len(infObj.Contents[key].PcdsFeatureFlag)):\r
652                     pcd = infObj.Contents[key].PcdsFeatureFlag[index].split(DataType.TAB_VALUE_SPLIT)\r
653                     pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_FEATURE_FLAG)\r
654                     #pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_FEATURE_FLAG, None, None, None, None)                    \r
655                 for index in range(len(infObj.Contents[key].PcdsDynamic)):\r
656                     pcd = infObj.Contents[key].PcdsDynamic[index].split(DataType.TAB_VALUE_SPLIT)\r
657                     pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC)\r
658                     #pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC, None, None, None, None)\r
659                 for index in range(len(infObj.Contents[key].PcdsDynamicEx)):\r
660                     pcd = infObj.Contents[key].PcdsDynamicEx[index].split(DataType.TAB_VALUE_SPLIT)\r
661                     pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_EX)\r
662                     #pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_EX, None, None, None, None)\r
663                                         \r
664                 #Add to database\r
665                 self.Build[key].ModuleDatabase[inf] = pb\r
666                 pb = None    \r
667             #End of Arch List Go Through\r
668         \r
669         #End of Inf Go Through\r
670         \r
671         #End of build ModuleDatabase\r
672     \r
673     def UpdateLibraryClassOfModule(self, InfFileName, LibraryClass, Arch):\r
674         LibList = self.InfDatabase[NormPath(InfFileName)].Module.LibraryClasses\r
675         NotFound = True\r
676         for Lib in LibList:\r
677             #\r
678             # Find this LibraryClass\r
679             #\r
680             if Lib.LibraryClass == LibraryClass:\r
681                 if Arch in Lib.SupArchList:\r
682                     return\r
683                 else:\r
684                     Lib.SupArchList.append(Arch)\r
685                     return\r
686         if NotFound:\r
687             Lib = LibraryClassClass()\r
688             Lib.LibraryClass = LibraryClass\r
689             Lib.SupArchList = [Arch]\r
690                 \r
691     \r
692 #    def UpdateInfDatabase(self, InfFileName, LibraryClass, Arch):\r
693 #        InfFileName = NormPath(InfFileName)\r
694 #        LibList = self.InfDatabase[InfFileName].Contents[Arch].LibraryClasses\r
695 #        LibList = self.InfDatabase[InfFileName].Module.LibraryClasses\r
696 #        NotFound = True\r
697 #        for Lib in LibList:\r
698 #            if Lib.LibraryClass == LibraryClass and Arch in Lib.SupArchList:\r
699 #                return\r
700 #        \r
701 #        if NotFound:\r
702 #            self.InfDatabase[infFileName].Module.Contents[Arch].LibraryClasses.extend([LibraryClass])\r
703     \r
704     def AddToInfDatabase(self, InfFileName):\r
705         InfFileName = NormPath(InfFileName)\r
706         File = self.WorkspaceFile(InfFileName)\r
707         if os.path.exists(File) and os.path.isfile(File):\r
708             if InfFileName not in self.InfDatabase:\r
709                 self.InfDatabase[InfFileName] = Inf(File, True, True)\r
710                 \r
711     def AddToDecDatabase(self, DecFileName):\r
712         DecFileName = NormPath(DecFileName)\r
713         File = self.WorkspaceFile(DecFileName)\r
714         if os.path.exists(File) and os.path.isfile(File):\r
715             if DecFileName not in self.DecDatabase:\r
716                 self.DecDatabase[DecFileName] = Dec(File, True, True)\r
717                 \r
718     def FindLibraryClassInstanceOfModule(self, lib, arch, moduleType, moduleName):\r
719         for dsc in self.DscDatabase.keys():\r
720             #First find if exist in <LibraryClass> of <Components> from dsc file            \r
721             dscObj = self.DscDatabase[dsc]\r
722             for index in range(len(dscObj.Contents[arch].Components)):\r
723                 if NormPath(dscObj.Contents[arch].Components[index][0]) == moduleName and len(dscObj.Contents[arch].Components[index][1]) > 0:\r
724                     #Search each library class\r
725                     LibList = dscObj.Contents[arch].Components[index][1]\r
726                     for indexOfLib in range(len(LibList)):\r
727                         if LibList[indexOfLib].split(DataType.TAB_VALUE_SPLIT)[0].strip() == lib:\r
728                             return LibList[indexOfLib].split(DataType.TAB_VALUE_SPLIT)[1].strip()\r
729             \r
730             #Second find if exist in <LibraryClass> of <LibraryClasses> from dsc file            \r
731             if (lib, moduleType) in self.Build[arch].PlatformDatabase[dsc].LibraryClasses:\r
732                 return self.Build[arch].PlatformDatabase[dsc].LibraryClasses[(lib, moduleType)]\r
733             elif (lib, None) in self.Build[arch].PlatformDatabase[dsc].LibraryClasses:\r
734                 return self.Build[arch].PlatformDatabase[dsc].LibraryClasses[(lib, None)]\r
735             \r
736     def FindLibraryClassInstanceOfLibrary(self, lib, arch, type):\r
737         for dsc in self.DscDatabase.keys():\r
738             dscObj = self.DscDatabase[dsc]\r
739             if (lib, type) in self.Build[arch].PlatformDatabase[dsc].LibraryClasses:\r
740                 return self.Build[arch].PlatformDatabase[dsc].LibraryClasses[(lib, type)]\r
741             elif (lib, None) in self.Build[arch].PlatformDatabase[dsc].LibraryClasses:\r
742                 return self.Build[arch].PlatformDatabase[dsc].LibraryClasses[(lib, None)]\r
743             \r
744     def FindBuildOptions(self, arch, moduleName, BuildOptions):\r
745         for dsc in self.DscDatabase.keys():\r
746             #First find if exist in <BuildOptions> of <Components> from dsc file\r
747             dscObj = self.DscDatabase[dsc]\r
748             for index in range(len(dscObj.Contents[arch].Components)):\r
749                 if NormPath(dscObj.Contents[arch].Components[index][0]) == moduleName and len(dscObj.Contents[arch].Components[index][2]) > 0:\r
750                     list = dscObj.Contents[arch].Components[index][2]\r
751                     for l in list:\r
752                         b = l.split(DataType.TAB_EQUAL_SPLIT, 1)\r
753                         Family = ''\r
754                         ToolChain = ''\r
755                         Flag = ''\r
756                         if b[0].find(':') > -1:\r
757                             Family = CleanString(b[0][ : b[0].find(':')])\r
758                             ToolChain = CleanString(b[0][b[0].find(':') + 1 : ])\r
759                         else:\r
760                             ToolChain = CleanString(b[0])\r
761                         Flag = CleanString(b[1])\r
762                         BuildOptions[(Family, ToolChain)] = Flag\r
763                         \r
764     def FindPcd(self, arch, CName, GuidCName, Type):\r
765         DatumType = ''\r
766         DefaultValue = ''\r
767         TokenValue = ''\r
768         MaxDatumSize = ''\r
769         SkuInfoList = None\r
770         for dsc in self.Build[arch].PlatformDatabase.keys():\r
771             platform = self.Build[arch].PlatformDatabase[dsc]\r
772             pcds = platform.Pcds\r
773             if (CName, GuidCName) in pcds:\r
774                 Type = pcds[(CName, GuidCName)].Type\r
775                 DatumType = pcds[(CName, GuidCName)].DatumType\r
776                 DefaultValue = pcds[(CName, GuidCName)].DefaultValue\r
777                 TokenValue = pcds[(CName, GuidCName)].TokenValue\r
778                 MaxDatumSize = pcds[(CName, GuidCName)].MaxDatumSize\r
779                 SkuInfoList =  pcds[(CName, GuidCName)].SkuInfoList\r
780                 break\r
781 \r
782         for dec in self.Build[arch].PackageDatabase.keys():\r
783             package = self.Build[arch].PackageDatabase[dec]\r
784             pcds = package.Pcds\r
785             if (CName, GuidCName) in pcds:\r
786                 DatumType = pcds[(CName, GuidCName)].DatumType\r
787                 #DefaultValue = pcds[(CName, GuidCName)].DefaultValue\r
788                 TokenValue = pcds[(CName, GuidCName)].TokenValue\r
789                 #MaxDatumSize = pcds[(CName, GuidCName)].MaxDatumSize\r
790                 break\r
791         \r
792         return PcdClassObject(CName, GuidCName, Type, DatumType, DefaultValue, TokenValue, MaxDatumSize, SkuInfoList)\r
793     \r
794     def ReloadPcd(self, FvDict):\r
795         pass\r
796                 \r
797 # This acts like the main() function for the script, unless it is 'import'ed into another\r
798 # script.\r
799 if __name__ == '__main__':\r
800 \r
801     # Nothing to do here. Could do some unit tests.\r
802     w = os.getenv('WORKSPACE')\r
803     ewb = WorkspaceBuild('Nt32Pkg/Nt32Pkg.dsc', w)\r
804     ewb.GenBuildDatabase()\r
805     #print ewb.DscDatabase\r
806     #print ewb.InfDatabase\r
807     #print ewb.DecDatabase\r
808     print 'SupArchList', ewb.SupArchList\r
809     print 'BuildTarget', ewb.BuildTarget\r
810     print 'SkuId', ewb.SkuId\r
811     \r
812     #\r
813     for arch in DataType.ARCH_LIST:\r
814         print arch\r
815         print 'Platform'\r
816         for platform in ewb.Build[arch].PlatformDatabase.keys():\r
817             p = ewb.Build[arch].PlatformDatabase[platform]\r
818             print 'DescFilePath = ', p.DescFilePath     \r
819             print 'PlatformName = ', p.PlatformName     \r
820             print 'Guid = ', p.Guid                     \r
821             print 'Version = ', p.Version\r
822             print 'OutputDirectory = ', p.OutputDirectory                \r
823             print 'FlashDefinition = ', p.FlashDefinition\r
824             print 'SkuIds = ', p.SkuIds\r
825             print 'Modules = ', p.Modules\r
826             print 'LibraryClasses = ', p.LibraryClasses \r
827             print 'Pcds = ', p.Pcds\r
828             for item in p.Pcds.keys():\r
829                 print p.Pcds[item]\r
830             print 'BuildOptions = ', p.BuildOptions\r
831             print ''   \r
832         #End of Platform\r
833     \r
834         print 'package'\r
835         for package in ewb.Build[arch].PackageDatabase.keys():\r
836             p = ewb.Build[arch].PackageDatabase[package]\r
837             print 'DescFilePath = ', p.DescFilePath    \r
838             print 'PackageName = ', p.PackageName     \r
839             print 'Guid = ', p.Guid                    \r
840             print 'Version = ', p.Version             \r
841             print 'Protocols = ', p.Protocols         \r
842             print 'Ppis = ', p.Ppis                    \r
843             print 'Guids = ', p.Guids                 \r
844             print 'Includes = ', p.Includes            \r
845             print 'LibraryClasses = ', p.LibraryClasses\r
846             print 'Pcds = ', p.Pcds\r
847             print ''                    \r
848         #End of Package\r
849         \r
850         print 'module'\r
851         for module in ewb.Build[arch].ModuleDatabase.keys():\r
852             p = ewb.Build[arch].ModuleDatabase[module]\r
853             print 'DescFilePath = ', p.DescFilePath                    \r
854             print 'BaseName = ', p.BaseName                         \r
855             print 'ModuleType = ', p.ModuleType                     \r
856             print 'Guid = ', p.Guid                                 \r
857             print 'Version = ', p.Version\r
858             print 'CustomMakefile = ', p.CustomMakefile\r
859             print 'Specification = ', p.Specification\r
860             print 'PcdIsDriver = ', p.PcdIsDriver\r
861             if p.LibraryClass != None:\r
862                 print 'LibraryClass = ', p.LibraryClass.LibraryClass\r
863                 print 'SupModList = ', p.LibraryClass.SupModList\r
864             print 'ModuleEntryPointList = ', p.ModuleEntryPointList \r
865             print 'ModuleUnloadImageList = ', p.ModuleUnloadImageList\r
866             print 'ConstructorList = ', p.ConstructorList            \r
867             print 'DestructorList = ', p.DestructorList             \r
868                                                                      \r
869             print 'Binaries = '\r
870             for item in p.Binaries:\r
871                 print str(item)\r
872             print 'Sources = '\r
873             for item in p.Sources:\r
874                 print str(item)\r
875             print 'LibraryClasses = ', p.LibraryClasses             \r
876             print 'Protocols = ', p.Protocols                        \r
877             print 'Ppis = ', p.Ppis                                 \r
878             print 'Guids = ', p.Guids                                \r
879             print 'Includes = ', p.Includes                         \r
880             print 'Packages = ', p.Packages                         \r
881             print 'Pcds = ', p.Pcds\r
882             print 'BuildOptions = ', p.BuildOptions\r
883             print 'Depex = ', p.Depex\r
884             print ''\r
885         #End of Module    \r
886             \r
887     #End of Arch List\r