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