- Remove the TOOL without NAME defined and its definition in ARCH_build.opt
[mirror_edk2.git] / Tools / Python / buildgen / SurfaceAreaElement.py
CommitLineData
28972318 1#!/usr/bin/env python\r
2\r
3# Copyright (c) 2007, Intel Corporation\r
4# All rights reserved. This program and the accompanying materials\r
5# are licensed and made available under the terms and conditions of the BSD License\r
6# which accompanies this distribution. The full text of the license may be found at\r
7# http://opensource.org/licenses/bsd-license.php\r
8#\r
9# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12"""Framework SurfaceArea Elemments"""\r
13#\r
14# TODO: FFS layout, Flash, FV, PCD\r
15#\r
2082f936 16import os, sys, re, getopt, string, glob, xml.dom.minidom, pprint, time, copy, shelve, pickle\r
28972318 17from XmlRoutines import *\r
18import FrameworkElement\r
19import BuildConfig\r
20\r
21################################################################################\r
22##\r
23## Convert given list to a string in the format like: [a, b, c]\r
24##\r
25################################################################################\r
26def ListString(lst):\r
27 return "[%s]" % ",".join(lst)\r
28\r
29class SurfaceAreaElement:\r
30 """Base class for Surface Area XML element"""\r
31 _ModuleTypes = ('BASE', 'SEC', 'PEI_CORE', 'PEIM', 'DXE_CORE', 'DXE_DRIVER',\r
32 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'DXE_SMM_DRIVER',\r
33 'TOOL', 'UEFI_DRIVER', 'UEFI_APPLICATION', 'USER_DEFINED')\r
34 _GuidTypes = ('DATA_HUB_RECORD', 'EFI_EVENT', 'EFI_SYSTEM_CONFIGURATION_TABLE',\r
35 'EFI_VARIABLE', 'GUID', 'HII_PACKAGE_LIST', 'HOB', 'TOKEN_SPACE_GUID')\r
36 _Archs = ('EBC', 'IA32', 'X64', 'IPF', 'ARM', 'PPC')\r
37 _Usages = ('ALWAYS_CONSUMED', 'SOMETIMES_CONSUMED', 'ALWAYS_PRODUCED',\r
38 'SOMETIMES_PRODUCED', 'TO_START', 'BY_START', 'PRIVATE')\r
39 _FileTypes = {\r
40 ".c" : "CCode",\r
41 ".C" : "CCode",\r
42 ".cpp" : "CCode",\r
43 ".Cpp" : "CCode",\r
44 ".CPP" : "CCode",\r
45 ".h" : "CHeader",\r
46 ".H" : "CHeader",\r
47 ".asm" : "ASM",\r
48 ".Asm" : "Assembly",\r
49 ".ASM" : "Assembly",\r
50 ".s" : "IpfAssembly",\r
51 ".S" : "GccAssembly",\r
52 ".uni" : "UNI",\r
53 ".Uni" : "Unicode",\r
54 ".UNI" : "Unicode",\r
55 ".vfr" : "VFR",\r
56 ".Vfr" : "VFR",\r
57 ".VFR" : "VFR",\r
58 ".dxs" : "DPX",\r
59 ".Dxs" : "DPX",\r
60 ".DXS" : "DPX",\r
61 ".fv" : "FirmwareVolume",\r
62 ".Fv" : "FirmwareVolume",\r
63 ".FV" : "FirmwareVolume",\r
64 ".efi" : "EFI",\r
65 ".Efi" : "EFI",\r
66 ".EFI" : "EFI",\r
67 ".SEC" : "FFS",\r
68 ".PEI" : "FFS",\r
69 ".DXE" : "FFS",\r
70 ".APP" : "FFS",\r
71 ".FYI" : "FFS",\r
72 ".FFS" : "FFS",\r
73 ".bmp" : "BMP",\r
74 ".i" : "PPCode",\r
75 ".asl" : "ASL",\r
76 ".Asl" : "ASL",\r
77 ".ASL" : "ASL",\r
78 }\r
79 _ToolMapping = {\r
80 "CCode" : "CC",\r
81 "CHeader" : "",\r
82 "ASM" : "ASM",\r
83 "Assembly" : "ASM",\r
84 "IpfAssembly" : "ASM",\r
85 "GccAssembly" : "ASM",\r
86 "UNI" : "",\r
87 "Unicode" : "",\r
88 "VFR" : "",\r
89 "DPX" : "",\r
90 "FirmwareVolume" : "",\r
91 "EFI" : "",\r
92 "FFS" : "",\r
93 "PPCode" : "PP",\r
94 "BMP" : "",\r
95 }\r
96\r
97 _BuildableFileTypes = ("CCode", "ASM", "Assembly", "IpfAssembly", "GccAssembly", "UNI", "Unicode", "VFR", "DPX", "EFI")\r
98 \r
99 def __init__(self, workspace, owner=None, dom=None, parse=True, postprocess=True):\r
100 self._Workspace = workspace\r
101 \r
102 if owner == None: self._Owner = ""\r
103 else: self._Owner = owner\r
104 \r
105 if dom == None: self._Root = ""\r
106 else: self._Root = dom\r
107 \r
108 self._Elements = {}\r
109 \r
110 if parse: self.Parse()\r
111 if postprocess: self.Postprocess()\r
112 \r
113 def Parse(self):\r
114 """Parse the XML element in DOM form"""\r
115 pass\r
116 \r
117 def Postprocess(self):\r
118 """Re-organize the original information form XML DOM into a format which can be used directly"""\r
119 pass\r
120 \r
121 def GetArchList(self, dom):\r
122 """Parse the SupArchList attribute. If not spcified, return all ARCH supported"""\r
123 archs = XmlAttribute(dom, "SupArchList").split()\r
124 if archs == []:\r
125 if self._Owner.Archs != []:\r
126 archs = self._Owner.Archs\r
127 elif self._Workspace.ActiveArchs != []:\r
128 archs = self._Workspace.ActiveArchs\r
129 elif self._Workspace.ActivePlatform != "" and self._Workspace.ActivePlatform.Archs != []:\r
130 archs = self._Workspace.ActivePlatform.Archs\r
131 else:\r
132 archs = self._Archs\r
133 return archs\r
134 \r
135 def GetModuleTypeList(self, dom):\r
136 """Parse the SupModuleList attribute. If not specified, return all supported module types"""\r
137 moduleTypes = XmlAttribute(dom, "SupModuleList").split()\r
138 if moduleTypes == []:\r
139 moduleTypes = self._ModuleTypes\r
140 return moduleTypes\r
141 \r
142 def GetGuidTypeList(self, dom):\r
143 """Parse GuidTypeList attribute. Default to GUID if not specified"""\r
144 guidTypes = XmlAttribute(dom, "GuidTypeList")\r
145 if guidTypes == []:\r
146 guidTypes = ["GUID"]\r
147 return guidTypes\r
148\r
149 def GetFeatureList(self, dom):\r
150 """Parse FeatureFlag attribute"""\r
151 return XmlAttribute(dom, "FeatureFlag").split()\r
152 \r
153 def GetToolchainTagList(self, dom):\r
154 """Parse TagName attribute. Return all defined toolchains defined in tools_def.txt if not given"""\r
155 toolchainTagString = XmlAttribute(dom, "TagName")\r
156 if toolchainTagString == "":\r
157 return self._Workspace.ToolConfig.Toolchains\r
158 return toolchainTagString.split()\r
159 \r
160 def GetToolchainFamilyList(self, dom):\r
161 """Parse ToolChainFamily attribute. Return all defined toolchain families in tools_def.txt if not given"""\r
162 familyString = XmlAttribute(dom, "ToolChainFamily")\r
163 if familyString != "":\r
164 return familyString.split()\r
165 return self._Workspace.ToolConfig.Families\r
166 \r
167 def GetTargetList(self, dom):\r
168 """Parse BuildTargets attribute. Return all build targets defined in tools_def.txt if not given"""\r
169 targetList = XmlAttribute(dom, "BuildTargets").split()\r
170 if targetList == []:\r
171 targetList = self._Workspace.ToolConfig.Targets\r
172 return targetList\r
173 \r
174 def GetUsage(self, dom):\r
175 """Parse Usage attribute. Default to ALWAYS_CONSUMED if not given"""\r
176 usageString = XmlAttribute(dom, "Usage")\r
177 if usageString == "":\r
178 return "ALWAYS_CONSUMED"\r
179 return usageString\r
180 \r
181 def GetBuildOptionList(self, dom):\r
182 """Parse Options/Option element. Return a options dictionay with keys as (toolchain, target, arch, toolcode, attr)"""\r
183 optionList = XmlList(dom, "/Options/Option")\r
184 buildOptions = {}\r
185 for option in optionList:\r
186 targets = self.GetTargetList(option)\r
187 toolchainFamilies = self.GetToolchainFamilyList(option)\r
188 toolchainTags = self.GetToolchainTagList(option)\r
189 toolcode = XmlAttribute(option, "ToolCode")\r
190 archs = self.GetArchList(option)\r
191 flag = XmlElementData(option)\r
192 # print flag\r
193\r
194 toolchains = []\r
195 if toolchainTags != []:\r
196 toolchains = toolchainTags\r
197 elif toolchainFamilies != []:\r
198 toolchains = toolchainFamilies\r
199 else:\r
200 raise Exception("No toolchain specified for a build option: " + self._Owner.Name)\r
201\r
202 if targets == []: targets = self._Workspace.ActiveTargets\r
203 if archs == []: archs = self._Workspace.ActiveArchs\r
204\r
205 for toolchain in toolchains:\r
206 for target in targets:\r
207 for arch in archs:\r
208 buildOptions[(toolchain, target, arch, toolcode, "FLAGS")] = flag\r
209 return buildOptions\r
210\r
211 def GetFvBindingList(self, dom):\r
212 """Parse FvBinding element. If not specified, return NULL FV"""\r
213 fvBindingList = XmlElementData(dom).split()\r
214 if fvBindingList == []:\r
215 fvBindingList = ["NULL"]\r
216 return fvBindingList\r
217 \r
218 def IsBuildable(self, type):\r
219 """Test if a file with the type can be built by a tool"""\r
220 return type in self._BuildableFileTypes\r
221 \r
222 def GetToolCode(self, type):\r
223 """Get the toolcode which must be used to build files with the type"""\r
224 toolcode = ""\r
225 if type in self._ToolMapping:\r
226 toolcode = self._ToolMapping[type]\r
227 return toolcode\r
228 \r
229 def GetBoolean(self, dom):\r
230 """Transate true/false in string form to python's True/False value"""\r
231 boolString = XmlElementData(dom).upper()\r
232 if boolString == "" or boolString == "FALSE" or boolString == "NO":\r
233 return False\r
234 else:\r
235 return True\r
236 \r
237class LibraryDeclaration(FrameworkElement.LibraryInterface, SurfaceAreaElement):\r
238 def __init__(self, workspace, package, dom):\r
239 FrameworkElement.LibraryInterface.__init__(self)\r
240 self.Package = package\r
241 SurfaceAreaElement.__init__(self, workspace, package, dom)\r
242\r
243 def Parse(self):\r
244 dom = self._Root\r
245 self.Name = XmlAttribute(dom, "Name")\r
2082f936 246 self.Path = os.path.normpath(XmlElementData(XmlNode(dom, "/LibraryClass/IncludeHeader")))\r
28972318 247 self.Dir = os.path.dirname(self.Path)\r
248 \r
249 attribute = XmlAttribute(dom, "RecommendedInstanceGuid")\r
250 if attribute is not '':\r
251 self.FavoriteIntance = FrameworkElement.Module()\r
252 self.FavoriteIntance.Guid = attribute\r
253\r
254 attribute = XmlAttribute(dom, "RecommendedInstanceVersion")\r
255 if attribute is not '':\r
256 if self.FavoriteIntance == "":\r
257 raise "No GUID for the recommened library instance"\r
258 self.FavoriteIntance.Version = attribute\r
259\r
260 self.Archs = self.GetArchList(dom)\r
261 self.ModuleTypes = self.GetModuleTypeList(dom)\r
262\r
263class LibraryClass(FrameworkElement.LibraryClass, SurfaceAreaElement):\r
264 def __init__(self, workspace, module, dom):\r
265 FrameworkElement.LibraryClass.__init__(self)\r
266 SurfaceAreaElement.__init__(self, workspace, module, dom)\r
267\r
268 def Parse(self):\r
269 dom = self._Root\r
270 \r
2082f936 271 self.Name = XmlElementData(XmlNode(dom, "/LibraryClass/Keyword"))\r
28972318 272 self.Usage = self.GetUsage(dom)\r
273 self.Features = self.GetFeatureList(dom)\r
274 self.Archs = self.GetArchList(dom)\r
275\r
276 attribute = XmlAttribute(dom, "RecommendedInstanceGuid")\r
277 if attribute is not '':\r
278 self.FavoriteIntance = FrameworkElement.Module()\r
279 self.FavoriteIntance.Guid = attribute\r
280\r
281 attribute = XmlAttribute(dom, "RecommendedInstanceVersion")\r
282 if attribute is not '':\r
283 if self.FavoriteIntance == "":\r
284 self.FavoriteIntance = FrameworkElement.Module()\r
285 self.FavoriteIntance.Version = attribute\r
286\r
28972318 287class SourceFile(FrameworkElement.SourceFile, SurfaceAreaElement):\r
288 def __init__(self, workspace, module, dom):\r
289 FrameworkElement.SourceFile.__init__(self)\r
290 SurfaceAreaElement.__init__(self, workspace, module, dom)\r
291\r
292 def Parse(self):\r
293 dom = self._Root\r
294 self.Path = os.path.normpath(XmlElementData(dom))\r
295 self.Dir = os.path.dirname(self.Path)\r
296 self.Type = self.GetFileType()\r
297 self.Toolchains = self.GetToolchainTagList(dom)\r
298 self.Families = self.GetToolchainFamilyList(dom)\r
299 self.Archs = self.GetArchList(dom)\r
300 self.Features = self.GetFeatureList(dom)\r
301\r
302 def GetFileType(self):\r
303 type = XmlAttribute(self._Root, "ToolCode")\r
304 if type == "":\r
305 fileName = os.path.basename(self.Path)\r
306 self.BaseName,self.Ext = os.path.splitext(fileName)\r
307 if self.Ext in self._FileTypes:\r
308 type = self._FileTypes[self.Ext]\r
309 else:\r
310 type = ""\r
311 return type\r
312 \r
313class PackageDependency(FrameworkElement.PackageDependency, SurfaceAreaElement):\r
314 def __init__(self, workspace, module, dom):\r
315 FrameworkElement.PackageDependency.__init__(self)\r
316 SurfaceAreaElement.__init__(self, workspace, module, dom)\r
317\r
318 def Parse(self):\r
319 dom = self._Root\r
320 self.GuidValue = XmlAttribute(dom, "PackageGuid").upper()\r
321 self.Version = XmlAttribute(dom, "PackageVersion")\r
322 self.Archs = self.GetArchList(dom)\r
323 self.Features = self.GetFeatureList(dom)\r
324\r
325 def Postprocess(self):\r
326 self.Package = self._Workspace.GetPackage(self.GuidValue, self.Version)\r
327 if self.Package == "": raise "No package with GUID=" + self.GuidValue + "VERSION=" + self.Version\r
328\r
329class Protocol(FrameworkElement.Protocol, SurfaceAreaElement):\r
330 def __init__(self, workspace, module, dom):\r
331 FrameworkElement.Protocol.__init__(self)\r
332 SurfaceAreaElement.__init__(self, workspace, module, dom)\r
333\r
334 def Parse(self):\r
335 dom = self._Root\r
2082f936 336 self.CName = XmlElementData(XmlNode(dom, "/Protocol/ProtocolCName"))\r
28972318 337 self.Usage = self.GetUsage(dom)\r
338 self.Archs = self.GetArchList(dom)\r
339 self.Features = self.GetFeatureList(dom)\r
340\r
341 def Postprocess(self):\r
342 for pd in self._Owner._Elements["PackageDependencies"]:\r
343 if self.CName not in pd.Package.Protocols: continue\r
344 self.GuidValue = pd.Package.Protocols[self.CName]\r
345\r
346class ProtocolNotify(FrameworkElement.ProtocolNotify, SurfaceAreaElement):\r
347 def __init__(self, workspace, module, dom):\r
348 FrameworkElement.ProtocolNotify.__init__(self)\r
349 SurfaceAreaElement.__init__(self, workspace, module, dom)\r
350\r
351 def Parse(self):\r
352 dom = self._Root\r
353 \r
2082f936 354 self.CName = XmlElementData(XmlNode(dom, "/ProtocolNotify/ProtocolCName"))\r
28972318 355 self.Usage = self.GetUsage(dom)\r
356 self.Archs = self.GetArchList(dom)\r
357 self.Features = self.GetFeatureList(dom)\r
358\r
359 def Postprocess(self):\r
360 for pd in self._Owner._Elements["PackageDependencies"]:\r
361 if self.CName not in pd.Package.Protocols: continue\r
362 self.GuidValue = pd.Package.Protocols[self.CName]\r
363\r
364class Ppi(FrameworkElement.Ppi, SurfaceAreaElement):\r
365 def __init__(self, workspace, module, dom):\r
366 FrameworkElement.Ppi.__init__(self)\r
367 SurfaceAreaElement.__init__(self, workspace, module, dom)\r
368\r
369 def Parse(self):\r
370 dom = self._Root\r
2082f936 371 self.CName = XmlElementData(XmlNode(dom, "/Ppi/PpiCName"))\r
28972318 372 self.Usage = self.GetUsage(dom)\r
373 self.Archs = self.GetArchList(dom)\r
374 self.Features = self.GetFeatureList(dom)\r
375\r
376 def Postprocess(self):\r
377 for pd in self._Owner._Elements["PackageDependencies"]:\r
378 if self.CName not in pd.Package.Ppis: continue\r
379 self.GuidValue = pd.Package.Ppis[self.CName]\r
380\r
381class PpiNotify(FrameworkElement.PpiNotify, SurfaceAreaElement):\r
382 def __init__(self, workspace, module, dom):\r
383 FrameworkElement.PpiNotify.__init__(self)\r
384 SurfaceAreaElement.__init__(self, workspace, module, dom)\r
385\r
386 def Parse(self):\r
387 dom = self._Root\r
2082f936 388 self.CName = XmlElementData(XmlNode(dom, "/PpiNotify/PpiCName"))\r
28972318 389 self.Usage = self.GetUsage(dom)\r
390 self.Archs = self.GetArchList(dom)\r
391 self.Features = self.GetFeatureList(dom)\r
392\r
393 def Postprocess(self):\r
394 for pd in self._Owner._Elements["PackageDependencies"]:\r
395 if self.CName not in pd.Package.Ppis: continue\r
396 self.GuidValue = pd.Package.Ppis[self.CName]\r
397\r
398class Guid(FrameworkElement.Guid, SurfaceAreaElement):\r
399 def __init__(self, workspace, module, dom):\r
400 FrameworkElement.Guid.__init__(self)\r
401 SurfaceAreaElement.__init__(self, workspace, module, dom)\r
402\r
403 def Parse(self):\r
404 dom = self._Root\r
2082f936 405 self.CName = XmlElementData(XmlNode(dom, "/GuidCNames/GuidCName"))\r
28972318 406 self.Usage = self.GetUsage(dom)\r
407 self.Archs = self.GetArchList(dom)\r
408 self.Features = self.GetFeatureList(dom)\r
409\r
410 def Postprocess(self):\r
411 for pd in self._Owner._Elements["PackageDependencies"]:\r
412 if self.CName not in pd.Package.Guids: continue\r
413 self.GuidValue = pd.Package.Guids[self.CName]\r
414\r
415class Extern(FrameworkElement.Extern, SurfaceAreaElement):\r
416 def __init__(self, workspace, module, dom):\r
417 FrameworkElement.Extern.__init__(self)\r
418 SurfaceAreaElement.__init__(self, workspace, module, dom)\r
419\r
420 def Parse(self):\r
421 dom = self._Root\r
422 self.Archs = self.GetArchList(dom)\r
423 self.Features = self.GetFeatureList(dom)\r
424 \r
2082f936 425 extern = XmlNode(dom, "/Extern/ModuleEntryPoint")\r
28972318 426 if extern is not None and extern is not '':\r
427 self.ModuleEntryPoints.append(XmlElementData(extern))\r
428 \r
2082f936 429 extern = XmlNode(dom, "/Extern/ModuleUnloadImage")\r
28972318 430 if extern is not None and extern is not '':\r
431 self.ModuleUnloadImages.append(XmlElementData(extern))\r
432 \r
2082f936 433 extern = XmlNode(dom, "/Extern/Constructor")\r
28972318 434 if extern is not None and extern is not '':\r
435 self.Constructors.append(XmlElementData(extern))\r
436 \r
2082f936 437 extern = XmlNode(dom, "/Extern/Destructor")\r
28972318 438 if extern is not None and extern is not '':\r
439 self.Destructors.append(XmlElementData(extern))\r
440 \r
2082f936 441 extern = XmlNode(dom, "/Extern/DriverBinding")\r
28972318 442 if extern is not None and extern is not '':\r
443 self.DriverBindings.append(XmlElementData(extern))\r
444 \r
2082f936 445 extern = XmlNode(dom, "/Extern/ComponentName")\r
28972318 446 if extern is not None and extern is not '':\r
447 self.ComponentNames.append(XmlElementData(extern))\r
448 \r
2082f936 449 extern = XmlNode(dom, "/Extern/DriverConfig")\r
28972318 450 if extern is not None and extern is not '':\r
451 self.DriverConfigs.append(XmlElementData(extern))\r
452 \r
2082f936 453 extern = XmlNode(dom, "/Extern/DriverDiag")\r
28972318 454 if extern is not None and extern is not '':\r
455 self.DriverDiags.append(XmlElementData(extern))\r
456\r
2082f936 457 extern = XmlNode(dom, "/Extern/SetVirtualAddressMapCallBacks")\r
28972318 458 if extern is not None and extern is not '':\r
459 self.SetVirtualAddressMapCallBacks.append(XmlElementData(extern))\r
460\r
2082f936 461 extern = XmlNode(dom, "/Extern/ExitBootServicesCallBack")\r
28972318 462 if extern is not None and extern is not '':\r
463 self.ExitBootServicesCallBacks.append(XmlElementData(extern))\r
464\r
465class IndustryStdHeader(FrameworkElement.IncludeFile, SurfaceAreaElement):\r
466 def __init__(self, workspace, package, dom):\r
467 FrameworkElement.IncludeFile.__init__(self)\r
468 SurfaceAreaElement.__init__(self, workspace, package, dom)\r
469\r
470 def Parse(self):\r
471 dom = self._Root\r
2082f936 472 self.Path = os.path.normpath(XmlElementData(XmlNode(dom, "/IndustryStdHeader/IncludeHeader")))\r
28972318 473 self.Dir = os.path.dirname(self.Path)\r
474 self.Archs = self.GetArchList(dom)\r
475 self.ModuleTypes = self.GetModuleTypeList(dom)\r
476\r
477class PackageHeader(FrameworkElement.IncludeFile, SurfaceAreaElement):\r
478 def __init__(self, workspace, package, dom):\r
479 FrameworkElement.IncludeFile.__init__(self)\r
480 SurfaceAreaElement.__init__(self, workspace, package, dom)\r
481\r
482 def Parse(self):\r
483 dom = self._Root\r
484 self.Path = os.path.normpath(XmlElementData(dom))\r
485 self.Dir = os.path.dirname(self.Path)\r
486 self.ModuleType = XmlAttribute(dom, "ModuleType")\r
487\r
488class GuidDeclaration(FrameworkElement.Guid, SurfaceAreaElement):\r
489 def __init__(self, workspace, package, dom):\r
490 FrameworkElement.Guid.__init__(self)\r
491 SurfaceAreaElement.__init__(self, workspace, package, dom)\r
492\r
493 def Parse(self):\r
494 dom = self._Root\r
2082f936 495 self.CName = XmlElementData(XmlNode(dom, "/Entry/C_Name"))\r
496 self.GuidValue = XmlElementData(XmlNode(dom, "/Entry/GuidValue")).upper()\r
28972318 497 self.Name = XmlAttribute(dom, "Name")\r
498 self.Types = self.GetGuidTypeList(dom)\r
499 self.Archs = self.GetArchList(dom)\r
500 self.ModuleTypes = self.GetModuleTypeList(dom)\r
501\r
502 def Postprocess(self):\r
503 pass\r
504 \r
505class ProtocolDeclaration(GuidDeclaration, SurfaceAreaElement):\r
506 pass\r
507\r
508class PpiDeclaration(GuidDeclaration, SurfaceAreaElement):\r
509 pass\r
510\r
511class PcdDeclaration(FrameworkElement.Pcd, SurfaceAreaElement):\r
512 def __init__(self, workspace, package, dom):\r
513 FrameworkElement.Pcd.__init__(self)\r
514 SurfaceAreaElement.__init__(self, workspace, package, dom)\r
515\r
516 def Parse(self):\r
517 dom = self._Root\r
2082f936 518 self.Types = XmlElementData(XmlNode(dom, "/PcdEntry/ValidUsage")).split()\r
519 self.CName = XmlElementData(XmlNode(dom, "/PcdEntry/C_Name"))\r
520 self.Token = XmlElementData(XmlNode(dom, "/PcdEntry/Token"))\r
521 self.TokenSpace = XmlElementData(XmlNode(dom, "/PcdEntry/TokenSpaceGuidCName"))\r
522 self.DatumType = XmlElementData(XmlNode(dom, "/PcdEntry/DatumType"))\r
523 self.Default = XmlElementData(XmlNode(dom, "/PcdEntry/DefaultValue"))\r
28972318 524 self.Archs = self.GetArchList(dom)\r
525 self.ModuleTypes= self.GetModuleTypeList(dom)\r
526\r
527class LibraryInstance(FrameworkElement.PlatformModule, SurfaceAreaElement):\r
528 def __init__(self, workspace, platformModule, dom):\r
529 FrameworkElement.PlatformModule.__init__(self)\r
530 SurfaceAreaElement.__init__(self, workspace, platformModule, dom)\r
531\r
532 def Parse(self):\r
533 dom = self._Root\r
534 self.GuidValue = XmlAttribute(dom, "ModuleGuid").upper()\r
535 self.Version = XmlAttribute(dom, "ModuleVersion")\r
536 self._Elements["PackageGuid"] = XmlAttribute(dom, "PackageGuid").upper()\r
537 self._Elements["PackageVersion"] = XmlAttribute(dom, "PackageVersion")\r
538 \r
539 def Postprocess(self):\r
540 self.Module = self._Workspace.GetModule(self.GuidValue, self.Version,\r
541 self._Elements["PackageGuid"], self._Elements["PackageVersion"])\r
542 self.Platform = self._Owner.Platform\r
543 self.Archs = self._Owner.Archs\r
544 self.Pcds = self._Owner.Pcds\r
545 self.BuildType = "lib"\r
546\r
547class PlatformModule(FrameworkElement.PlatformModule, SurfaceAreaElement):\r
548 def __init__(self, workspace, platform, dom):\r
549 FrameworkElement.PlatformModule.__init__(self)\r
550 self.Platform = platform\r
551 SurfaceAreaElement.__init__(self, workspace, platform, dom)\r
552\r
553 def Parse(self):\r
554 dom = self._Root\r
555 self.GuidValue = XmlAttribute(dom, "ModuleGuid").upper()\r
556 self.Version = XmlAttribute(dom, "ModuleVersion")\r
557 self.Archs = self.GetArchList(dom)\r
558\r
559 self._Elements["PackageGuid"] = XmlAttribute(dom, "PackageGuid").upper()\r
560 self._Elements["PackageVersion"] = XmlAttribute(dom, "PackageVersion")\r
561\r
562 libraryList = XmlList(dom, "/ModuleSA/Libraries/Instance")\r
563 for lib in libraryList:\r
564 self.Libraries.append(LibraryInstance(self._Workspace, self, lib))\r
565 \r
2082f936 566 dom = XmlNode(dom, "/ModuleSA/ModuleSaBuildOptions")\r
567 self.FvBindings = self.GetFvBindingList(XmlNode(dom, "/ModuleSaBuildOptions/FvBinding"))\r
568 self.FfsLayouts = XmlElementData(XmlNode(dom, "/ModuleSaBuildOptions/FfsFormatKey")).split()\r
569 self.BuildOptions = self.GetBuildOptionList(XmlNode(dom, "/ModuleSaBuildOptions/Options"))\r
28972318 570\r
571 def Postprocess(self):\r
572 self.Module = self._Workspace.GetModule(self.GuidValue, self.Version,\r
573 self._Elements["PackageGuid"], self._Elements["PackageVersion"])\r
574 if self.Module == "":\r
575 raise Exception("No module found: \n\t\tGUID=%s \n\t\tVERSION=%s \n\t\tPACKAGE_GUID=%s \n\t\tPACKAGE_VERSION=%s" % (\r
576 self.GuidValue, self.Version, self._Elements["PackageGuid"], self._Elements["PackageVersion"]))\r
577 \r
578## def SetupEnvironment(self):\r
579## self.Environment = {\r
580## "ARCH" : "",\r
581## "MODULE_BUILD_TARGET" : "",\r
582## "SINGLE_MODULE_BUILD" : "",\r
583## "PLATFORM_PREBUILD" : "",\r
584## "PLATFORM_POSTBUILD" : "",\r
585## "LIBS" : "",\r
586## "SOURCE_FILES" : "",\r
587## "ENTRYPOINT" : "_ModuleEntryPoint",\r
588## } # name/value pairs\r
589## self.Environment["MODULE_BUILD_TARGET"] = "platform_module_build"\r
590\r
591class ModuleSurfaceArea(FrameworkElement.Module, SurfaceAreaElement):\r
592 def __init__(self, workspace, package, path):\r
593 FrameworkElement.Module.__init__(self)\r
594\r
595 self.Path = os.path.normpath(path)\r
596 self.Dir = os.path.dirname(self.Path)\r
597 self.FileBaseName,_ext = os.path.splitext(os.path.basename(self.Path))\r
598 self.Package = package\r
599 SurfaceAreaElement.__init__(self, workspace, package)\r
600\r
601 def _MsaHeader(self, xpath):\r
2082f936 602 dom = XmlNode(self._Root, xpath)\r
28972318 603 if dom == '': return\r
2082f936 604 self.Name = XmlElementData(XmlNode(dom, "/MsaHeader/ModuleName"))\r
605 self.Type = XmlElementData(XmlNode(dom, "/MsaHeader/ModuleType"))\r
606 self.GuidValue = XmlElementData(XmlNode(dom, "/MsaHeader/GuidValue")).upper()\r
607 self.Version = XmlElementData(XmlNode(dom, "/MsaHeader/Version"))\r
28972318 608 \r
609 def _ModuleDefinitions(self, xpath):\r
2082f936 610 dom = XmlNode(self._Root, xpath)\r
28972318 611 if dom == '': return\r
2082f936 612 self.Archs = XmlElementData(XmlNode(dom, "/ModuleDefinitions/SupportedArchitectures")).split()\r
613 self.IsBinary = self.GetBoolean(XmlNode(dom, "/ModuleDefinitions/BinaryModule"))\r
614 self.BaseName = XmlElementData(XmlNode(dom, "/ModuleDefinitions/OutputFileBasename"))\r
28972318 615 \r
616 def _LibraryClassDefinitions(self, xpath):\r
2082f936 617 dom = XmlNode(self._Root, xpath)\r
28972318 618 if dom == '': return\r
619 lcList = []\r
620 for lc in XmlList(dom, "/LibraryClassDefinitions/LibraryClass"):\r
621 lcList.append(LibraryClass(self._Workspace, self, lc))\r
622 self._Elements["LibraryClassDefinitions"] = lcList\r
623\r
624 def _SourceFiles(self, xpath):\r
2082f936 625 dom = XmlNode(self._Root, xpath)\r
28972318 626 if dom == '': return\r
627 srcList = []\r
628 for f in XmlList(dom, "/SourceFiles/Filename"):\r
629 srcList.append(SourceFile(self._Workspace, self, f))\r
630 self._Elements["SourceFiles"] = srcList\r
631\r
632 def _NonProcessedFiles(self, xpath):\r
2082f936 633 dom = XmlNode(self._Root, xpath)\r
28972318 634 if dom == '': return\r
635 for f in XmlList(dom, "/NonProcessedFiles/Filename"):\r
636 self.NonProcessedFiles.append(SourceFile(self._Workspace, self, f))\r
637\r
638 def _PackageDependencies(self, xpath):\r
2082f936 639 dom = XmlNode(self._Root, xpath)\r
28972318 640 if dom == '': return\r
641 pdList = []\r
642 for pkg in XmlList(dom, "/PackageDependencies/Package"):\r
643 pdList.append(PackageDependency(self._Workspace, self, pkg))\r
644 self._Elements["PackageDependencies"] = pdList\r
645\r
646 def _Protocols(self, xpath):\r
2082f936 647 dom = XmlNode(self._Root, xpath)\r
28972318 648 if dom == '': return\r
649 \r
650 protocolList = []\r
651 for p in XmlList(dom, "/Protocols/Protocol"):\r
652 protocolList.append(Protocol(self._Workspace, self, p))\r
653 for p in XmlList(dom, "/Protocols/ProtocolNotify"):\r
654 protocolList.append(ProtocolNotify(self._Workspace, self, p))\r
655 \r
656 self._Elements["Protocols"] = protocolList\r
657\r
658 def _Ppis(self, xpath):\r
2082f936 659 dom = XmlNode(self._Root, xpath)\r
28972318 660 if dom == '': return\r
661 \r
662 ppiList = []\r
663 for p in XmlList(dom, "/PPIs/Ppi"):\r
664 ppiList.append(Ppi(self._Workspace, self, p))\r
665 for p in XmlList(dom, "/PPIs/PpiNotify"):\r
666 ppiList.append(PpiNotify(self._Workspace, self, p))\r
667 \r
668 self._Elements["PPIs"] = ppiList\r
669\r
670 def _Guids(self, xpath):\r
2082f936 671 dom = XmlNode(self._Root, xpath)\r
28972318 672 if dom == '': return\r
673 guidList = []\r
674 for g in XmlList(dom, "/Guids/GuidCNames"):\r
675 guidList.append(Guid(self._Workspace, self, g))\r
676 self._Elements["Guids"] = guidList\r
677\r
678 def _Externs(self, xpath):\r
2082f936 679 dom = XmlNode(self._Root, xpath)\r
28972318 680 if dom == '': return\r
2082f936 681 self.PcdIsDriver = self.GetBoolean(XmlNode(dom, "/Externs/PcdIsDriver"))\r
682 self.NeedsFlashMap_h = self.GetBoolean(XmlNode(dom, "/Externs/TianoR8FlashMap_h"))\r
28972318 683\r
684 externList = []\r
685 specs = FrameworkElement.Extern()\r
686 specs.Archs = self._Archs\r
687 externList.append(specs)\r
688 for spec in XmlList(dom, "/Externs/Specification"):\r
689 specs.Specifications.append(XmlElementData(spec))\r
690 for ext in XmlList(dom, "/Externs/Extern"):\r
691 externList.append(Extern(self._Workspace, self, ext))\r
692 self._Elements["Externs"] = externList\r
693\r
694 def _ModuleBuildOptions(self, xpath):\r
2082f936 695 dom = XmlNode(self._Root, xpath)\r
28972318 696 if dom == '': return\r
2082f936 697 self.BuildOptions = self.GetBuildOptionList(XmlNode(dom, "/ModuleBuildOptions/Options"))\r
28972318 698\r
699 def _UserExtensions(self, xpath):\r
700 domList = XmlList(self._Root, xpath)\r
701 if domList == []: return\r
702 for extension in domList:\r
703 userId = XmlAttribute(extension, "UserID")\r
704 identifier = XmlAttribute(extension, "Identifier")\r
705 if userId == '' or identifier == '':\r
706 raise Exception("No UserId or Identifier specified")\r
707 if userId != "TianoCore": continue\r
708 if identifier not in self.UserExtensions:\r
709 self.UserExtensions[identifier] = []\r
710\r
711 contentList = self.UserExtensions[identifier]\r
712 for node in extension.childNodes:\r
713 #print node.nodeType\r
714 contentList.append(node.cloneNode(True))\r
715\r
716 def Parse(self):\r
717 fileFullPath = self._Workspace.SubPath(os.path.dirname(self.Package.Path), self.Path)\r
718 self._Root = xml.dom.minidom.parse(fileFullPath)\r
719 assert self._Root.documentElement.tagName == "ModuleSurfaceArea"\r
720\r
721 # print " Parsing...",self.Path\r
722 self._MsaHeader("/ModuleSurfaceArea/MsaHeader")\r
723 self._ModuleDefinitions("/ModuleSurfaceArea/ModuleDefinitions")\r
724 self._PackageDependencies("/ModuleSurfaceArea/PackageDependencies")\r
725 self._LibraryClassDefinitions("/ModuleSurfaceArea/LibraryClassDefinitions")\r
726 self._SourceFiles("/ModuleSurfaceArea/SourceFiles")\r
727 self._NonProcessedFiles("/ModuleSurfaceArea/NonProcessedFiles")\r
728 self._Protocols("/ModuleSurfaceArea/Protocols")\r
729 self._Ppis("/ModuleSurfaceArea/Ppis")\r
730 self._Guids("/ModuleSurfaceArea/Guids")\r
731 self._Externs("/ModuleSurfaceArea/Externs")\r
732 self._ModuleBuildOptions("/ModuleSurfaceArea/ModuleBuildOptions")\r
733 self._UserExtensions("/ModuleSurfaceArea/UserExtensions")\r
734\r
735 def Postprocess(self):\r
736 # resolve package dependency\r
737 if self._Elements.has_key("PackageDependencies"):\r
738 for pd in self._Elements["PackageDependencies"]:\r
739 package = pd.Package\r
740 if self.Type not in package.PackageIncludes:\r
741 print "! Module type %s is not supported in the package %s" % (self.Type, package.Name)\r
742\r
743 for arch in pd.Archs:\r
744 if arch not in self.IncludePaths:\r
745 self.IncludePaths[arch] = []\r
746 self.IncludePaths[arch].append(package.SubPath("Include"))\r
747 self.IncludePaths[arch].append(package.SubPath("Include", arch.capitalize()))\r
748\r
749 if arch not in self.IncludeFiles:\r
750 self.IncludeFiles[arch] = []\r
751 if self.Type in package.PackageIncludes:\r
752 for path in package.PackageIncludes[self.Type]:\r
753 self.IncludeFiles[arch].append(package.SubPath(path))\r
754\r
755 # resolve library class\r
756 if self._Elements.has_key("LibraryClassDefinitions"):\r
757 for lc in self._Elements["LibraryClassDefinitions"]:\r
d59f2c72 758 lc.Interface = self.GetLibraryInterface(lc.Name)\r
28972318 759 if "ALWAYS_PRODUCED" in lc.Usage:\r
760 self.IsLibrary = True\r
761 lc.Interface.Instances.append(self)\r
762 else:\r
763 lc.Interface.Consumers.append(self)\r
764\r
765 for arch in lc.Archs:\r
766 if arch not in self.LibraryClasses:\r
767 self.LibraryClasses[arch] = []\r
768 self.LibraryClasses[arch].append(lc)\r
769 \r
770 # expand source files\r
771 if self._Elements.has_key("SourceFiles"):\r
772 for src in self._Elements["SourceFiles"]:\r
773 for arch in src.Archs:\r
774 if arch not in self.SourceFiles:\r
775 self.SourceFiles[arch] = {}\r
776 if src.Type not in self.SourceFiles[arch]:\r
777 self.SourceFiles[arch][src.Type] = []\r
778 self.SourceFiles[arch][src.Type].append(src)\r
779 \r
780 # expand guids\r
781 if self._Elements.has_key("Guids"):\r
782 for guid in self._Elements["Guids"]:\r
783 for arch in guid.Archs:\r
784 if arch not in self.Guids:\r
785 self.Guids[arch] = []\r
786 self.Guids[arch].append(guid)\r
787 \r
788 # expand protocol\r
789 if self._Elements.has_key("Protocols"):\r
790 for protocol in self._Elements["Protocols"]:\r
791 for arch in protocol.Archs:\r
792 if arch not in self.Protocols:\r
793 self.Protocols[arch] = []\r
794 self.Protocols[arch].append(protocol)\r
795\r
796 # expand ppi\r
797 if self._Elements.has_key("PPIs"):\r
798 for ppi in self._Elements["PPIs"]:\r
799 for arch in ppi.Archs:\r
800 if arch not in self.Ppis:\r
801 self.Ppis[arch] = []\r
802 self.Ppis[arch].append(ppi)\r
803 \r
804 # expand extern\r
805 if self._Elements.has_key("Externs"):\r
806 for extern in self._Elements["Externs"]:\r
807 for arch in extern.Archs:\r
808 if arch not in self.Externs:\r
809 self.Externs[arch] = []\r
810 self.Externs[arch].append(extern)\r
d59f2c72 811 \r
812 def GetLibraryInterface(self, name):\r
813 if name in self.Package.LibraryInterfaces:\r
814 return self.Package.LibraryInterfaces[name]\r
815 for pd in self._Elements["PackageDependencies"]:\r
816 if name in pd.Package.LibraryInterfaces:\r
817 return pd.Package.LibraryInterfaces[name]\r
818 return ""\r
28972318 819## def SetupEnvironment(self):\r
820## self.Environment["MODULE"] = self.Name\r
821## self.Environment["MODULE_GUID"] = self.GuidValue\r
822## self.Environment["MODULE_VERSION"] = self.Version\r
823## self.Environment["MODULE_TYPE"] = self.Type\r
824## self.Environment["MODULE_FILE_BASE_NAME"] = os.path.basename(self.Path).split(".")[0]\r
825## self.Environment["MODULE_RELATIVE_DIR"] = os.path.dirname(self.Path)\r
826## self.Environment["BASE_NAME"] = self.OutputName\r
827\r
828class Workspace(FrameworkElement.Workspace, SurfaceAreaElement):\r
829 _Db = "Tools/Conf/FrameworkDatabase.db"\r
830 _Target = "Tools/Conf/Target.txt"\r
831 _PlatformBuildPath = "Tools/Conf/platform_build_path.txt"\r
832 _ModuleBuildPath = "Tools/Conf/module_build_path.txt"\r
833 \r
834 def __init__(self, path, fpdList=None, msaList=None):\r
835 FrameworkElement.Workspace.__init__(self)\r
836 SurfaceAreaElement.__init__(self, self, None, None, False, False)\r
837 self.Path = os.path.normpath(path)\r
838 self.Dir = os.path.dirname(self.Path)\r
839 self._Elements["PlatformList"] = fpdList\r
840 self._Elements["ModuleList"] = msaList\r
841 self.Parse()\r
842 self.Postprocess()\r
843\r
844 def _FdbHeader(self, xpath):\r
2082f936 845 dom = XmlNode(self._Root, xpath)\r
28972318 846 if dom == '': return\r
2082f936 847 self.Name = XmlElementData(XmlNode(dom, "/FdbHeader/DatabaseName"))\r
848 self.GuidValue = XmlElementData(XmlNode(dom, "/FdbHeader/GuidValue")).upper()\r
849 self.Version = XmlElementData(XmlNode(dom, "/FdbHeader/Version"))\r
28972318 850\r
851 def _PackageList(self, xpath):\r
2082f936 852 dom = XmlNode(self._Root, xpath)\r
28972318 853 if dom == '': return\r
854 \r
855 fileList = XmlList(dom, "/PackageList/Filename")\r
856 packages = []\r
857 for f in fileList:\r
858 packages.append(os.path.normpath(XmlElementData(f)))\r
859 self._Elements["PackageList"] = packages\r
860 \r
861 def _PlatformList(self, xpath):\r
862 if len(self._Elements["PlatformList"]) > 0:\r
863 return\r
864 \r
2082f936 865 dom = XmlNode(self._Root, xpath)\r
28972318 866 if dom == '': return\r
867 \r
868 fileList = XmlList(dom, "/PlatformList/Filename")\r
869 platforms = []\r
870 for f in fileList:\r
871 platforms.append(os.path.normpath(XmlElementData(f)))\r
872 self._Elements["PlatformList"] = platforms\r
873\r
874 def _FarList(self, xpath):\r
2082f936 875 dom = XmlNode(self._Root, xpath)\r
28972318 876 if dom == '': return\r
877 \r
878 fileList = XmlList(dom, "/FarList/Filename")\r
879 fars = []\r
880 for f in fileList:\r
881 fars.append(os.path.normpath(XmlElementData(f)))\r
882 self._Elements["FarList"] = fars\r
883\r
884 def ParseWorkspaceDatabase(self):\r
885 # parse frameworkdatabase.db\r
886 self._Root = xml.dom.minidom.parse(self.SubPath(self._Db))\r
887 assert self._Root.documentElement.tagName == "FrameworkDatabase"\r
888\r
889 self._FdbHeader("/FrameworkDatabase/FdbHeader")\r
890 self._PackageList("/FrameworkDatabase/PackageList")\r
891 self._PlatformList("/FrameworkDatabase/PlatformList")\r
892 self._FarList("/FrameworkDatabase/FarList")\r
893\r
894 def ParseConfig(self):\r
895 # parse target.txt\r
896 self.ParseTargetConfig()\r
897 # parse tools_def.txt\r
898 self.ParseToolConfig()\r
899 # parse platform/module_build_path.txt\r
900 \r
901 # active toolchain\r
902 # print self.TargetConfig\r
903 self.ActiveToolchain = self.TargetConfig["TOOL_CHAIN_TAG"]\r
904 if self.ActiveToolchain not in self.ToolConfig.Toolchains:\r
905 raise "Not supported tool chain tag %s" % self.ActiveToolchain\r
906\r
907 # active toolchain family\r
908 self.ActiveFamilies = []\r
909 for key in self.ToolConfig:\r
910 if self.ActiveToolchain in key and "FAMILY" in key:\r
911 family = self.ToolConfig[key]\r
912 if family not in self.ActiveFamilies:\r
913 self.ActiveFamilies.append(family)\r
914\r
915\r
916 def ParsePackage(self, packagePaths=None):\r
917 if packagePaths == None:\r
918 return\r
919 \r
920 for packagePath in packagePaths:\r
921 self.Packages.append(PackageSurfaceArea(self, packagePath))\r
922 \r
923 def ParsePlatform(self, platformPaths=None):\r
924 # Only one active platform is allowed\r
925 activePlatformPath = ""\r
926 if self.TargetConfig["ACTIVE_PLATFORM"] == "":\r
927 if platformPaths != None and len(platformPaths) == 1:\r
928 activePlatformPath = platformPaths[0]\r
929 else:\r
930 raise Exception("No active platform specified or implied!")\r
931 else:\r
932 activePlatformPath = os.path.normpath(self.TargetConfig["ACTIVE_PLATFORM"])\r
933\r
934 self.ActivePlatform = PlatformSurfaceArea(self, activePlatformPath)\r
935 self.Platforms.append(self.ActivePlatform)\r
936 \r
937 def ParseTargetConfig(self):\r
938 self.TargetConfig = BuildConfig.TargetConfig(self.SubPath(self._Target))\r
939 # print self.TargetConfig\r
940\r
941 def ParseToolConfig(self):\r
942 self.ToolConfig = BuildConfig.ToolConfig(self.SubPath(self.TargetConfig["TOOL_CHAIN_CONF"]))\r
943\r
944 def GetModule(self, guid, version, packageGuid, packageVersion):\r
945 moduleGuidIndex = self.ModuleXref["GUID"]\r
946 if guid not in moduleGuidIndex:\r
947 print "! No module has GUID=" + guid\r
948 return ""\r
949\r
950 moduleVersionList = moduleGuidIndex[guid]\r
951 # print moduleVersionList\r
952 moduleList = []\r
953 module = ""\r
954 if version != "":\r
955 if version in moduleVersionList:\r
956 moduleList = moduleVersionList[version]\r
957 else:\r
958 return ""\r
959 else:\r
960 ## no version given, return the first one\r
961 version = "0.0"\r
962 for ver in moduleVersionList:\r
963 if ver > version: version = ver\r
964 moduleList = moduleVersionList[version]\r
965\r
966 if packageGuid == "":\r
967 ## if no package GUID given, just return the latest one\r
968 version = "0.0"\r
969 for m in moduleList:\r
970 if m.Package.Version > version:\r
971 version = m.Package.Version\r
972 module = m\r
973 else:\r
974 version = "0.0"\r
975 for m in moduleList:\r
976 if m.Package.GuidValue != packageGuid: continue\r
977 if packageVersion == "":\r
978 ## if no version given, just return the latest\r
979 if m.Package.Version > version:\r
980 version = m.Package.Version\r
981 module = m\r
982 elif packageVersion == m.Package.Version:\r
983 module = m\r
984 break;\r
985\r
986 return module\r
987\r
988 def GetModuleByPath(self, path):\r
989 ownerPackage = ""\r
990 ownerPackageFullPath = ""\r
991 for package in self.Packages:\r
992 ownerPackageFullPath = self.SubPath(package.Path)\r
993 if path.startswith(packageFullPath): break\r
994\r
995 if ownerPackage == "":\r
996 return ""\r
997 \r
998 for module in ownerPackage.Modules:\r
999 moduleFullPath = os.path.join(ownerPackageFullPath, module.Path)\r
1000 if moduleFullPath == path:\r
1001 return module\r
1002 \r
1003 return ""\r
1004 \r
1005 def GetPackage(self, guid, version):\r
1006 packageGuidIndex = self.PackageXref["GUID"]\r
1007 if guid not in packageGuidIndex:\r
1008 # raise Exception("No package has GUID=" + guid)\r
1009 return ""\r
1010 \r
1011 packageList = packageGuidIndex[guid]\r
1012 package = ""\r
1013 if version != "":\r
1014 if version in packageList:\r
1015 package = packageList[version]\r
1016 else:\r
1017 ## no version given, return the latest one\r
1018 version = "0.0"\r
1019 for ver in packageList:\r
1020 if ver > version: version = ver\r
1021 package = packageList[version]\r
1022\r
1023 return package\r
1024\r
1025 def GetPlatform(self, guid, version):\r
1026 pass\r
1027 \r
1028 def GetPlatformByPath(self, path):\r
1029 for platform in self.Platforms:\r
1030 platformFullPath = self.SubPath(platform.Path)\r
1031 if platformFullPath == path:\r
1032 return platform\r
1033 return ""\r
1034\r
d59f2c72 1035 def GetLibraryInterface(self, name, package):\r
28972318 1036 if name not in self.LibraryInterfaceXref["NAME"]:\r
1037 return ""\r
d59f2c72 1038 liList = self.LibraryInterfaceXref["NAME"][name]\r
1039 for li in liList:\r
1040 if li.Package == package:\r
1041 return li\r
1042 return ""\r
28972318 1043 \r
1044 def SubPath(self, *relativePathList):\r
1045 return os.path.normpath(os.path.join(self.Path, *relativePathList))\r
1046 \r
1047 def SetupCrossRef(self):\r
1048 ##\r
1049 ## setup platform cross reference as nest-dict\r
1050 ## guid -> {version -> platform}\r
1051 ##\r
1052 ## platformList = self.Platforms\r
1053 ## for p in platformList:\r
1054 ## guid = p.GuidValue\r
1055 ## version = p.Version\r
1056 ## if guid not in self.PlatformIndex:\r
1057 ## self.PlatformIndex[guid] = {}\r
1058 ## if version in self.PlatformIndex[guid]:\r
1059 ## raise Exception("Duplicate platform")\r
1060 ## self.PlatformIndex[guid][version] = p\r
1061\r
1062 ##\r
1063 ## setup package cross reference as nest-dict\r
1064 ## guid -> {version -> package}\r
1065 ## name -> [package list]\r
1066 ## path -> package\r
1067 ##\r
1068 packageList = self.Packages\r
1069 for p in packageList:\r
1070 guid = p.GuidValue\r
1071 version = p.Version\r
1072 packageGuidIndex = self.PackageXref["GUID"]\r
1073 if guid not in packageGuidIndex:\r
1074 packageGuidIndex[guid] = {}\r
1075 if version in packageGuidIndex[guid]:\r
1076 raise Exception("Duplicate package: %s-%s [%s]" % p.Name, version, guid)\r
1077 packageGuidIndex[guid][version] = p\r
1078 \r
1079 packageNameIndex = self.PackageXref["NAME"]\r
1080 name = p.Name\r
1081 if name not in packageNameIndex:\r
1082 packageNameIndex[name] = []\r
1083 packageNameIndex[name].append(p)\r
1084 \r
1085 packagePathIndex = self.PackageXref["PATH"]\r
1086 path = p.Path\r
1087 if path in packagePathIndex:\r
1088 raise Exception("Duplicate package: %s %s" % p.Name, p.Path)\r
1089 packagePathIndex[path] = p.Path\r
1090\r
1091 ##\r
1092 ## setup library class cross reference as\r
1093 ## library class name -> library class object\r
1094 ##\r
1095 for lcname in p.LibraryInterfaces:\r
d59f2c72 1096 if lcname not in self.LibraryInterfaceXref["NAME"]:\r
1097 # raise Exception("Duplicate library class: %s in package %s" % (lcname, name))\r
1098 self.LibraryInterfaceXref["NAME"][lcname] = []\r
28972318 1099 lcInterface = p.LibraryInterfaces[lcname]\r
d59f2c72 1100 self.LibraryInterfaceXref["NAME"][lcname].append(lcInterface)\r
28972318 1101 \r
d59f2c72 1102 lcHeader = p.SubPath(lcInterface.Path)\r
1103 if lcHeader not in self.LibraryInterfaceXref["PATH"]:\r
1104 # raise Exception("Duplicate library class interface: %s in package %s" % (lcInterface, name))\r
1105 self.LibraryInterfaceXref["PATH"][lcHeader] = []\r
1106 self.LibraryInterfaceXref["PATH"][lcHeader].append(lcInterface)\r
28972318 1107\r
1108 ##\r
1109 ## setup package cross reference as nest-dict\r
1110 ## guid -> {version -> [module list]}\r
1111 ## name -> [module list]\r
1112 ## path -> module\r
1113 for p in packageList:\r
1114 p.ParseMsaFile()\r
1115 \r
1116 moduleList = p.Modules\r
1117 for m in moduleList:\r
1118 name = m.Name\r
1119 path = m.Path\r
1120 guid = m.GuidValue\r
1121 version = m.Version\r
1122 moduleGuidIndex = self.ModuleXref["GUID"]\r
1123 if guid not in moduleGuidIndex:\r
1124 moduleGuidIndex[guid] = {}\r
1125 else:\r
d59f2c72 1126 print "! Duplicate module GUID found:", guid, p.SubPath(path)\r
1127 dm = moduleGuidIndex[guid].values()[0][0]\r
1128 print " ", dm.GuidValue,\\r
1129 dm.Package.SubPath(dm.Path)\r
28972318 1130\r
1131 if version not in moduleGuidIndex[guid]:\r
1132 moduleGuidIndex[guid][version] = []\r
1133 if m in moduleGuidIndex[guid][version]:\r
1134 raise Exception("Duplicate modules in the same package: %s-%s [%s]" % (name, version, guid))\r
1135 moduleGuidIndex[guid][version].append(m)\r
1136 \r
1137 modulePathIndex = self.ModuleXref["PATH"]\r
1138 path = p.SubPath(m.Path)\r
1139 if path in modulePathIndex:\r
1140 raise Exception("Duplicate modules in the same package: %s %s" % (name, path))\r
1141 modulePathIndex[path] = m\r
1142 \r
1143 moduleNameIndex = self.ModuleXref["NAME"]\r
1144 if name not in moduleNameIndex:\r
1145 moduleNameIndex[name] = []\r
1146 moduleNameIndex[name].append(m)\r
1147\r
1148 def GetToolDef(self, toolchain, target, arch, toolcode, attr):\r
1149 return self.ToolConfig[(toolchain, target, arch, toolcode, attr)]\r
1150 \r
1151 def Parse(self):\r
1152 self.ParseConfig()\r
1153 self.ParseWorkspaceDatabase()\r
1154\r
1155 def SetupBuild(self):\r
1156 # active archs\r
1157 self.ActiveArchs = self.TargetConfig["TARGET_ARCH"].split()\r
1158 if self.ActiveArchs == []:\r
1159 self.ActiveArchs = self.ActivePlatform.Archs\r
1160\r
1161 # active targets\r
1162 self.ActiveTargets = self.TargetConfig["TARGET"].split()\r
1163 if self.ActiveTargets == []:\r
1164 self.ActiveTargets = self.ActivePlatform.Targets\r
1165\r
1166\r
1167 # active modules\r
1168 for msa in self._Elements["ModuleList"]:\r
1169 module = self.GetModuleByPath(msa)\r
1170 if module == "":\r
1171 raise Exception(msa + " is not in any package!")\r
1172 self.ActiveModules.append(module)\r
1173 self.IndividualModuleBuild = True\r
1174 if self.TargetConfig["MULTIPLE_THREAD"].upper() == "ENABLE":\r
1175 self.MultiThreadBuild = True\r
1176 if "MAX_CONCURRENT_THREAD_NUMBER" in self.TargetConfig:\r
1177 self.ThreadCount = self.TargetConfig["MAX_CONCURRENT_THREAD_NUMBER"]\r
1178 else:\r
1179 self.ThreadCount = "1"\r
1180\r
1181 def Postprocess(self):\r
1182 self.ParsePackage(self._Elements["PackageList"])\r
1183 self.SetupCrossRef()\r
1184 self.ParsePlatform(self._Elements["PlatformList"])\r
1185 self.SetupBuild()\r
1186\r
1187## def SetupEnvironment(self):\r
1188## config = BuildConfig.Config(self.SubPath(self._PlatformBuildPath))\r
1189## for name in config:\r
1190## self.Environment[name] = config[name]\r
1191##\r
1192## config = BuildConfig.Config(self.SubPath(self._ModuleBuildPath))\r
1193## for name in config:\r
1194## self.Environment[name] = config[name]\r
1195##\r
1196## multiThread = self.TargetConfig["MULTIPLE_THREAD"].upper()\r
1197## threadNumber = self.TargetConfig["MAX_CONCURRENT_THREAD_NUMBER"]\r
1198## if multiThread == "" or multiThread == "FALSE":\r
1199## self.Environment["MULTIPLE_THREAD"] = False\r
1200## self.Environment["MAX_CONCURRENT_THREAD_NUMBER"] = 1\r
1201## else:\r
1202## self.Environment["MULTIPLE_THREAD"] = True\r
1203## if threadNumber != "":\r
1204## self.Environment["MAX_CONCURRENT_THREAD_NUMBER"] = threadNumber\r
1205## else:\r
1206## self.Environment["MAX_CONCURRENT_THREAD_NUMBER"] = 2\r
1207\r
1208class PackageSurfaceArea(FrameworkElement.Package, SurfaceAreaElement):\r
1209 def __init__(self, workspace, path):\r
1210 FrameworkElement.Package.__init__(self)\r
1211 \r
1212 self.Path = os.path.normpath(path)\r
1213 self.Dir = os.path.dirname(self.Path)\r
1214 SurfaceAreaElement.__init__(self, workspace, workspace, None, True, True)\r
1215 \r
1216 def _SpdHeader(self, xpath):\r
2082f936 1217 dom = XmlNode(self._Root, xpath)\r
1218 self.Name = XmlElementData(XmlNode(dom, "/SpdHeader/PackageName"))\r
1219 self.GuidValue = XmlElementData(XmlNode(dom, "/SpdHeader/GuidValue")).upper()\r
1220 self.Version = XmlElementData(XmlNode(dom, "/SpdHeader/Version"))\r
28972318 1221\r
1222 def _PackageDefinitions(self, xpath):\r
2082f936 1223 dom = XmlNode(self._Root, xpath)\r
1224 self.ReadOnly = XmlElementData(XmlNode(dom, "/PackageDefinitions/ReadOnly"))\r
1225 self.Repackage = XmlElementData(XmlNode(dom, "/PackageDefinitions/RePackage"))\r
28972318 1226\r
1227 def _LibraryClassDeclarations(self, xpath):\r
2082f936 1228 dom = XmlNode(self._Root, xpath)\r
28972318 1229 lcdList = XmlList(dom, "/LibraryClassDeclarations/LibraryClass")\r
1230 lcds = []\r
1231 for lc in lcdList:\r
1232 lcds.append(LibraryDeclaration(self._Workspace, self, lc))\r
1233 self._Elements["LibraryClassDeclarations"] = lcds\r
1234 \r
1235 def _IndustryStdIncludes(self, xpath):\r
2082f936 1236 dom = XmlNode(self._Root, xpath)\r
28972318 1237 headerList = XmlList(dom, "/IndustryStdIncludes/IndustryStdHeader")\r
1238 headers = []\r
1239 for h in headerList:\r
1240 headers.append(IndustryStdHeader(self._Workspace, self, h))\r
1241 self._Elements["IndustryStdIncludes"] = headers\r
1242 \r
1243 def _MsaFiles(self, xpath):\r
2082f936 1244 dom = XmlNode(self._Root, xpath)\r
28972318 1245 msaFileList = XmlList(dom, "/MsaFiles/Filename")\r
1246 msaFiles = []\r
1247 for msa in msaFileList:\r
1248 filePath = os.path.normpath(XmlElementData(msa))\r
1249 msaFiles.append(filePath)\r
1250 self._Elements["MsaFiles"] = msaFiles\r
1251\r
1252 def _PackageHeaders(self, xpath):\r
2082f936 1253 dom = XmlNode(self._Root, xpath)\r
28972318 1254 headerList = XmlList(dom, "/PackageHeaders/IncludePkgHeader")\r
1255 headers = []\r
1256 for h in headerList:\r
1257 headers.append(PackageHeader(self._Workspace, self, h))\r
1258 self._Elements["PackageHeaders"] = headers\r
1259\r
1260 def _GuidDeclarations(self, xpath):\r
2082f936 1261 dom = XmlNode(self._Root, xpath)\r
28972318 1262 guidList = XmlList(dom, "/GuidDeclarations/Entry")\r
1263 guids = []\r
1264 for guid in guidList:\r
1265 guids.append(GuidDeclaration(self._Workspace, self, guid))\r
1266 self._Elements["GuidDeclarations"] = guids\r
1267 \r
1268 def _ProtocolDeclarations(self, xpath):\r
2082f936 1269 dom = XmlNode(self._Root, xpath)\r
28972318 1270 protocolList = XmlList(dom, "/ProtocolDeclarations/Entry")\r
1271 protocols = []\r
1272 for p in protocolList:\r
1273 protocols.append(ProtocolDeclaration(self._Workspace, self, p))\r
1274 self._Elements["ProtocolDeclarations"] = protocols\r
1275\r
1276 def _PpiDeclarations(self, xpath):\r
2082f936 1277 dom = XmlNode(self._Root, xpath)\r
28972318 1278 ppiList = XmlList(dom, "/PpiDeclarations/Entry")\r
1279 ppis = []\r
1280 for p in ppiList:\r
1281 ppis.append(PpiDeclaration(self._Workspace, self, p))\r
1282 self._Elements["PpiDeclarations"] = ppis\r
1283\r
1284 def _PcdDeclarations(self, xpath):\r
2082f936 1285 dom = XmlNode(self._Root, xpath)\r
28972318 1286 pcdList = XmlList(dom, "/PcdDeclarations/PcdEntry")\r
1287 pcds = []\r
1288 for p in pcdList:\r
1289 pcds.append(PcdDeclaration(self._Workspace, self, p))\r
1290 self._Elements["PcdDeclarations"] = pcds\r
1291\r
1292 def SubPath(self, *relativePathList):\r
1293 return os.path.normpath(os.path.join(self.Dir, *relativePathList))\r
1294\r
1295 def Parse(self):\r
1296 self._Root = xml.dom.minidom.parse(self._Workspace.SubPath(self.Path))\r
1297 assert self._Root.documentElement.tagName == "PackageSurfaceArea"\r
1298\r
1299 # print "Parsing...",self.Path\r
1300 self._SpdHeader("/PackageSurfaceArea/SpdHeader")\r
1301 self._PackageDefinitions("/PackageSurfaceArea/PackageDefinitions")\r
1302 self._LibraryClassDeclarations("/PackageSurfaceArea/LibraryClassDeclarations")\r
1303 self._IndustryStdIncludes("/PackageSurfaceArea/IndustryStdIncludes")\r
1304 self._MsaFiles("/PackageSurfaceArea/MsaFiles")\r
1305 self._PackageHeaders("/PackageSurfaceArea/PackageHeaders")\r
1306 self._GuidDeclarations("/PackageSurfaceArea/GuidDeclarations")\r
1307 self._ProtocolDeclarations("/PackageSurfaceArea/ProtocolDeclarations")\r
1308 self._PpiDeclarations("/PackageSurfaceArea/PpiDeclarations")\r
1309 self._PcdDeclarations("/PackageSurfaceArea/PcdDeclarations")\r
1310 \r
1311 def Postprocess(self):\r
1312 # setup guid, protocol, ppi\r
1313 for guid in self._Elements["GuidDeclarations"]:\r
1314 if guid.CName in self.Guids:\r
1315 print "! Duplicate GUID CName (%s) in package %s" % (guid.CName, self.Path)\r
1316 self.Guids[guid.CName] = guid\r
1317 \r
1318 for protocol in self._Elements["ProtocolDeclarations"]:\r
1319 if protocol.CName in self.Protocols:\r
1320 print "! Duplicate Protocol CName (%s) in package %s" % (protocol.CName, self.Path)\r
1321 self.Protocols[protocol.CName] = protocol\r
1322\r
1323 for ppi in self._Elements["PpiDeclarations"]:\r
1324 if ppi.CName in self.Ppis:\r
1325 print "! Duplicate PPI CName (%s) in package (%s)" % (ppi.CName, self.Path)\r
1326 self.Ppis[ppi.CName] = ppi\r
1327 \r
1328 # package header\r
1329 for inc in self._Elements["PackageHeaders"]:\r
1330 if inc.ModuleType not in self.PackageIncludes:\r
1331 self.PackageIncludes[inc.ModuleType] = []\r
1332 self.PackageIncludes[inc.ModuleType].append(inc.Path)\r
1333 \r
1334 # library class\r
1335 for lcd in self._Elements["LibraryClassDeclarations"]:\r
1336 if lcd.Name in self.LibraryInterfaces:\r
1337 raise "Duplicate library class: " + lcd.Name\r
1338 self.LibraryInterfaces[lcd.Name] = lcd\r
1339 \r
1340 # parse mas files\r
1341 # self.ParseMsaFile()\r
1342 # resolve RecommendedInstance\r
1343\r
1344 def ParseMsaFile(self):\r
1345 for msaFilePath in self._Elements["MsaFiles"]:\r
1346 self.Modules.append(ModuleSurfaceArea(self._Workspace, self, msaFilePath))\r
1347\r
1348class PlatformSurfaceArea(FrameworkElement.Platform, SurfaceAreaElement):\r
1349 def __init__(self, workspace, path):\r
1350 FrameworkElement.Platform.__init__(self)\r
1351\r
1352 self.Path = os.path.normpath(path)\r
1353 self.Dir = os.path.dirname(self.Path)\r
1354 SurfaceAreaElement.__init__(self, workspace)\r
1355 \r
1356 def _PlatformHeader(self, xpath):\r
2082f936 1357 dom = XmlNode(self._Root, xpath)\r
28972318 1358 if dom == '': return\r
2082f936 1359 self.Name = XmlElementData(XmlNode(dom, "/PlatformHeader/PlatformName"))\r
1360 self.GuidValue = XmlElementData(XmlNode(dom, "/PlatformHeader/GuidValue")).upper()\r
1361 self.Version = XmlElementData(XmlNode(dom, "/PlatformHeader/Version"))\r
28972318 1362\r
1363 def _PlatformDefinitions(self, xpath):\r
2082f936 1364 dom = XmlNode(self._Root, xpath)\r
28972318 1365 if dom == '': return\r
2082f936 1366 self.Archs = XmlElementData(XmlNode(dom, "/PlatformDefinitions/SupportedArchitectures")).split()\r
28972318 1367 if self.Archs == []:\r
1368 raise Exception("No ARCH specified in platform " + self.Path)\r
2082f936 1369 self.Targets = XmlElementData(XmlNode(dom, "/PlatformDefinitions/BuildTargets")).split()\r
1370 self.OutputPath = os.path.normpath(XmlElementData(XmlNode(dom, "/PlatformDefinitions/OutputDirectory")))\r
28972318 1371\r
1372 def _Flash(self, xpath):\r
2082f936 1373 dom = XmlNode(self._Root, xpath)\r
28972318 1374 if dom == '': return\r
1375\r
1376 def _FrameworkModules(self, xpath):\r
2082f936 1377 dom = XmlNode(self._Root, xpath)\r
28972318 1378 if dom == '': return\r
1379 moduleList = XmlList(dom, "/FrameworkModules/ModuleSA")\r
1380 modules = []\r
1381 for m in moduleList:\r
1382 modules.append(PlatformModule(self._Workspace, self, m))\r
1383 self._Elements["FrameworkModules"] = modules\r
1384\r
1385 def _DynamicPcdBuildDefinitions(self, xpath):\r
2082f936 1386 dom = XmlNode(self._Root, xpath)\r
28972318 1387 if dom == '': return\r
1388\r
1389 def _BuildOptions(self, xpath):\r
2082f936 1390 dom = XmlNode(self._Root, xpath)\r
28972318 1391 if dom == '': return\r
2082f936 1392 self.BuildOptions = self.GetBuildOptionList(XmlNode(dom, "/BuildOptions/Options"))\r
28972318 1393 # print self.BuildOptions\r
1394\r
1395 def _UserExtensions(self, xpath):\r
1396 domList = XmlList(self._Root, xpath)\r
1397 if domList == []: return\r
1398 for extension in domList:\r
1399 userId = XmlAttribute(extension, "UserID")\r
1400 identifier = XmlAttribute(extension, "Identifier")\r
1401 \r
1402 if userId == '' or identifier == '':\r
1403 raise Exception("No UserId or Identifier specified")\r
1404 if userId != "TianoCore": continue\r
1405 if identifier not in self.UserExtensions:\r
1406 self.UserExtensions[identifier] = []\r
1407 \r
1408 contentList = self.UserExtensions[identifier]\r
1409 for node in extension.childNodes:\r
1410 # print node.nodeType\r
1411 contentList.append(node.cloneNode(True))\r
1412\r
1413 def Parse(self):\r
1414 self._Root = xml.dom.minidom.parse(self._Workspace.SubPath(self.Path))\r
1415 assert self._Root.documentElement.tagName == "PlatformSurfaceArea"\r
1416\r
1417 self._PlatformHeader("/PlatformSurfaceArea/PlatformHeader")\r
1418 self._PlatformDefinitions("/PlatformSurfaceArea/PlatformDefinitions")\r
1419 self._Flash("/PlatformSurfaceArea/Flash")\r
1420 self._FrameworkModules("/PlatformSurfaceArea/FrameworkModules")\r
1421 self._DynamicPcdBuildDefinitions("/PlatformSurfaceArea/DynamicPcdBuildDefinitions")\r
1422 self._BuildOptions("/PlatformSurfaceArea/BuildOptions")\r
1423 self._UserExtensions("/PlatformSurfaceArea/UserExtensions")\r
1424\r
1425 def Postprocess(self):\r
1426 # summarize all library modules for build\r
1427 for module in self._Elements["FrameworkModules"]:\r
1428 for arch in module.Archs:\r
1429 if arch not in self.Modules:\r
1430 self.Modules[arch] = []\r
1431 self.Modules[arch].append(module)\r
1432\r
1433 if arch not in self.Libraries:\r
1434 self.Libraries[arch] = []\r
1435 for li in module.Libraries:\r
1436 if li in self.Libraries[arch]: continue\r
1437 self.Libraries[arch].append(li)\r
1438\r
1439 # FV\r
1440 for fvName in module.FvBindings:\r
1441 if fvName not in self.Fvs:\r
1442 self.Fvs[fvName] = []\r
1443 self.Fvs[fvName].append(module)\r
1444 # build options\r
1445 # user extension\r
1446 \r
1447## def SetupEnvironment(self):\r
1448## self.Environment["PLATFORM"] = self.Name\r
1449## self.Environment["PLATFORM_GUID"] = self.GuidValue\r
1450## self.Environment["PLATFORM_VERSION"] = self.Version\r
1451## self.Environment["PLATFORM_RELATIVE_DIR"] = self.Path\r
1452## self.Environment["PLATFORM_OUTPUT_DIR"] = self.OutputPath\r
1453\r
1454def PrintWorkspace(ws):\r
1455 print "\nPlatforms:\n"\r
1456 for guid in ws.PlatformXref["GUID"]:\r
1457 for ver in ws.PlatformXref["GUID"][guid]:\r
1458 platform = ws.PlatformXref["GUID"][guid][ver]\r
1459 print " %s %s-%s" % (guid, platform.Name, ver)\r
1460 for pm in platform.Modules:\r
1461 print " %-40s %-10s <%s-%s>" % (pm.Module.Name+"-"+pm.Module.Version,\r
1462 ListString(pm.Archs), pm.Module.Package.Name,\r
1463 pm.Module.Package.Version)\r
1464 for li in pm.Libraries:\r
1465 print " %-47s <%s-%s>" % (li.Module.Name+"-"+li.Module.Version,\r
1466 li.Module.Package.Name, li.Module.Package.Version)\r
1467 print ""\r
1468 \r
1469 print "\nPackages:\n"\r
1470 for guid in ws.PackageXref["GUID"]:\r
1471 for ver in ws.PackageXref["GUID"][guid]:\r
1472 print " %s %s-%s" % (guid, ws.PackageXref["GUID"][guid][ver].Name, ver)\r
1473\r
1474 print "\nModules:\n"\r
1475 for guid in ws.ModuleXref["GUID"]:\r
1476 for ver in ws.ModuleXref["GUID"][guid]:\r
1477 for module in ws.ModuleXref["GUID"][guid][ver]:\r
1478 print " %s %-40s [%s-%s]" % (guid, module.Name+"-"+ver, module.Package.Name, module.Package.Version)\r
1479 print " Depending on packages:"\r
1480 for arch in module.IncludePaths:\r
1481 print " ", arch, ":"\r
1482 for path in module.IncludePaths[arch]:\r
1483 print " ", path\r
1484 print "\n"\r
1485\r
1486 for arch in module.IncludeFiles:\r
1487 print " ", arch, ":"\r
1488 for path in module.IncludeFiles[arch]:\r
1489 print " ", path\r
1490 print "\n"\r
1491 \r
1492 print " Source files:"\r
1493 for arch in module.SourceFiles:\r
1494 print " ", arch, ":"\r
1495 for type in module.SourceFiles[arch]:\r
1496 for src in module.SourceFiles[arch][type]:\r
1497 print " %-40s (%s)" % (src.Path, src.Type)\r
1498 print "\n"\r
1499 print "\nLibrary Classes:"\r
1500 for name in ws.LibraryInterfaceXref["NAME"]:\r
d59f2c72 1501 lcList = ws.LibraryInterfaceXref["NAME"][name]\r
1502 for lc in lcList:\r
1503 pkgPath = os.path.dirname(lc.Package.Path)\r
1504 print "\n [%s] <%s>" % (lc.Name, pkgPath + os.path.sep + lc.Path)\r
1505\r
1506 print " Produced By:"\r
1507 for li in lc.Instances:\r
1508 print " %-40s <%s>" % (li.Name+"-"+li.Version, li.Package.SubPath(li.Path))\r
1509\r
1510 print " Consumed By:"\r
1511 for li in lc.Consumers:\r
1512 print " %-40s <%s>" % (li.Name+"-"+li.Version, li.Package.SubPath(li.Path))\r
28972318 1513\r
1514 print "\nActive Platform:"\r
1515 for arch in ws.ActivePlatform.Libraries:\r
1516 print " Library Instances (%s) (%d libraries)" % (arch , len(ws.ActivePlatform.Libraries[arch]))\r
1517 for li in ws.ActivePlatform.Libraries[arch]:\r
1518 print " %s-%s (%s-%s)" % (li.Module.Name, li.Module.Version,\r
1519 li.Module.Package.Name, li.Module.Package.Version)\r
1520\r
1521 for arch in ws.ActivePlatform.Modules:\r
1522 print " Driver Modules (%s) (%d modules)" % (arch, len(ws.ActivePlatform.Modules[arch]))\r
1523 for m in ws.ActivePlatform.Modules[arch]:\r
1524 print " %s-%s (%s-%s)" % (m.Module.Name, m.Module.Version,\r
1525 m.Module.Package.Name, m.Module.Package.Version)\r
1526\r
1527 for fv in ws.ActivePlatform.Fvs:\r
1528 print\r
1529 print " Firmware Volume (%s) (%d modules)" % (fv, len(ws.ActivePlatform.Fvs[fv]))\r
1530 for m in ws.ActivePlatform.Fvs[fv]:\r
1531 print " %s-%s (%s-%s)" % (m.Module.Name, m.Module.Version,\r
1532 m.Module.Package.Name, m.Module.Package.Version)\r
1533\r
1534# for test\r
1535if __name__ == "__main__":\r
1536 # os.environ["WORKSPACE"]\r
1537 workspacePath = os.getenv("WORKSPACE", os.getcwd())\r
2082f936 1538 workspacePath = "C:\\home\\src\\R9\\pbuild"\r
28972318 1539 saFile = ""\r
1540 if len(sys.argv) <= 1:\r
1541 saFile = os.path.join(workspacePath, "Tools/Conf/FrameworkDatabase.db")\r
1542 else:\r
1543 saFile = sys.argv[1]\r
1544\r
1545 print "Parsing ... %s\n" % saFile\r
1546\r
1547 startTime = time.clock()\r
1548 sa = Workspace(workspacePath, [], [])\r
28972318 1549 # sa = PackageSurfaceArea(saFile)\r
1550 # sa = PlatformSurfaceArea(saFile)\r
1551 # sa = ModuleSurfaceArea(saFile)\r
1552 # print sa\r
1553 \r
1554 PrintWorkspace(sa)\r
1555 print "\n[Finished in %fs]" % (time.clock() - startTime)\r
1556\r