2 # Open an FPD file and load all its contents to a PlatformClass object.
4 # Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 from CommonDataClass
.PlatformClass
import *
19 from CommonDataClass
.FdfClass
import *
20 from Common
.XmlRoutines
import *
21 from Common
.MigrationUtilities
import *
22 from EdkIIWorkspaceGuidsInfo
import gEdkIIWorkspaceGuidsInfo
24 ## Load Platform Header
26 # Read an input Platform XML DOM object and return Platform Header class object
27 # contained in the DOM object.
29 # @param XmlFpd An XML DOM object read from FPD file
30 # @param FpdFileName The file path of FPD File
32 # @retvel PlatformHeader A new Platform Header object loaded from XmlFpd
34 def LoadPlatformHeader(XmlFpd
, FpdFileName
):
35 PlatformHeader
= PlatformHeaderClass()
37 XmlTag
= "PlatformSurfaceArea/PlatformHeader"
38 FpdHeader
= XmlNode(XmlFpd
, XmlTag
)
40 SetIdentification(PlatformHeader
, FpdHeader
, "PlatformName", FpdFileName
)
41 SetCommonHeader(PlatformHeader
, FpdHeader
)
43 XmlTag
= "PlatformSurfaceArea/PlatformHeader/Specification"
44 List
= XmlElement(XmlFpd
, XmlTag
).split()
45 SpecificationName
= List
[0]
46 SpecificationValue
= List
[1]
47 PlatformHeader
.Specification
= {SpecificationName
:SpecificationValue
}
49 XmlTag
= "PlatformSurfaceArea/PlatformDefinitions/SupportedArchitectures"
50 PlatformHeader
.SupArchList
= XmlElement(XmlFpd
, XmlTag
).split()
52 XmlTag
= "PlatformSurfaceArea/PlatformDefinitions/BuildTargets"
53 PlatformHeader
.BuildTargets
= XmlElement(XmlFpd
, XmlTag
).split()
55 XmlTag
= "PlatformSurfaceArea/PlatformDefinitions/IntermediateDirectories"
56 PlatformHeader
.IntermediateDirectories
= XmlElement(XmlFpd
, XmlTag
)
58 XmlTag
= "PlatformSurfaceArea/PlatformDefinitions/OutputDirectory"
59 PlatformHeader
.OutputDirectory
= XmlElement(XmlFpd
, XmlTag
)
61 XmlTag
= "PlatformSurfaceArea/PlatformDefinitions/SkuInfo"
62 List
= map(LoadSkuId
, XmlList(XmlFpd
, XmlTag
))
64 PlatformHeader
.SkuIdName
= List
[0]
68 ## Load a Platform SkuId
70 # Read an input Platform XML DOM object and return a list of Platform SkuId
71 # contained in the DOM object.
73 # @param XmlPlatformSkuInfo An XML DOM object read from FPD file
75 # @retvel PlatformSkuInfo A SkuInfo loaded from XmlFpd
77 def LoadPlatformSkuInfo(XmlPlatformSkuInfo
):
78 XmlTag
= "SkuInfo/SkuId"
80 SkuId
= XmlElement(XmlPlatformSkuInfo
, XmlTag
)
83 XmlTag
= "SkuInfo/Value"
84 Value
= XmlElement(XmlPlatformSkuInfo
, XmlTag
)
88 ## Load a Platform SkuId
90 # Read an input Platform XML DOM object and return a list of Platform SkuId
91 # contained in the DOM object.
93 # @param XmlSkuInfo An XML DOM object read from FPD file
95 # @retvel List A list of SkuId and SkuValue loaded from XmlFpd
97 def LoadSkuId(XmlSkuInfo
):
98 XmlTag
= "SkuInfo/UiSkuName"
99 SkuValue
= XmlElement(XmlSkuInfo
, XmlTag
)
101 XmlTag
= "SkuInfo/UiSkuName"
102 List
= map(LoadSkuID
, XmlList(XmlSkuInfo
, XmlTag
))
105 #SkuID = XmlAttribute(XmlSkuInfo, XmlTag)
108 List
.append(SkuValue
)
111 def LoadSkuID(XmlUiSkuName
):
113 SkuID
= XmlAttribute(XmlUiSkuName
, XmlTag
)
116 ## Load a list of Platform SkuIds
118 # Read an input Platform XML DOM object and return a list of Platform SkuId
119 # contained in the DOM object.
121 # @param XmlFpd An XML DOM object read from FPD file
123 # @retvel PlatformSkuIds A platform SkuIds object loaded from XmlFpd
125 def LoadPlatformSkuInfos(XmlFpd
):
126 PlatformSkuIds
= SkuInfoListClass()
130 XmlTag
= "PlatformSurfaceArea/PlatformDefinitions/SkuInfo"
131 List
= map(LoadSkuId
, XmlList(XmlFpd
, XmlTag
))
134 XmlTag
= "PlatformSurfaceArea/PlatformDefinitions/SkuInfo/UiSkuName"
135 Value
= XmlElement(XmlFpd
, XmlTag
)
137 XmlTag
= "PlatformSurfaceArea/DynamicPcdBuildDefinitions/PcdBuildData/SkuInfo"
139 List
= map(LoadPlatformSkuInfo
, XmlList(XmlFpd
, XmlTag
))
145 SkuInfoList
.append(SkuInfo
)
147 PlatformSkuIds
.SkuInfoList
= SkuInfoList
149 return PlatformSkuIds
151 ## Load Platform Module Build Option
153 # Read an input Platform XML DOM object and return Platform Module Build Option class object
154 # contained in the DOM object.
156 # @param XmlModuleBuildOption An XML DOM object read from FPD file
158 # @retvel PlatformBuildOption A Platform Build Option object loaded from XmlFpd
160 def LoadModuleBuildOption(XmlModuleBuildOption
):
161 PlatformBuildOption
= PlatformBuildOptionClass()
162 PlatformBuildOption
.UserDefinedAntTasks
= {}
164 XmlTag
= "BuildOptions/Options/Option"
165 PlatformBuildOption
.Options
= map(LoadBuildOption
, XmlList(XmlModuleBuildOption
, XmlTag
))
167 PlatformBuildOption
.UserExtensions
= {}
168 PlatformBuildOption
.FfsKeyList
= {}
169 return PlatformBuildOption
171 ## Load Platform Module Extern
173 # Read an input Platform XML DOM object and return Platform Module Extern class object
174 # contained in the DOM object.
176 # @param XmlModuleExtern An XML DOM object read from FPD file
178 # @retvel PlatformModuleExtern A Platform Module Extern object loaded from XmlFpd
180 def LoadModuleExtern(XmlModuleExtern
):
181 PlatformModuleExtern
= []
183 XmlTag
= "Externs/PcdIsDriver"
184 PcdIsDriver
= XmlElement(XmlModuleExtern
, XmlTag
)
185 PlatformModuleExtern
.append(PcdIsDriver
)
187 XmlTag
= "Externs/Specification"
188 Specification
= XmlElement(XmlModuleExtern
, XmlTag
)
189 PlatformModuleExtern
.append(Specification
)
191 XmlTag
= "Externs/Extern"
193 return PlatformModuleExtern
195 ## Load Platform ModuleSaBuildOptions
197 # Read an input Platform XML DOM object and return Platform ModuleSaBuildOptions class object
198 # contained in the DOM object.
200 # @param XmlModuleSaBuildOptions An XML DOM object read from FPD file
202 # @retvel PlatformBuildOptions A list of Platform ModuleSaBuildOption object loaded from XmlFpd
204 def LoadPlatformModuleSaBuildOption(XmlModuleSA
):
205 PlatformModuleSaBuildOption
= PlatformBuildOptionClasses()
207 XmlTag
= "ModuleSA/ModuleSaBuildOptions/FvBinding"
208 PlatformModuleSaBuildOption
.FvBinding
= XmlElement(XmlModuleSA
, XmlTag
)
210 XmlTag
= "ModuleSA/ModuleSaBuildOptions/FfsFormatKey"
211 PlatformModuleSaBuildOption
.FfsFormatKey
= XmlElement(XmlModuleSA
, XmlTag
)
213 XmlTag
= "ModuleSA/ModuleSaBuildOptions/FfsFileNameGuid"
214 PlatformModuleSaBuildOption
.FfsFileNameGuid
= XmlElement(XmlModuleSA
, XmlTag
)
216 XmlTag
= "ModuleSA/ModuleSaBuildOptions/Options/Option"
217 PlatformModuleSaBuildOption
.BuildOptionList
= map(LoadBuildOption
, XmlList(XmlModuleSA
, XmlTag
))
219 return PlatformModuleSaBuildOption
221 ## Load a list of Platform Library Classes
223 # Read an input Platform XML DOM object and return a list of Library Classes
224 # contained in the DOM object.
226 # @param XmlLibraryInstance An XML DOM object read from FPD file
228 # @retvel LibraryInstance A Library Instance loaded from XmlFpd
230 def LoadPlatformModuleLibraryInstance(XmlLibraryInstance
):
233 XmlTag
= "ModuleGuid"
234 ModuleGuid
= XmlAttribute(XmlLibraryInstance
, XmlTag
)
236 ModulePath
= gEdkIIWorkspaceGuidsInfo
.ResolveModuleFilePath(ModuleGuid
)
237 ModuleMSAFile
= ModulePath
.replace('.inf', '.msa')
238 WorkSpace
= os
.getenv('WORKSPACE')
239 ModuleMSAFileName
= os
.path
.join(WorkSpace
, ModuleMSAFile
)
240 XmlMsa
= XmlParseFile(ModuleMSAFileName
)
242 XmlTag
= "ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass/Keyword"
243 Name
= XmlElement(XmlMsa
, XmlTag
)
244 LibraryInstance
.append(Name
)
245 LibraryInstance
.append(ModulePath
)
247 #XmlTag = "PackageGuid"
248 #PackageGuid = XmlAttribute(XmlLibraryInstance, XmlTag)
249 #LibraryInstance.append(PackageGuid)
250 return LibraryInstance
252 ## Load a Library Class
254 # Read an input Platform XML DOM object and return a library class object
255 # contained in the DOM object.
257 # @param XmlLibraryClass An XML DOM object read from FPD file
259 # @retvel SupModuleList A Library Class Supported Module List object loaded from XmlFpd
261 def LoadLibraryClassSupModuleList(XmlLibraryClass
):
263 Usage
= XmlAttribute(XmlLibraryClass
, XmlTag
)
264 if Usage
== "ALWAYS_PRODUCED":
265 XmlTag
= "SupModuleList"
266 SupModuleList
= XmlAttribute(XmlLibraryClass
, XmlTag
).split()
269 ## Load Platform Library Class
271 # Read an input Platform XML DOM object and return Platform module class object
272 # contained in the DOM object.
274 # @param XmlLibraries An XML DOM object read from FPD file
276 # @retvel PlatformLibraryClass A Platform Library Class object loaded from XmlFpd
278 def LoadPlatformLibraryClass(XmlPlatformLibraryClass
):
279 PlatformLibraryInstance
= PlatformLibraryClass()
281 XmlTag
= "ModuleGuid"
282 LibraryInstanceModuleGuid
= XmlAttribute(XmlPlatformLibraryClass
, XmlTag
)
284 XmlTag
= "PackageGuid"
285 LibraryInstancePackageGuid
= XmlAttribute(XmlPlatformLibraryClass
, XmlTag
)
287 LibraryInstancePath
= gEdkIIWorkspaceGuidsInfo
.ResolveModuleFilePath(LibraryInstanceModuleGuid
)
289 if LibraryInstancePath
!= "": # if LibraryInstancePath == "" that's because the module guid cannot be resolved
290 PlatformLibraryInstance
.FilePath
= LibraryInstancePath
291 # replace *.inf to *.msa
292 LibraryInstanceMSAName
= LibraryInstancePath
.replace('.inf', '.msa')
293 WorkSpace
= os
.getenv('WORKSPACE')
294 LibraryInstanceMSAPath
= os
.path
.join(WorkSpace
, LibraryInstanceMSAName
)
296 PlatformLibraryInstance
.FilePath
= LibraryInstancePath
298 XmlMsa
= XmlParseFile(LibraryInstanceMSAPath
)
300 XmlTag
= "ModuleSurfaceArea/MsaHeader/ModuleName"
301 PlatformLibraryInstance
.Name
= XmlElement(XmlMsa
, XmlTag
)
303 XmlTag
= "ModuleSurfaceArea/MsaHeader/ModuleType"
304 PlatformLibraryInstance
.ModuleType
= XmlElement(XmlMsa
, XmlTag
)
306 if PlatformLibraryInstance
.ModuleType
!= "BASE":
307 XmlTag
= "ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass"
308 List
= map(LoadLibraryClassSupModuleList
, XmlList(XmlMsa
, XmlTag
))
310 PlatformLibraryInstance
.SupModuleList
= List
[0]
311 XmlTag
= "ModuleSurfaceArea/ModuleDefinitions/SupportedArchitectures"
312 PlatformLibraryInstance
.SupArchList
= XmlElement(XmlMsa
, XmlTag
).split()
314 PlatformLibraryInstance
.ModuleGuid
= LibraryInstanceModuleGuid
316 XmlTag
= "ModuleSurfaceArea/MsaHeader/Version"
317 PlatformLibraryInstance
.ModuleVersion
= XmlElement(XmlMsa
, XmlTag
)
319 PlatformLibraryInstance
.PackageGuid
= LibraryInstancePackageGuid
320 PlatformLibraryInstance
.PackageVersion
= ''
322 return PlatformLibraryInstance
324 ## Load Platform Library Classes
326 # Read an input Platform XML DOM object and return Platform module class object
327 # contained in the DOM object.
329 # @param XmlLibraries An XML DOM object read from FPD file
331 # @retvel PlatformLibraryClasses A list of Platform Library Class object loaded from XmlFpd
333 def LoadPlatformLibraryClasses(XmlFpd
):
334 PlatformLibraryInstances
= PlatformLibraryClasses()
335 PlatformLibraryInstances
.LibraryList
= []
338 XmlTag
= "PlatformSurfaceArea/FrameworkModules/ModuleSA/Libraries/Instance"
339 List
= map(LoadPlatformLibraryClass
, XmlList(XmlFpd
, XmlTag
))
344 PlatformLibraryInstances
.LibraryList
= List
346 return PlatformLibraryInstances
348 ## Load Platform module
350 # Read an input Platform XML DOM object and return Platform module class object
351 # contained in the DOM object.
353 # @param XmlModuleSA An XML DOM object read from FPD file
355 # @retvel PlatformModule A Platform module object loaded from XmlFpd
357 def LoadModuleSA(XmlModuleSA
):
358 PlatformModule
= PlatformModuleClass()
360 # three parts: Libraries instances, PcdBuildDefinition, ModuleSaBuildOptions
361 XmlTag
= "ModuleSA/Libraries/Instance"
363 PlatformModule
.LibraryClasses
= map(LoadPlatformModuleLibraryInstance
, XmlList(XmlModuleSA
, XmlTag
))
365 XmlTag
= "ModuleSA/PcdBuildDefinition/PcdData"
366 PlatformModule
.PcdBuildDefinitions
= map(LoadPlatformPcdData
, XmlList(XmlModuleSA
, XmlTag
))
368 XmlTag
= "ModuleSA/ModuleSaBuildOptions"
369 PlatformModule
.ModuleSaBuildOption
= LoadPlatformModuleSaBuildOption(XmlModuleSA
)
371 XmlTag
= "ModuleSA/BuildOptions"
372 PlatformModule
.BuildOptions
= map(LoadModuleBuildOption
, XmlList(XmlModuleSA
, XmlTag
)) #bugbug fix me
374 XmlTag
= "ModuleSA/Externs"
375 PlatformModule
.Externs
= map(LoadModuleExtern
, XmlList(XmlModuleSA
, XmlTag
)) #bugbug fix me
377 XmlTag
= "SupArchList"
378 PlatformModule
.SupArchList
= XmlAttribute(XmlModuleSA
, XmlTag
).split()
380 # the package guid which the module depends on, do not care for now
381 XmlTag
= "PackageGuid"
382 PlatformModule
.PackageGuid
= XmlAttribute(XmlModuleSA
, XmlTag
)
384 # the module guid, use this guid to get the module *.msa file and convert it to *.inf file with path
385 XmlTag
= "ModuleGuid"
386 PlatformModule
.ModuleGuid
= XmlAttribute(XmlModuleSA
, XmlTag
)
387 # use this guid to find the *.msa file path or FilePath $(WORKSPACE)/EdkModulePkg/Core/Dxe/DxeMain.msa
388 # then convert $(WORKSPACE)/EdkModulePkg/Core/Dxe/DxeMain.msa to $(WORKSPACE)/EdkModulePkg/Core/Dxe/DxeMain.inf, it's FilePath
389 PlatformModulePath
= gEdkIIWorkspaceGuidsInfo
.ResolveModuleFilePath(PlatformModule
.ModuleGuid
)
391 PlatformModule
.FilePath
= PlatformModulePath
# *.inf file path
392 # *.inf back to *.msa
393 ModuleMSAFileName
= PlatformModulePath
.replace('.inf', '.msa')
394 WorkSpace
= os
.getenv('WORKSPACE')
395 ModuleMSAFileName
= os
.path
.join(WorkSpace
, ModuleMSAFileName
)
397 #ModuleMSA = open(ModuleMSAFileName, "r")
398 XmlMsa
= XmlParseFile(ModuleMSAFileName
)
400 XmlTag
= "ModuleSurfaceArea/MsaHeader/ModuleName"
401 PlatformModule
.Name
= XmlElement(XmlMsa
, XmlTag
) # ModuleName
403 XmlTag
= "ModuleSurfaceArea/MsaHeader/ModuleType"
404 PlatformModule
.ModuleType
= XmlElement(XmlMsa
, XmlTag
)
406 # IA32, X64, IPF and EBC which the module support arch
407 #XmlTag = "ModuleSurfaceArea/ModuleDefinitions/SupportedArchitectures"
408 #PlatformModule.SupArchList = XmlElement(XmlMsa, XmlTag).split()
410 #XmlTag = "ModuleSurfaceArea/MsaHeader/"
411 PlatformModule
.Type
= '' #LIBRARY | LIBRARY_CLASS | MODULE, used by dsc. New in DSC spec
413 PlatformModule
.ExecFilePath
= '' # New in DSC spec
415 XmlTag
= "ModuleSurfaceArea/MsaHeader/Specification"
416 PlatformModule
.Specifications
= XmlElement(XmlMsa
, XmlTag
).split()
418 return PlatformModule
420 ## Load Platform modules
422 # Read an input Platform XML DOM object and return a list of Platform modules class object
423 # contained in the DOM object.
425 # @param XmlFpd An XML DOM object read from FPD file
427 # @retvel PlatformModules A list of Platform modules object loaded from XmlFpd
429 def LoadPlatformModules(XmlFpd
):
430 PlatformModules
= PlatformModuleClasses()
432 XmlTag
= "PlatformSurfaceArea/FrameworkModules/ModuleSA"
433 PlatformModules
.ModuleList
= map(LoadModuleSA
, XmlList(XmlFpd
, XmlTag
))
435 return PlatformModules
437 ## Load Platform Flash Definition File
439 # Read an input Platform XML DOM object and return Platform Flash Definition File class object
440 # contained in the DOM object.
442 # @param XmlFpd An XML DOM object read from FPD file
443 # @param FpdFileName The file path of FPD File
445 # @retvel PlatformFlashDefinitionFile A new Platform Flash Definition File object loaded from XmlFpd
447 def LoadPlatformFlashDefinitionFile(XmlFpd
, FpdFileName
):
448 PlatformFlashDefinitionFile
= PlatformFlashDefinitionFileClass()
450 XmlTag
= "PlatformSurfaceArea/Flash/FlashDefinitionFile"
451 PlatformFlashDefinitionFile
.FilePath
= XmlElement(XmlFpd
, XmlTag
)
453 XmlTag
= "PlatformSurfaceArea/Flash/FlashDefinitionFile/Id"
454 PlatformFlashDefinitionFile
.Id
= XmlAttribute(XmlFpd
, XmlTag
)
456 XmlTag
= "PlatformSurfaceArea/Flash/FlashDefinitionFile/UiName"
457 PlatformFlashDefinitionFile
.UiName
= XmlAttribute(XmlFpd
, XmlTag
)
459 XmlTag
= "PlatformSurfaceArea/Flash/FlashDefinitionFile/Preferred"
460 PlatformFlashDefinitionFile
.Preferred
= XmlAttribute(XmlFpd
, XmlTag
)
462 return PlatformFlashDefinitionFile
464 ## Load Platform User Defined Ant Tasks
466 # Read an input Platform XML DOM object and return platform
467 # User Defined Ant Tasks contained in the DOM object.
469 # @param XmlUserDefinedAntTasks An XML DOM object read from FPD file
471 # @retvel AntTask An Ant Task loaded from XmlFpd
473 def LoadUserDefinedAntTasks(XmlFpd
):
475 AntTask
= PlatformAntTaskClass()
477 XmlTag
= "PlatformSurfaceArea/BuildOptions/UserDefinedAntTasks/AntTask/Id"
478 AntTask
.Id
= XmlAttribute(XmlFpd
, XmlTag
)
480 XmlTag
= "PlatformSurfaceArea/BuildOptions/UserDefinedAntTasks/AntTask/AntCmdOptions"
481 AntTask
.AntCmdOptions
= XmlElement(XmlFpd
, XmlTag
)
483 XmlTag
= "PlatformSurfaceArea/BuildOptions/UserDefinedAntTasks/AntTask/Filename"
484 AntTask
.FilePath
= XmlElement(XmlFpd
, XmlTag
)
486 Dict
[AntTask
.Id
] = AntTask
489 ## Load Platform Build Options
491 # Read an input Platform XML DOM object and return a list of platform
492 # Build Option contained in the DOM object.
494 # @param XmlBuildOptions An XML DOM object read from FPD file
496 # @retvel PlatformBuildOptions A list of platform Build Options loaded from XmlFpd
498 def LoadBuildOptions(XmlBuildOptions
):
500 return map(LoadBuildOption
, XmlList(XmlBuildOptions
, XmlTag
)) # LoadBuildOption is a method in MigrationUtilities.py
502 ## Load Platform Build Option
504 # Read an input Platform XML DOM object and return a Build Option
505 # contained in the DOM object.
507 # @param XmlFpd An XML DOM object read from FPD file
509 # @retvel PlatformBuildOption A Build Options loaded from XmlFpd
511 def LoadPlatformBuildOption(XmlBuildOptions
):
512 PlatformBuildOption
= PlatformBuildOptionClass()
514 # handle UserDefinedAntTasks
515 XmlTag
= "BuildOptions/UserDefinedAntTasks/AntTask"
516 PlatformBuildOption
.UserDefinedAntTasks
= LoadUserDefinedAntTasks(XmlTag
)
519 XmlTag
= "BuildOptions/Options/Option"
520 PlatformBuildOption
.Options
= map(LoadBuildOption
, XmlList(XmlBuildOptions
, XmlTag
))
522 # handle UserExtensions
523 XmlTag
= "BuildOptions/UserExtensions"
524 PlatformBuildOption
.UserExtensions
= LoadUserExtensions(XmlTag
) # from MigrationUtilities.py LoadUserExtensions
527 XmlTag
= "BuildOptions/Ffs/FfsKey"
528 PlatformBuildOption
.FfsKeyList
= map(LoadPlatformFfs
, XmlList(XmlBuildOptions
, XmlTag
))
530 return PlatformBuildOption
532 ## Load Platform Ffs Dictionary
534 # Read an input Platform XML DOM object and return a platform Ffs Dictionary
535 # contained in the DOM object.
537 # @param XmlFpd An XML DOM object read from FPD file
539 # @retvel Dict A platform Ffs Dict loaded from XmlFpd
541 def LoadPlatformFfsDict(XmlFpd
):
543 XmlTag
= "PlatformSurfaceArea/BuildOptions/Ffs"
544 List
= map(LoadPlatformFfs
, XmlList(XmlFpd
, XmlTag
))
550 ## Load Platform Ffs Section
552 # Read an input Platform XML DOM object and return a platform Ffs Section
553 # contained in the DOM object.
555 # @param XmlFfs An XML DOM object read from FPD file
557 # @retvel PlatformFfsSection A platform Ffs Section loaded from XmlFpd
559 def LoadPlatformFfsSection(XmlFfsSection
):
560 PlatformFfsSection
= PlatformFfsSectionClass()
563 PlatformFfsSection
.BindingOrder
= ''
566 PlatformFfsSection
.Compressible
= ''
568 XmlTag
= "SectionType"
569 PlatformFfsSection
.SectionType
= XmlAttribute(XmlFfsSection
, XmlTag
)
572 PlatformFfsSection
.EncapsulationType
= ''
575 PlatformFfsSection
.ToolName
= ''
578 PlatformFfsSection
.Filenames
= []
581 PlatformFfsSection
.Args
= ''
584 PlatformFfsSection
.OutFile
= ''
587 PlatformFfsSection
.OutputFileExtension
= ''
590 PlatformFfsSection
.ToolNameElement
= ''
592 return PlatformFfsSection
594 ## Load Platform Ffs Sections
596 # Read an input Platform XML DOM object and return a platform Ffs Sections
597 # contained in the DOM object.
599 # @param XmlFfs An XML DOM object read from FPD file
601 # @retvel PlatformFfsSections A platform Ffs Sections loaded from XmlFpd
603 def LoadFfsSections():
604 PlatformFfsSections
= PlatformFfsSectionsClass()
605 PlatformFfsSections
.BindingOrder
= ''
606 PlatformFfsSections
.Compressible
= ''
607 PlatformFfsSections
.SectionType
= ''
608 PlatformFfsSections
.EncapsulationType
= ''
609 PlatformFfsSections
.ToolName
= ''
610 PlatformFfsSections
.Section
= []
611 PlatformFfsSections
.Sections
= []
613 return PlatformFfsSections
615 ## Load Platform Ffs Sections
617 # Read an input Platform XML DOM object and return a platform Ffs Sections
618 # contained in the DOM object.
620 # @param XmlFfs An XML DOM object read from FPD file
622 # @retvel PlatformFfsSections A platform Ffs Sections loaded from XmlFpd
624 def LoadPlatformFfsSections(XmlFfsSections
):
625 PlatformFfsSections
= PlatformFfsSectionsClass()
628 PlatformFfsSections
.BindingOrder
= ''
636 XmlTag
= "EncapsulationType"
637 EncapsulationType
= XmlAttribute(XmlFfsSections
, XmlTag
)
642 XmlTag
= "Sections/Section"
643 Section
= [] #[ PlatformFfsSectionClass, ... ]
644 Section
= map(LoadPlatformFfsSection
, XmlList(XmlFfsSections
, XmlTag
))
647 XmlTag
= "Sections/Sections"
648 Sections
= map(LoadFfsSections
, XmlList(XmlFfsSections
, XmlTag
)) #[ PlatformFfsSectionsClass, ...]
650 return PlatformFfsSections
652 ## Load Platform Ffs Attribute
654 # Read an input Platform XML DOM object and return a platform Ffs Attribute
655 # contained in the DOM object.
657 # @param XmlFfs An XML DOM object read from FPD file
659 # @retvel List A platform Ffs Attribute loaded from XmlFpd
661 def LoadFfsAttribute(XmlFfs
):
663 XmlTag
= "Ffs/Attribute"
664 for XmlAttr
in XmlList(XmlFfs
, XmlTag
):
666 Name
= XmlAttribute(XmlAttr
, XmlTag
)
668 Value
= XmlAttribute(XmlAttr
, XmlTag
)
669 List
.append([Name
,Value
])
672 ## Load a list of Platform Build Options
674 # Read an input Platform XML DOM object and return a list of Build Options
675 # contained in the DOM object.
677 # @param XmlFfs An XML DOM object read from FPD file
679 # @retvel PlatformFfsKey A platform Ffs key loaded from XmlFpd
681 def LoadPlatformFfs(XmlFfs
):
682 PlatformFfs
= PlatformFfsClass()
684 PlatformFfs
.Attribute
= {}
687 List
= LoadFfsAttribute(XmlFfs
)
689 XmlTag
= "Ffs/Sections/Sections"
690 PlatformFfs
.Sections
= map(LoadPlatformFfsSections
, XmlList(XmlFfs
, XmlTag
)) #[PlatformFfsSectionsClass, ...]
695 for Item
in PlatformFfs
.Sections
:
696 Dict
[(Name
, Item
)] = Value
697 PlatformFfs
.Attribute
= Dict
699 XmlTag
= "Ffs/FfsKey"
700 PlatformFfs
.Key
= XmlAttribute(XmlFfs
, XmlTag
)
704 ## Load a list of Platform Build Options
706 # Read an input Platform XML DOM object and return a list of Build Options
707 # contained in the DOM object.
709 # @param XmlFpd An XML DOM object read from FPD file
711 # @retvel PlatformBuildOptions A list of Build Options loaded from XmlFpd
713 def LoadPlatformBuildOptions(XmlFpd
):
714 PlatformBuildOptions
= PlatformBuildOptionClass()
716 PlatformBuildOptions
.UserDefinedAntTasks
= LoadUserDefinedAntTasks(XmlFpd
)
718 XmlTag
= "PlatformSurfaceArea/BuildOptions/Options/Option"
719 PlatformBuildOptions
.Options
= map(LoadBuildOption
, XmlList(XmlFpd
, XmlTag
))
721 PlatformBuildOptions
.UserExtensions
= LoadPlatformUserExtension(XmlFpd
)
723 PlatformBuildOptions
.FfsKeyList
= LoadPlatformFfsDict(XmlFpd
)
725 return PlatformBuildOptions
727 ## Load Platform Pcd Data
729 # Read an input Platform XML DOM object and return Platform module class object
730 # contained in the DOM object.
732 # @param XmlPcd An XML DOM object read from FPD file
734 # @retvel PlatformPcdData A Platform Pcd object loaded from XmlFpd
736 def LoadPlatformPcdData(XmlPcdData
):
737 PcdData
= PcdClass() # defined in CommonDataClass.CommonClass.py
740 PcdData
.ItemType
= XmlAttribute(XmlPcdData
, XmlTag
) #DYNAMIC
742 XmlTag
= "PcdData/C_Name"
743 PcdData
.C_NAME
= XmlElement(XmlPcdData
, XmlTag
)
745 XmlTag
= "PcdData/Token"
746 PcdData
.Token
= XmlElement(XmlPcdData
, XmlTag
)
748 XmlTag
= "PcdData/TokenSpaceGuidCName"
749 PcdData
.TokenSpaceGuidCName
= XmlElement(XmlPcdData
, XmlTag
)
751 XmlTag
= "PcdData/DatumType"
752 PcdData
.DatumType
= XmlElement(XmlPcdData
, XmlTag
)
754 XmlTag
= "PcdData/MaxDatumSize"
755 PcdData
.MaxDatumSize
= XmlElement(XmlPcdData
, XmlTag
)
757 XmlTag
= "PcdData/Value"
758 PcdData
.Value
= XmlElement(XmlPcdData
, XmlTag
)
762 ## Load a Platform Pcd Build Data
764 # Read an input Platform XML DOM object and return a list of Pcd Dynamic
765 # contained in the DOM object.
767 # @param XmlPcdBuildData An XML DOM object read from FPD file
769 # @retvel PcdBuildData A Platform Pcd Build Data loaded from XmlFpd
771 def LoadPlatformPcdBuildData(XmlPcdBuildData
):
772 PcdBuildData
= PcdClass() # defined in CommonDataClass.CommonClass.py
775 PcdBuildData
.ItemType
= XmlAttribute(XmlPcdBuildData
, XmlTag
) #DYNAMIC
777 XmlTag
= "PcdBuildData/C_Name"
778 PcdBuildData
.C_NAME
= XmlElement(XmlPcdBuildData
, XmlTag
)
780 XmlTag
= "PcdBuildData/Token"
781 PcdBuildData
.Token
= XmlElement(XmlPcdBuildData
, XmlTag
)
783 XmlTag
= "PcdBuildData/TokenSpaceGuidCName"
784 PcdBuildData
.TokenSpaceGuidCName
= XmlElement(XmlPcdBuildData
, XmlTag
)
786 XmlTag
= "PcdBuildData/DatumType"
787 PcdBuildData
.DatumType
= XmlElement(XmlPcdBuildData
, XmlTag
)
789 XmlTag
= "PcdBuildData/MaxDatumSize"
790 PcdBuildData
.MaxDatumSize
= XmlElement(XmlPcdBuildData
, XmlTag
)
792 #XmlTag = "PcdBuildData/Value"
793 #PcdBuildData.Value = XmlElement(XmlPcdBuildData, XmlTag)
797 ## Load a list of Platform Pcd Dynamic
799 # Read an input Platform XML DOM object and return a list of Pcd Dynamic
800 # contained in the DOM object.
802 # @param XmlFpd An XML DOM object read from FPD file
804 # @retvel PcdDynamic A list of Pcd Dynamic loaded from XmlFpd
806 def LoadDynamicPcdBuildDefinitions(XmlFpd
):
807 DynamicPcdBuildDefinitions
= []
808 XmlTag
= "PlatformSurfaceArea/DynamicPcdBuildDefinitions/PcdBuildData"
809 return map(LoadPlatformPcdBuildData
, XmlList(XmlFpd
, XmlTag
))
811 ## Load a Platform NameValue object
813 # Read an input Platform XML DOM object and return a list of User Extensions
814 # contained in the DOM object.
816 # @param XmlNameValue An XML DOM object read from FPD file
818 # @retvel NameValue A Platform NameValue object
820 def LoadNameValue(XmlNameValue
):
824 Name
= XmlAttribute(XmlNameValue
, XmlTag
)
825 NameValue
.append(Name
)
828 Value
= XmlAttribute(XmlNameValue
, XmlTag
)
829 NameValue
.append(Value
)
833 ## Load a Platform Fv Image Name object
835 # Read an input Platform XML DOM object and return a platform Fv Image
836 # Name contained in the DOM object.
838 # @param XmlFvImageNames An XML DOM object read from FPD file
840 # @retvel FvImageNames A Platform Fv Image Name object
842 def LoadFvImageNames(XmlFvImageNames
):
843 XmlTag
= "FvImageNames"
844 FvImageNames
= XmlElement(XmlFvImageNames
, XmlTag
)
847 ## Load a Platform Fv Image option object
849 # Read an input Platform XML DOM object and return a platform Fv Image
850 # Option contained in the DOM object.
852 # @param XmlFvImageOptions An XML DOM object read from FPD file
854 # @retvel PlatformFvImageOption A Platform Fv Image Option object
856 def LoadFvImageOptions(XmlFvImageOptions
):
857 PlatformFvImageOption
= PlatformFvImageOptionClass()
860 PlatformFvImageOption
.FvImageOptionName
= ''
863 PlatformFvImageOption
.FvImageOptionValues
= []
865 XmlTag
= "FvImageOptions/NameValue"
866 List
= map(LoadNameValue
, XmlList(XmlFvImageOptions
, XmlTag
))
868 return PlatformFvImageOption
870 ## Load a Platform Fv Image object
872 # Read an input Platform XML DOM object and return a list of User Extensions
873 # contained in the DOM object.
875 # @param XmlFvImage An XML DOM object read from Fpd file
877 # @retvel PlatformFvImage A Platform Fv Image object
879 def LoadPlatformFvImage(XmlFvImage
):
880 PlatformFvImage
= PlatformFvImageClass()
883 PlatformFvImage
.Name
= XmlAttribute(XmlFvImage
, XmlTag
)
886 PlatformFvImage
.Value
= XmlAttribute(XmlFvImage
, XmlTag
)
889 PlatformFvImage
.Type
= XmlAttribute(XmlFvImage
, XmlTag
)
891 XmlTag
= "FvImage/FvImageNames"
892 PlatformFvImage
.FvImageNames
= map(LoadFvImageNames
, XmlList(XmlFvImage
, XmlTag
))
894 XmlTag
= "FvImage/FvImageOptions"
895 PlatformFvImage
.FvImageOptions
= map(LoadFvImageOptions
, XmlList(XmlFvImage
, XmlTag
))
897 return PlatformFvImage
899 ## Load a Platform fdf object
901 # Read an input Platform XML DOM object and return a list of User Extensions
902 # contained in the DOM object.
904 # @param XmlFvImages An XML DOM object read from FPD file
906 # @retvel PlatformFdf A Platform fdf object
908 def LoadPlatformFvImages(XmlFvImages
):
911 XmlTag
= "FvImages/NameValue"
912 NameValues
= map(LoadNameValue
, XmlList(XmlFvImages
, XmlTag
))
913 List
.append(NameValues
)
915 XmlTag
= "FvImages/FvImage"
916 FvImages
= map(LoadPlatformFvImage
, XmlList(XmlFvImages
, XmlTag
))
917 List
.append(FvImages
)
919 XmlTag
= "FvImages/FvImageName"
920 FvImageNames
= map(LoadPlatformFvImageName
, XmlList(XmlFvImages
, XmlTag
))
921 List
.append(FvImageNames
)
925 ## Load a Platform Fv Image Name object
927 # Read an input Platform XML DOM object and return a list of User Extensions
928 # contained in the DOM object.
930 # @param XmlFvImageName An XML DOM object read from FPD file
932 # @retvel PlatformFvImageName A Platform Fv Image Name object
934 def LoadPlatformFvImageName(XmlFvImageName
):
935 PlatformFvImageName
= PlatformFvImageNameClass()
938 PlatformFvImageName
.Name
= XmlAttribute(XmlFvImageName
, XmlTag
)
941 PlatformFvImageName
.Type
= XmlAttribute(XmlFvImageName
, XmlTag
)
943 XmlTag
= "FvImageOptions"
944 PlatformFvImageName
.FvImageOptions
= map(LoadFvImageOptions
, XmlList(XmlFvImageName
, XmlTag
))
946 return PlatformFvImageName
948 ## Load a list of Platform fdf objects
950 # Read an input Platform XML DOM object and return a list of User Extensions
951 # contained in the DOM object.
953 # @param XmlFpd An XML DOM object read from FPD file
955 # @retvel PlatformFdfs A list of Platform fdf object
957 def LoadPlatformFdfs(XmlFpd
):
958 PlatformFvImages
= PlatformFvImagesClass()
960 XmlTag
= "PlatformSurfaceArea/Flash/FvImages"
961 PlatformFvImages
.FvImages
= map(LoadPlatformFvImages
, XmlList(XmlFpd
, XmlTag
))
963 return PlatformFvImages
965 ## Load a Platform User Extensions
967 # Read an input Platform XML DOM object and return an User Extension
968 # contained in the DOM object.
970 # @param XmlUserExtension An XML DOM object read from FPD file
972 # @retvel PlatformUserExtensions A platform User Extension loaded from XmlFpd
974 def LoadPlatformUserExtension(XmlFpd
):
977 PlatformUserExtensions
= UserExtensionsClass()
979 XmlTag
= "PlatformSurfaceArea/BuildOptions/UserExtensions"
980 List
= map(LoadUserExtensions
, XmlList(XmlFpd
, XmlTag
))
984 Identifier
= Item
.Identifier
985 Dict
[(UserID
, Identifier
)] = Item
986 #XmlTag = "PlatformSurfaceArea/BuildOptions/UserExtensions/UserID"
987 #PlatformUserExtensions.UserID = XmlAttribute(XmlFpd, XmlTag)
989 #XmlTag = "PlatformSurfaceArea/BuildOptions/UserExtensions/Identifier"
990 #PlatformUserExtensions.Identifier = XmlAttribute(XmlFpd, XmlTag)
992 #PlatformUserExtensions.Content = XmlElementData(XmlFpd)
993 #Dict[(PlatformUserExtensions.UserID,PlatformUserExtensions.Identifier)] = PlatformUserExtensions
994 #return PlatformUserExtensions
997 ## Load a list of Platform User Extensions
999 # Read an input Platform XML DOM object and return a list of User Extensions
1000 # contained in the DOM object.
1002 # @param XmlFpd An XML DOM object read from FPD file
1004 # @retvel UserExtensions A list of platform User Extensions loaded from XmlFpd
1006 def LoadPlatformUserExtensions(XmlFpd
):
1007 XmlTag
= "PlatformSurfaceArea/UserExtensions"
1008 return map(LoadUserExtensions
, XmlList(XmlFpd
, XmlTag
)) # from MigrationUtilities.py LoadUserExtensions
1010 ## Load a new Platform class object
1012 # Read an input FPD File and return a new Platform class Object.
1014 # @param FpdFileName An XML DOM object read from FPD file
1016 # @retvel Platform A new Platform class object loaded from FPD File
1018 def LoadFpd(FpdFileName
):
1019 XmlFpd
= XmlParseFile(FpdFileName
)
1020 EdkLogger
.verbose("Load FPD File: %s" % FpdFileName
)
1022 Platform
= PlatformClass()
1023 Platform
.Header
= LoadPlatformHeader(XmlFpd
, FpdFileName
)
1024 Platform
.SkuInfos
= LoadPlatformSkuInfos(XmlFpd
)
1025 Platform
.Libraries
= [] #New in dsc spec, do not handle for now
1026 Platform
.LibraryClasses
= LoadPlatformLibraryClasses(XmlFpd
)
1027 Platform
.Modules
= LoadPlatformModules(XmlFpd
)
1028 Platform
.FlashDefinitionFile
= LoadPlatformFlashDefinitionFile(XmlFpd
, FpdFileName
)
1029 Platform
.BuildOptions
= LoadPlatformBuildOptions(XmlFpd
)
1030 Platform
.DynamicPcdBuildDefinitions
= LoadDynamicPcdBuildDefinitions(XmlFpd
)
1031 Platform
.Fdf
= LoadPlatformFdfs(XmlFpd
)
1032 Platform
.UserExtensions
= LoadPlatformUserExtensions(XmlFpd
)
1036 # This acts like the main() function for the script, unless it is 'import'ed
1037 # into another script.
1038 if __name__
== '__main__':