add target and tooldef declaration in init()
[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 key in DataType.ARCH_LIST:\r
210             self.Build[key] = ItemBuild(key)\r
211         \r
212         # Get active platform\r
213         dscFileName = NormPath(ActivePlatform)\r
214         File = self.WorkspaceFile(dscFileName)\r
215         if os.path.exists(File) and os.path.isfile(File):\r
216             self.DscDatabase[dscFileName] = Dsc(File, True)\r
217         else:\r
218             raise ParserError(FILE_NOT_FOUND, name = File)\r
219         \r
220         # parse platform to get module\r
221         for dsc in self.DscDatabase.keys():\r
222             dscObj = self.DscDatabase[dsc]\r
223             \r
224             #\r
225             # Get global information\r
226             #\r
227             self.SupArchList = dscObj.Defines.DefinesDictionary[TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES]\r
228             self.BuildTarget = dscObj.Defines.DefinesDictionary[TAB_DSC_DEFINES_BUILD_TARGETS]\r
229             self.SkuId = dscObj.Defines.DefinesDictionary[TAB_DSC_DEFINES_SKUID_IDENTIFIER][0]\r
230             self.Fdf = dscObj.Defines.DefinesDictionary[TAB_DSC_DEFINES_FLASH_DEFINITION][0]\r
231             \r
232             #Get all inf\r
233             for key in DataType.ARCH_LIST:\r
234                 for index in range(len(dscObj.Contents[key].LibraryClasses)):\r
235                     self.AddToInfDatabase(dscObj.Contents[key].LibraryClasses[index][0].split(DataType.TAB_VALUE_SPLIT, 1)[1])\r
236                 for index in range(len(dscObj.Contents[key].Components)):\r
237                     Module = dscObj.Contents[key].Components[index][0]\r
238                     LibList = dscObj.Contents[key].Components[index][1]\r
239                     self.AddToInfDatabase(Module)\r
240                     for indexOfLib in range(len(LibList)):\r
241                         Lib = LibList[indexOfLib]\r
242                         if len(Lib.split(DataType.TAB_VALUE_SPLIT)) == 2:\r
243                             self.AddToInfDatabase(CleanString(Lib.split(DataType.TAB_VALUE_SPLIT)[1]))\r
244                             self.UpdateInfDatabase(Module, CleanString(Lib.split(DataType.TAB_VALUE_SPLIT)[0]), key)\r
245         #End For of Dsc\r
246         \r
247         #parse module to get package\r
248         for inf in self.InfDatabase.keys():\r
249             infObj = self.InfDatabase[inf]\r
250             #Get all dec\r
251             for key in DataType.ARCH_LIST:\r
252                 for index in range(len(infObj.Contents[key].Packages)):\r
253                     self.AddToDecDatabase(infObj.Contents[key].Packages[index])\r
254     #End of self.Init()\r
255     \r
256     #\r
257     # Return a full path with workspace dir\r
258     #\r
259     def WorkspaceFile(self, Filename):\r
260         return os.path.join(self.WorkspaceDir, Filename)\r
261     \r
262     def GenBuildDatabase(self, PcdsSet = {}):\r
263         #Build databases\r
264         #Build PlatformDatabase\r
265         for dsc in self.DscDatabase.keys():\r
266             dscObj = self.DscDatabase[dsc]\r
267             \r
268             for key in DataType.ARCH_LIST:\r
269                 pb = PlatformBuildClassObject()\r
270                 pb.DescFilePath = dsc\r
271                 pb.PlatformName = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_PLATFORM_NAME][0]\r
272                 pb.Guid = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_PLATFORM_GUID][0]\r
273                 pb.Version = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_PLATFORM_VERSION][0]\r
274                 pb.DscSpecification = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_DSC_SPECIFICATION][0]\r
275                 pb.OutputDirectory = NormPath(dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_OUTPUT_DIRECTORY][0])\r
276                 pb.FlashDefinition = NormPath(dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_FLASH_DEFINITION][0])\r
277                 pb.BuildNumber = dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_BUILD_NUMBER][0]\r
278                 pb.MakefileName = NormPath(dscObj.Defines.DefinesDictionary[DataType.TAB_DSC_DEFINES_MAKEFILE_NAME][0])\r
279                 \r
280                 #SkuId\r
281                 for index in range(len(dscObj.Contents[key].SkuIds)):\r
282                     SkuInfo = dscObj.Contents[key].SkuIds[index]\r
283                     SkuName = ''\r
284                     SkuId = ''\r
285                     if SkuInfo.find('!include') > -1:\r
286                         SkuName = '!include'\r
287                         SkuId = NormPath(CleanString(SkuInfo[SkuInfo.find('!include') + len('!include'):]))\r
288                     elif len(SkuInfo.split(DataType.TAB_VALUE_SPLIT)) == 2:\r
289                         SkuName = CleanString(SkuInfo.split(DataType.TAB_VALUE_SPLIT)[1])\r
290                         SkuId = CleanString(SkuInfo.split(DataType.TAB_VALUE_SPLIT)[0])\r
291                     else:\r
292                         raise ParseError('Wrong defintion for SkuId: %s' % SkuInfo)\r
293                     pb.SkuIds[SkuName] = SkuId\r
294                 \r
295                 #Module\r
296                 for index in range(len(dscObj.Contents[key].Components)):\r
297                     pb.Modules.append(NormPath(dscObj.Contents[key].Components[index][0]))\r
298                 \r
299                 #BuildOptions\r
300                 for index in range(len(dscObj.Contents[key].BuildOptions)):\r
301                     b = dscObj.Contents[key].BuildOptions[index].split(DataType.TAB_EQUAL_SPLIT, 1)\r
302                     Family = ''\r
303                     ToolChain = ''\r
304                     Flag = ''\r
305                     if b[0].find(':') > -1:\r
306                         Family = CleanString(b[0][ : b[0].find(':')])\r
307                         ToolChain = CleanString(b[0][b[0].find(':') + 1 : ])\r
308                     else:\r
309                         ToolChain = CleanString(b[0])\r
310                     Flag = CleanString(b[1])\r
311                     pb.BuildOptions[(Family, ToolChain)] = Flag\r
312                     \r
313                 #LibraryClass\r
314                 for index in range(len(dscObj.Contents[key].LibraryClasses)):\r
315                     #['DebugLib|MdePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf', ['DXE_CORE']]\r
316                     list = dscObj.Contents[key].LibraryClasses[index][0].split(DataType.TAB_VALUE_SPLIT, 1)\r
317                     type = dscObj.Contents[key].LibraryClasses[index][1][0]\r
318                     pb.LibraryClasses[(list[0], type)] = NormPath(list[1])\r
319 \r
320                 #Pcds\r
321                 for index in range(len(dscObj.Contents[key].PcdsFixedAtBuild)):\r
322                     pcd = dscObj.Contents[key].PcdsFixedAtBuild[index].split(DataType.TAB_VALUE_SPLIT)\r
323                     pcd.append(None)\r
324                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_FIXED_AT_BUILD, None, pcd[2], None, pcd[3])\r
325                 for index in range(len(dscObj.Contents[key].PcdsPatchableInModule)):\r
326                     pcd = dscObj.Contents[key].PcdsPatchableInModule[index].split(DataType.TAB_VALUE_SPLIT)\r
327                     pcd.append(None)\r
328                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_PATCHABLE_IN_MODULE, None, pcd[2], None, pcd[3])\r
329                 for index in range(len(dscObj.Contents[key].PcdsFeatureFlag)):\r
330                     pcd = dscObj.Contents[key].PcdsFeatureFlag[index].split(DataType.TAB_VALUE_SPLIT)\r
331                     pcd.append(None)                    \r
332                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_FEATURE_FLAG, None, pcd[2], None, pcd[3])\r
333                 #\r
334                 # PcdsDynamic\r
335                 #\r
336                 for index in range(len(dscObj.Contents[key].PcdsDynamicDefault)):\r
337                     pcd = dscObj.Contents[key].PcdsDynamicDefault[index][0].split(DataType.TAB_VALUE_SPLIT)\r
338                     pcd.append(None)\r
339                     SkuName = dscObj.Contents[key].PcdsDynamicDefault[index][1]\r
340                     SkuInfoList = []\r
341                     if SkuName == None or SkuName == [] or SkuName == ['']:\r
342                         SkuName = ['DEFAULT']\r
343                     SkuNameList = map(lambda l: l.strip(), SkuName[0].split(DataType.TAB_VALUE_SPLIT))\r
344                     for Item in SkuNameList:\r
345                         SkuInfo = SkuInfoClass()\r
346                         SkuInfo.SkuId = Item[1]\r
347                         SkuInfo.DefaultValue = pcd[2]\r
348                         SkuInfoList.append(SkuInfo)\r
349                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_DEFAULT, None, None, None, pcd[3], SkuInfoList)\r
350                 for index in range(len(dscObj.Contents[key].PcdsDynamicVpd)):\r
351                     pcd = dscObj.Contents[key].PcdsDynamicVpd[index][0].split(DataType.TAB_VALUE_SPLIT)\r
352                     pcd.append(None)\r
353                     SkuId = dscObj.Contents[key].PcdsDynamicVpd[index][1]\r
354                     SkuInfoList = []\r
355                     if SkuId == None:\r
356                         SkuId = 'DEFAULT'\r
357                     SkuIdList = map(lambda l: l.strip(), SkuId.split(DataType.TAB_VALUE_SPLIT))\r
358                     for Item in SkuIdList:\r
359                         SkuInfo = SkuInfoClassObject()\r
360                         SkuInfo.SkuId = Item\r
361                         SkuInfo.VpdOffset = pcd[2]\r
362                         SkuInfoList.append(SkuInfo)\r
363                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_VPD, None, None, None, pcd[3], SkuInfoList)\r
364                 for index in range(len(dscObj.Contents[key].PcdsDynamicHii)):\r
365                     pcd = dscObj.Contents[key].PcdsDynamicHii[index][0].split(DataType.TAB_VALUE_SPLIT)\r
366                     pcd.append(None)\r
367                     SkuId = dscObj.Contents[key].PcdsDynamicHii[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.VariableName = pcd[2]\r
376                         SkuInfo.VariableGuid = pcd[3]\r
377                         SkuInfo.VariableOffset = pcd[4]\r
378                         SkuInfo.HiiDefaultValue = pcd[5]                                                \r
379                         SkuInfoList.append(SkuInfo)\r
380                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_HII, None, None, None, pcd[6], SkuInfoList)\r
381                 #\r
382                 # PcdsDynamicEx\r
383                 #\r
384                 for index in range(len(dscObj.Contents[key].PcdsDynamicExDefault)):\r
385                     pcd = dscObj.Contents[key].PcdsDynamicExDefault[index][0].split(DataType.TAB_VALUE_SPLIT)\r
386                     pcd.append(None)\r
387                     SkuId = dscObj.Contents[key].PcdsDynamicExDefault[index][1]\r
388                     SkuInfoList = []\r
389                     if SkuId == None:\r
390                         SkuId = 'DEFAULT'\r
391                     SkuIdList = map(lambda l: l.strip(), SkuId.split(DataType.TAB_VALUE_SPLIT))\r
392                     for Item in SkuIdList:\r
393                         SkuInfo = SkuInfoClassObject()\r
394                         SkuInfo.SkuId = Item\r
395                         SkuInfo.DefaultValue = pcd[2]\r
396                         SkuInfoList.append(SkuInfo)\r
397                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_EX_DEFAULT, None, None, None, pcd[3], SkuInfoList)\r
398                 for index in range(len(dscObj.Contents[key].PcdsDynamicExVpd)):\r
399                     pcd = dscObj.Contents[key].PcdsDynamicExVpd[index][0].split(DataType.TAB_VALUE_SPLIT)\r
400                     pcd.append(None)\r
401                     SkuId = dscObj.Contents[key].PcdsDynamicExVpd[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.VpdOffset = 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_VPD, None, None, None, pcd[3], SkuInfoList)\r
412                 for index in range(len(dscObj.Contents[key].PcdsDynamicExHii)):\r
413                     pcd = dscObj.Contents[key].PcdsDynamicExHii[index][0].split(DataType.TAB_VALUE_SPLIT)\r
414                     pcd.append(None)\r
415                     SkuId = dscObj.Contents[key].PcdsDynamicExHii[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.VariableName = pcd[2]\r
424                         SkuInfo.VariableGuid = pcd[3]\r
425                         SkuInfo.VariableOffset = pcd[4]\r
426                         SkuInfo.HiiDefaultValue = pcd[5]                                                \r
427                         SkuInfoList.append(SkuInfo)\r
428                     pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_EX_HII, None, None, None, pcd[6], SkuInfoList)\r
429               \r
430                 self.Build[key].PlatformDatabase[dsc] = pb\r
431                 pb = None    \r
432             #End of Arch List Go Through    \r
433                 \r
434         #End of Dsc Go Through\r
435         \r
436         #End of build PlatformDatabase\r
437         \r
438         #Build PackageDatabase\r
439         for dec in self.DecDatabase.keys():\r
440             decObj = self.DecDatabase[dec]\r
441 \r
442             for key in DataType.ARCH_LIST:\r
443                 pb = PackageBuildClassObject()\r
444                 #Defines\r
445                 pb.DescFilePath = dec\r
446                 pb.PackageName = decObj.Defines.DefinesDictionary[TAB_DEC_DEFINES_PACKAGE_NAME][0]\r
447                 pb.Guid = decObj.Defines.DefinesDictionary[TAB_DEC_DEFINES_PACKAGE_GUID][0]\r
448                 pb.Version = decObj.Defines.DefinesDictionary[TAB_DEC_DEFINES_PACKAGE_VERSION][0]\r
449                 \r
450                 #Protocols\r
451                 for index in range(len(decObj.Contents[key].Protocols)):\r
452                     list = decObj.Contents[key].Protocols[index].split(DataType.TAB_EQUAL_SPLIT)\r
453                     pb.Protocols[CleanString(list[0])] = CleanString(list[1])\r
454 \r
455                 #Ppis\r
456                 for index in range(len(decObj.Contents[key].Ppis)):\r
457                     list = decObj.Contents[key].Ppis[index].split(DataType.TAB_EQUAL_SPLIT)\r
458                     pb.Ppis[CleanString(list[0])] = CleanString(list[1])            \r
459 \r
460                 #Guids\r
461                 for index in range(len(decObj.Contents[key].Guids)):\r
462                     list = decObj.Contents[key].Guids[index].split(DataType.TAB_EQUAL_SPLIT)\r
463                     pb.Guids[CleanString(list[0])] = CleanString(list[1])        \r
464                 \r
465                 #Includes\r
466                 for index in range(len(decObj.Contents[key].Includes)):\r
467                     pb.Includes.append(NormPath(decObj.Contents[key].Includes[index]))\r
468             \r
469                 #LibraryClasses\r
470                 for index in range(len(decObj.Contents[key].LibraryClasses)):\r
471                     list = decObj.Contents[key].LibraryClasses[index].split(DataType.TAB_VALUE_SPLIT)\r
472                     pb.LibraryClasses[CleanString(list[0])] = NormPath(CleanString(list[1]))\r
473                                                 \r
474                 #Pcds\r
475                 for index in range(len(decObj.Contents[key].PcdsFixedAtBuild)):\r
476                     pcd = decObj.Contents[key].PcdsFixedAtBuild[index].split(DataType.TAB_VALUE_SPLIT)\r
477                     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
478                 for index in range(len(decObj.Contents[key].PcdsPatchableInModule)):\r
479                     pcd = decObj.Contents[key].PcdsPatchableInModule[index].split(DataType.TAB_VALUE_SPLIT)\r
480                     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
481                 for index in range(len(decObj.Contents[key].PcdsFeatureFlag)):\r
482                     pcd = decObj.Contents[key].PcdsFeatureFlag[index].split(DataType.TAB_VALUE_SPLIT)\r
483                     pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_FEATURE_FLAG, pcd[3], pcd[4], pcd[1], None)\r
484                 for index in range(len(decObj.Contents[key].PcdsDynamic)):\r
485                     pcd = decObj.Contents[key].PcdsDynamic[index].split(DataType.TAB_VALUE_SPLIT)\r
486                     pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_DYNAMIC, pcd[3], pcd[4], pcd[1], None)\r
487                 for index in range(len(decObj.Contents[key].PcdsDynamicEx)):\r
488                     pcd = decObj.Contents[key].PcdsDynamicEx[index].split(DataType.TAB_VALUE_SPLIT)\r
489                     pb.Pcds[(pcd[0], pcd[2])] = PcdClassObject(pcd[0], pcd[2], DataType.TAB_PCDS_DYNAMIC_EX, pcd[3], pcd[4], pcd[1], None)\r
490             \r
491                 #Add to database\r
492                 self.Build[key].PackageDatabase[dec] = pb\r
493                 pb = None    \r
494             #End of Arch List Go Through\r
495         \r
496         #End of Dec Go Through    \r
497         \r
498         #End of build PackageDatabase\r
499     \r
500         #Build ModuleDatabase\r
501         for inf in self.InfDatabase.keys():\r
502             infObj = self.InfDatabase[inf]\r
503             \r
504             for key in DataType.ARCH_LIST:\r
505                 #Defines\r
506                 pb = ModuleBuildClassObject()\r
507                 pb.DescFilePath = inf\r
508                 pb.BaseName = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_BASE_NAME][0]\r
509                 pb.Guid = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_FILE_GUID][0]\r
510                 pb.Version = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_VERSION_STRING][0]\r
511                 pb.ModuleType = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_MODULE_TYPE][0]\r
512                 pb.PcdIsDriver = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_PCD_IS_DRIVER][0]\r
513                 pb.BinaryModule = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_BINARY_MODULE][0]\r
514                 \r
515                 for Index in range(len(infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_CUSTOM_MAKEFILE])):\r
516                     Makefile = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_CUSTOM_MAKEFILE][Index]\r
517                     if Makefile != '':\r
518                         MakefileList = Makefile.split(DataType.TAB_VALUE_SPLIT)\r
519                         if len(MakefileList) == 2:\r
520                             pb.CustomMakefile[CleanString(MakefileList[0])] = CleanString(MakefileList[1])\r
521                         else:\r
522                             raise ParseError('Wrong custom makefile defined in file ' + inf + ', correct format is CUSTOM_MAKEFILE = Family|Filename')\r
523                 \r
524                 if infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_EDK_RELEASE_VERSION][0] != '':\r
525                     pb.Specification[TAB_INF_DEFINES_EDK_RELEASE_VERSION] = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_EDK_RELEASE_VERSION][0]\r
526                 if infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION][0] != '':\r
527                     pb.Specification[TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION] = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION][0]                \r
528                 \r
529                 LibraryClass = infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_LIBRARY_CLASS][0]\r
530                 if LibraryClass != '':\r
531                     l = LibraryClass.split(DataType.TAB_VALUE_SPLIT, 1)\r
532                     if len(l) == 1:\r
533                         pb.LibraryClass = LibraryClassObject(l[0], DataType.SUP_MODULE_LIST_STRING)\r
534                     else:\r
535                         pb.LibraryClass = LibraryClassObject(l[0], l[1])\r
536 \r
537                 pb.ModuleEntryPointList.extend(infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_ENTRY_POINT])\r
538                 pb.ModuleUnloadImageList.extend(infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_UNLOAD_IMAGE])\r
539                 pb.ConstructorList.extend(infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_CONSTRUCTOR])\r
540                 pb.DestructorList.extend(infObj.Defines.DefinesDictionary[TAB_INF_DEFINES_DESTRUCTOR])\r
541 \r
542                 #Binaries\r
543                 for index in range(len(infObj.Contents[key].Binaries)):\r
544                     BinaryFile = infObj.Contents[key].Binaries[index].split(DataType.TAB_VALUE_SPLIT)\r
545                     BinaryFile.append('')\r
546                     FileType = BinaryFile[0].strip()\r
547                     Target = BinaryFile[1].strip()\r
548                     FileName = NormPath(BinaryFile[2].strip())\r
549                     PcdFeatureFlag = BinaryFile[3].strip()\r
550                     pb.Binaries.append(ModuleBinaryFilesClassObject(FileName, FileType, Target, PcdFeatureFlag))\r
551                     \r
552                 #Sources\r
553                 for index in range(len(infObj.Contents[key].Sources)):\r
554                     SourceFile = infObj.Contents[key].Sources[index].split(DataType.TAB_VALUE_SPLIT)\r
555                     if len(SourceFile) == 6:\r
556                         FileName = NormPath(SourceFile[0].strip())\r
557                         PcdFeatureFlag = SourceFile[1].strip()\r
558                         TagName = SourceFile[3].strip()\r
559                         ToolCode = SourceFile[4].strip()\r
560                         ToolChainFamily = SourceFile[2].strip()\r
561                         String = SourceFile[5].strip()\r
562                         pb.Sources.append(ModuleSourceFilesClassObject(FileName, PcdFeatureFlag, TagName, ToolCode, ToolChainFamily, String))\r
563                     elif len(SourceFile) == 1:\r
564                         pb.Sources.append(ModuleSourceFilesClassObject(NormPath(infObj.Contents[key].Sources[index])))\r
565                     else:\r
566                         raise ParseError("Inconsistent '|' value defined in SourceFiles." + key + " section in file " + inf)\r
567 \r
568                 #Protocols\r
569                 for index in range(len(infObj.Contents[key].Protocols)):\r
570                     pb.Protocols.append(infObj.Contents[key].Protocols[index])\r
571             \r
572                 #Ppis\r
573                 for index in range(len(infObj.Contents[key].Ppis)):\r
574                     pb.Ppis.append(infObj.Contents[key].Ppis[index])\r
575                                 \r
576                 #Guids\r
577                 for index in range(len(infObj.Contents[key].Guids)):\r
578                     pb.Guids.append(infObj.Contents[key].Guids[index])\r
579             \r
580                 #Includes\r
581                 for index in range(len(infObj.Contents[key].Includes)):\r
582                     pb.Includes.append(NormPath(infObj.Contents[key].Includes[index]))\r
583             \r
584                 #Packages\r
585                 for index in range(len(infObj.Contents[key].Packages)):\r
586                     pb.Packages.append(NormPath(infObj.Contents[key].Packages[index]))\r
587                     \r
588                 #BuildOptions\r
589                 for index in range(len(infObj.Contents[key].BuildOptions)):\r
590                     b = infObj.Contents[key].BuildOptions[index].split(DataType.TAB_EQUAL_SPLIT, 1)\r
591                     Family = ''\r
592                     ToolChain = ''\r
593                     Flag = ''\r
594                     if b[0].find(':') > -1:\r
595                         Family = CleanString(b[0][ : b[0].find(':')])\r
596                         ToolChain = CleanString(b[0][b[0].find(':') + 1 : ])\r
597                     else:\r
598                         ToolChain = CleanString(b[0])\r
599                     Flag = CleanString(b[1])\r
600                     pb.BuildOptions[(Family, ToolChain)] = Flag\r
601                 self.FindBuildOptions(key, inf, pb.BuildOptions)\r
602                 \r
603                 #Depex\r
604                 pb.Depex = ' '.join(infObj.Contents[key].Depex)\r
605                 \r
606                 #LibraryClasses\r
607                 for index in range(len(infObj.Contents[key].LibraryClasses)):\r
608                     #Get LibraryClass name and default instance if existing\r
609                     list = infObj.Contents[key].LibraryClasses[index][0].split(DataType.TAB_VALUE_SPLIT)\r
610                     if len(list) < 2:\r
611                         v = ''\r
612                     else:\r
613                         v = list[1]\r
614                     \r
615                     if pb.LibraryClass != None:\r
616                         #For Library\r
617                         for type in pb.LibraryClass.SupModList:\r
618                             instance = self.FindLibraryClassInstanceOfLibrary(CleanString(list[0]), key, type)\r
619                             if instance != None:\r
620                                 v = instance\r
621                                 pb.LibraryClasses[(CleanString(list[0]), type)] = NormPath(CleanString(v))\r
622                     else:\r
623                         #For Module                        \r
624                         instance = self.FindLibraryClassInstanceOfModule(CleanString(list[0]), key, pb.ModuleType, inf) \r
625                         if instance != None:\r
626                             v = instance\r
627                             pb.LibraryClasses[(CleanString(list[0]), pb.ModuleType)] = NormPath(CleanString(v))\r
628 \r
629                 #Pcds\r
630                 for index in range(len(infObj.Contents[key].PcdsFixedAtBuild)):\r
631                     pcd = infObj.Contents[key].PcdsFixedAtBuild[index].split(DataType.TAB_VALUE_SPLIT)\r
632                     pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_FIXED_AT_BUILD)\r
633                 for index in range(len(infObj.Contents[key].PcdsPatchableInModule)):\r
634                     pcd = infObj.Contents[key].PcdsPatchableInModule[index].split(DataType.TAB_VALUE_SPLIT)\r
635                     pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_PATCHABLE_IN_MODULE)\r
636                     #pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_PATCHABLE_IN_MODULE, None, None, None, None)                    \r
637                 for index in range(len(infObj.Contents[key].PcdsFeatureFlag)):\r
638                     pcd = infObj.Contents[key].PcdsFeatureFlag[index].split(DataType.TAB_VALUE_SPLIT)\r
639                     pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_FEATURE_FLAG)\r
640                     #pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_FEATURE_FLAG, None, None, None, None)                    \r
641                 for index in range(len(infObj.Contents[key].PcdsDynamic)):\r
642                     pcd = infObj.Contents[key].PcdsDynamic[index].split(DataType.TAB_VALUE_SPLIT)\r
643                     pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC)\r
644                     #pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC, None, None, None, None)\r
645                 for index in range(len(infObj.Contents[key].PcdsDynamicEx)):\r
646                     pcd = infObj.Contents[key].PcdsDynamicEx[index].split(DataType.TAB_VALUE_SPLIT)\r
647                     pb.Pcds[(pcd[0], pcd[1])] = self.FindPcd(key, pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_EX)\r
648                     #pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_EX, None, None, None, None)\r
649                                         \r
650                 #Add to database\r
651                 self.Build[key].ModuleDatabase[inf] = pb\r
652                 pb = None    \r
653             #End of Arch List Go Through\r
654         \r
655         #End of Inf Go Through\r
656         \r
657         #End of build ModuleDatabase    \r
658     \r
659 \r
660     \r
661     def UpdateInfDatabase(self, infFileName, LibraryClass, Arch):\r
662         infFileName = NormPath(infFileName)\r
663         LibList = self.InfDatabase[infFileName].Contents[Arch].LibraryClasses\r
664         NotFound = True\r
665         for Item in LibList:\r
666             LibName = Item[0].split(DataType.TAB_VALUE_SPLIT)[0].strip()\r
667             if LibName == LibraryClass:\r
668                 return\r
669         \r
670         if NotFound:\r
671             self.InfDatabase[infFileName].Contents[Arch].LibraryClasses.extend([LibraryClass])\r
672     \r
673     def AddToInfDatabase(self, infFileName):\r
674         infFileName = NormPath(infFileName)\r
675         file = self.WorkspaceFile(infFileName)\r
676         if os.path.exists(file) and os.path.isfile(file):\r
677             if infFileName not in self.InfDatabase:\r
678                 self.InfDatabase[infFileName] = Inf(file, True)\r
679                 \r
680     def AddToDecDatabase(self, decFileName):\r
681         decFileName = NormPath(decFileName)\r
682         file = self.WorkspaceFile(decFileName)\r
683         if os.path.exists(file) and os.path.isfile(file):\r
684             if decFileName not in self.DecDatabase:\r
685                 self.DecDatabase[decFileName] = Dec(file, True)\r
686                 \r
687     def FindLibraryClassInstanceOfModule(self, lib, arch, moduleType, moduleName):\r
688         for dsc in self.DscDatabase.keys():\r
689             #First find if exist in <LibraryClass> of <Components> from dsc file            \r
690             dscObj = self.DscDatabase[dsc]\r
691             for index in range(len(dscObj.Contents[arch].Components)):\r
692                 if NormPath(dscObj.Contents[arch].Components[index][0]) == moduleName and len(dscObj.Contents[arch].Components[index][1]) > 0:\r
693                     #Search each library class\r
694                     LibList = dscObj.Contents[arch].Components[index][1]\r
695                     for indexOfLib in range(len(LibList)):\r
696                         if LibList[indexOfLib].split(DataType.TAB_VALUE_SPLIT)[0].strip() == lib:\r
697                             return LibList[indexOfLib].split(DataType.TAB_VALUE_SPLIT)[1].strip()\r
698             \r
699             #Second find if exist in <LibraryClass> of <LibraryClasses> from dsc file            \r
700             if (lib, moduleType) in self.Build[arch].PlatformDatabase[dsc].LibraryClasses:\r
701                 return self.Build[arch].PlatformDatabase[dsc].LibraryClasses[(lib, moduleType)]\r
702             elif (lib, None) in self.Build[arch].PlatformDatabase[dsc].LibraryClasses:\r
703                 return self.Build[arch].PlatformDatabase[dsc].LibraryClasses[(lib, None)]\r
704             \r
705     def FindLibraryClassInstanceOfLibrary(self, lib, arch, type):\r
706         for dsc in self.DscDatabase.keys():\r
707             dscObj = self.DscDatabase[dsc]\r
708             if (lib, type) in self.Build[arch].PlatformDatabase[dsc].LibraryClasses:\r
709                 return self.Build[arch].PlatformDatabase[dsc].LibraryClasses[(lib, type)]\r
710             elif (lib, None) in self.Build[arch].PlatformDatabase[dsc].LibraryClasses:\r
711                 return self.Build[arch].PlatformDatabase[dsc].LibraryClasses[(lib, None)]\r
712             \r
713     def FindBuildOptions(self, arch, moduleName, BuildOptions):\r
714         for dsc in self.DscDatabase.keys():\r
715             #First find if exist in <BuildOptions> of <Components> from dsc file\r
716             dscObj = self.DscDatabase[dsc]\r
717             for index in range(len(dscObj.Contents[arch].Components)):\r
718                 if NormPath(dscObj.Contents[arch].Components[index][0]) == moduleName and len(dscObj.Contents[arch].Components[index][2]) > 0:\r
719                     list = dscObj.Contents[arch].Components[index][2]\r
720                     for l in list:\r
721                         b = l.split(DataType.TAB_EQUAL_SPLIT, 1)\r
722                         Family = ''\r
723                         ToolChain = ''\r
724                         Flag = ''\r
725                         if b[0].find(':') > -1:\r
726                             Family = CleanString(b[0][ : b[0].find(':')])\r
727                             ToolChain = CleanString(b[0][b[0].find(':') + 1 : ])\r
728                         else:\r
729                             ToolChain = CleanString(b[0])\r
730                         Flag = CleanString(b[1])\r
731                         BuildOptions[(Family, ToolChain)] = Flag\r
732                         \r
733     def FindPcd(self, arch, CName, GuidCName, Type):\r
734         DatumType = ''\r
735         DefaultValue = ''\r
736         TokenValue = ''\r
737         MaxDatumSize = ''\r
738         SkuInfoList = None\r
739         for dsc in self.Build[arch].PlatformDatabase.keys():\r
740             platform = self.Build[arch].PlatformDatabase[dsc]\r
741             pcds = platform.Pcds\r
742             if (CName, GuidCName) in pcds:\r
743                 Type = pcds[(CName, GuidCName)].Type\r
744                 DatumType = pcds[(CName, GuidCName)].DatumType\r
745                 DefaultValue = pcds[(CName, GuidCName)].DefaultValue\r
746                 TokenValue = pcds[(CName, GuidCName)].TokenValue\r
747                 MaxDatumSize = pcds[(CName, GuidCName)].MaxDatumSize\r
748                 SkuInfoList =  pcds[(CName, GuidCName)].SkuInfoList\r
749                 break\r
750 \r
751         for dec in self.Build[arch].PackageDatabase.keys():\r
752             package = self.Build[arch].PackageDatabase[dec]\r
753             pcds = package.Pcds\r
754             if (CName, GuidCName) in pcds:\r
755                 DatumType = pcds[(CName, GuidCName)].DatumType\r
756                 #DefaultValue = pcds[(CName, GuidCName)].DefaultValue\r
757                 TokenValue = pcds[(CName, GuidCName)].TokenValue\r
758                 #MaxDatumSize = pcds[(CName, GuidCName)].MaxDatumSize\r
759                 break\r
760         \r
761         return PcdClassObject(CName, GuidCName, Type, DatumType, DefaultValue, TokenValue, MaxDatumSize, SkuInfoList)\r
762     \r
763     def ReloadPcd(self, FvDict):\r
764         pass\r
765                 \r
766 # This acts like the main() function for the script, unless it is 'import'ed into another\r
767 # script.\r
768 if __name__ == '__main__':\r
769 \r
770     # Nothing to do here. Could do some unit tests.\r
771     w = os.getenv('WORKSPACE')\r
772     ewb = WorkspaceBuild('MdeModulePkg/MdeModulePkg.dsc', w)\r
773     ewb.GenBuildDatabase()\r
774     #print ewb.DscDatabase\r
775     #print ewb.InfDatabase\r
776     #print ewb.DecDatabase\r
777     print 'SupArchList', ewb.SupArchList\r
778     print 'BuildTarget', ewb.BuildTarget\r
779     print 'SkuId', ewb.SkuId\r
780     \r
781     #\r
782     for arch in DataType.ARCH_LIST:\r
783         print arch\r
784         print 'Platform'\r
785         for platform in ewb.Build[arch].PlatformDatabase.keys():\r
786             p = ewb.Build[arch].PlatformDatabase[platform]\r
787             print 'DescFilePath = ', p.DescFilePath     \r
788             print 'PlatformName = ', p.PlatformName     \r
789             print 'Guid = ', p.Guid                     \r
790             print 'Version = ', p.Version\r
791             print 'OutputDirectory = ', p.OutputDirectory                \r
792             print 'FlashDefinition = ', p.FlashDefinition\r
793             print 'SkuIds = ', p.SkuIds\r
794             print 'Modules = ', p.Modules\r
795             print 'LibraryClasses = ', p.LibraryClasses \r
796             print 'Pcds = ', p.Pcds\r
797             for item in p.Pcds.keys():\r
798                 print p.Pcds[item]\r
799             print 'BuildOptions = ', p.BuildOptions\r
800             print ''   \r
801         #End of Platform\r
802     \r
803         print 'package'\r
804         for package in ewb.Build[arch].PackageDatabase.keys():\r
805             p = ewb.Build[arch].PackageDatabase[package]\r
806             print 'DescFilePath = ', p.DescFilePath    \r
807             print 'PackageName = ', p.PackageName     \r
808             print 'Guid = ', p.Guid                    \r
809             print 'Version = ', p.Version             \r
810             print 'Protocols = ', p.Protocols         \r
811             print 'Ppis = ', p.Ppis                    \r
812             print 'Guids = ', p.Guids                 \r
813             print 'Includes = ', p.Includes            \r
814             print 'LibraryClasses = ', p.LibraryClasses\r
815             print 'Pcds = ', p.Pcds\r
816             print ''                    \r
817         #End of Package\r
818         \r
819         print 'module'\r
820         for module in ewb.Build[arch].ModuleDatabase.keys():\r
821             p = ewb.Build[arch].ModuleDatabase[module]\r
822             print 'DescFilePath = ', p.DescFilePath                    \r
823             print 'BaseName = ', p.BaseName                         \r
824             print 'ModuleType = ', p.ModuleType                     \r
825             print 'Guid = ', p.Guid                                 \r
826             print 'Version = ', p.Version\r
827             print 'CustomMakefile = ', p.CustomMakefile\r
828             print 'Specification = ', p.Specification\r
829             print 'PcdIsDriver = ', p.PcdIsDriver\r
830             if p.LibraryClass != None:\r
831                 print 'LibraryClass = ', p.LibraryClass.LibraryClass\r
832                 print 'SupModList = ', p.LibraryClass.SupModList\r
833             print 'ModuleEntryPointList = ', p.ModuleEntryPointList \r
834             print 'ModuleUnloadImageList = ', p.ModuleUnloadImageList\r
835             print 'ConstructorList = ', p.ConstructorList            \r
836             print 'DestructorList = ', p.DestructorList             \r
837                                                                      \r
838             print 'Binaries = '\r
839             for item in p.Binaries:\r
840                 print str(item)\r
841             print 'Sources = '\r
842             for item in p.Sources:\r
843                 print str(item)\r
844             print 'LibraryClasses = ', p.LibraryClasses             \r
845             print 'Protocols = ', p.Protocols                        \r
846             print 'Ppis = ', p.Ppis                                 \r
847             print 'Guids = ', p.Guids                                \r
848             print 'Includes = ', p.Includes                         \r
849             print 'Packages = ', p.Packages                         \r
850             print 'Pcds = ', p.Pcds\r
851             print 'BuildOptions = ', p.BuildOptions\r
852             print 'Depex = ', p.Depex\r
853             print ''\r
854         #End of Module    \r
855             \r
856     #End of Arch List\r