4 # Copyright (c) 2007, Intel Corporation
5 # All rights reserved. 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.
14 """ This program converts EDK II MSA files into EDK II Extended INF format files """
16 import os
, re
, sys
, fnmatch
, xml
.dom
.minidom
17 from optparse
import OptionParser
18 from AutoGenExterns
import *
19 from Common
.XmlRoutines
import * # XmlParseFile, XmlElement, XmlAttribute, XmlList, XmlElementData, XmlNode
20 from Common
.EdkIIWorkspace
import *
23 __version__
= "%prog Version " + versionNumber
24 __copyright__
= "Copyright (c) 2007, Intel Corporation All rights reserved."
26 commonHeaderFilename
= "CommonHeader.h"
27 entryPointFilename
= "EntryPoint.c"
29 AutoGenLibraryMapping
= {
30 "HiiLib":"HiiLibFramework",
31 "EdkIfrSupportLib":"IfrSupportLibFramework",
32 "EdkScsiLib":"ScsiLib",
34 "EdkFvbServiceLib":"FvbServiceLib",
35 "EdkGraphicsLib":"GraphicsLib"
39 """ Argument Parser """
40 usage
= "%prog [options] -f input_filename"
41 parser
= OptionParser(usage
=usage
,description
=__copyright__
,version
="%prog " + str(versionNumber
))
42 parser
.add_option("-f", "--file", dest
="filename", help="Name of MSA file to convert")
43 parser
.add_option("-o", "--output", dest
="outfile", help="Specific Name of the INF file to create, otherwise it is the MSA filename with the extension repalced.")
44 parser
.add_option("-a", "--auto", action
="store_true", dest
="autowrite", default
=False, help="Automatically create output files and write the INF file")
45 parser
.add_option("-i", "--interactive", action
="store_true", dest
="interactive", default
=False, help="Set Interactive mode, user must approve each change.")
46 parser
.add_option("-q", "--quiet", action
="store_const", const
=0, dest
="verbose", help="Do not print any messages, just return either 0 for succes or 1 for failure")
47 parser
.add_option("-v", "--verbose", action
="count", dest
="verbose", help="Do not print any messages, just return either 0 for succes or 1 for failure")
48 parser
.add_option("-d", "--debug", action
="store_true", dest
="debug", default
=False, help="Enable printing of debug messages.")
49 parser
.add_option("-c", "--convert", action
="store_true", dest
="convert", default
=False, help="Convert package: OldMdePkg->MdePkg EdkModulePkg->MdeModulePkg.")
50 parser
.add_option("-e", "--event", action
="store_true", dest
="event", default
=False, help="Enable handling of Exit Boot Services & Virtual Address Changed Event")
51 parser
.add_option("-m", "--manual", action
="store_true", dest
="manual", default
=False, help="Generate CommonHeader.txt, user picks up & copy it to a module common header")
52 parser
.add_option("-w", "--workspace", dest
="workspace", default
=str(os
.environ
.get('WORKSPACE')), help="Specify workspace directory.")
53 (options
, args
) = parser
.parse_args(sys
.argv
[1:])
59 """ Parse XML in the FrameworkDatabase.db file pointed to by f """
60 if (options
.debug
and options
.verbose
> 1):
61 print "Opening the database file:", f
69 """ Parse XML in the SPD file pointed to by s """
70 if (options
.debug
and options
.verbose
> 1):
71 print "Opening the SPD file:", s
79 """ Parse XML in the MSA file pointed to by m """
80 if (options
.debug
and options
.verbose
> 1):
81 print "Opening the MSA file:", m
88 def AddGuid(ArchList
, CName
, Usage
):
89 """ Add a GUID to the Architecture array that the GUID is valid for. """
90 if "IA32" in ArchList
:
91 GuidCNameIa32
.insert(0, str(" %-45s # %s" % (CName
, Usage
)))
93 GuidCNameX64
.insert(0, str(" %-45s # %s" % (CName
, Usage
)))
95 GuidCNameIPF
.insert(0, str(" %-45s # %s" % (CName
, Usage
)))
97 GuidCNameEBC
.insert(0, str(" %-45s # %s" % (CName
, Usage
)))
99 GuidCName
.insert(0, str(" %-45s # %s" % (CName
, Usage
)))
102 def removeDups(CN
, ListName
):
103 """ Remove Duplicate Entries from the Guid List passed in """
104 for Entry
in ListName
[:]:
105 if " " + CN
+ " " in Entry
:
106 if (options
.verbose
> 1):
107 print "Removing C Name %s Entry from Guids List." % (CN
)
108 ListName
.remove(Entry
)
111 """ Process the supported architectures passed in to combine if possible """
112 Archs
= Archs
.upper()
113 if (("IA32" in Archs
) & ("X64" in Archs
) & ("IPF" in Archs
) & ("EBC" in Archs
)):
115 if (len(Archs
) == 0):
119 def saveSourceFile(moduleDir
, sourceFilename
, sourceFileContents
):
120 newFilename
= os
.path
.join(moduleDir
, sourceFilename
)
123 f
= open(newFilename
, "w+")
124 f
.write(sourceFileContents
)
127 print "IO error in saving %s" % sourceFilename
129 return sourceFilename
131 def openSourceFile(moduleDir
, sourceFilename
):
132 newFilename
= os
.path
.join(moduleDir
, sourceFilename
)
133 sourceFileContents
= ""
135 f
= open(newFilename
, "r")
136 sourceFileContents
= f
.read()
139 print "IO error in opening %s" % sourceFilename
141 return sourceFileContents
143 def MatchOption(eline
, ToolChainFamily
, Targets
, Archs
, ToolCode
, Value
):
144 IDs
= eline
.split("_")
150 if (Targets
[0] == "*") or IDs
[0] in Targets
:
151 MatchedTargets
.append(IDs
[0])
153 MatchedTargets
= Targets
156 if Archs
[0] == "*" or IDs
[2] in Archs
:
157 MatchedArchs
.append(IDs
[2])
161 if IDs
[3] != ToolCode
and IDs
[3] != "*":
165 for arch
in MatchedArchs
:
166 for target
in MatchedTargets
:
167 line
= "%s:%s_%s_%s_%s_FLAGS = %s" % (ToolChainFamily
, target
, IDs
[1], arch
, ToolCode
, Value
)
176 AutoGenDeclaration
= ""
177 AutoGenModuleFolder
= None
181 if (options
.workspace
== None):
182 print "ERROR: E0000: WORKSPACE not defined.\n Please set the WORKSPACE environment variable to the location of the EDK II install directory."
185 workspace
= options
.workspace
187 print "Using Workspace:", workspace
196 FdbPath
= os
.path
.join(workspace
, "Conf")
197 FdbPath
= os
.path
.join(FdbPath
, "FrameworkDatabase.db")
198 if os
.path
.exists(FdbPath
):
201 print "ERROR: E0001: WORKSPACE does not contain the FrameworkDatabase File.\n Please run EdkSetup from the EDK II install directory.\n"
204 Fdb
= openDatabase(FdbFile
)
206 print "ERROR: E0002 Could not open the Framework Database file:", FdbFile
210 print "FrameworkDataBase.db file:", FdbFile
213 InitializeAutoGen(workspace
, Fdb
)
215 if (options
.filename
):
216 filename
= options
.filename
217 if ((options
.verbose
> 1) |
(options
.autowrite
)):
218 print "Filename:", filename
220 print "ERROR: E0001 - You must specify an input filename"
223 if (options
.outfile
):
224 outputFile
= options
.outfile
226 outputFile
= filename
.replace('.msa', '.inf')
228 if ((options
.verbose
> 2) or (options
.debug
)):
229 print "Output Filename:", outputFile
231 Msa
= openMsa(filename
)
233 ## Maybe developer think WORKSPACE macro is the root directory of file name
234 ## So we will try to add WORKSPACE path into filename
236 MsaFileName
= os
.path
.join(workspace
, filename
)
237 Msa
= openMsa(MsaFileName
)
239 print "ERROR: E0002: Could not open the file:", filename
242 AutoGenModuleFolder
= os
.path
.dirname(filename
)
244 MsaHeader
= "/ModuleSurfaceArea/MsaHeader/"
245 MsaDefs
= "/ModuleSurfaceArea/ModuleDefinitions/"
246 BaseName
= str(XmlElement(Msa
, MsaDefs
+ "OutputFileBasename")).strip()
248 if (len(BaseName
) < 1):
249 BaseName
= str(XmlElement(Msa
, MsaHeader
+ "BaseName")).strip()
250 BaseName
= re
.sub(' ', '_', BaseName
)
252 GuidValue
= str(XmlElement(Msa
, MsaHeader
+ "GuidValue")).strip()
253 VerString
= str(XmlElement(Msa
, MsaHeader
+ "Version")).strip()
254 ModType
= str(XmlElement(Msa
, MsaHeader
+ "ModuleType")).strip()
255 CopyRight
= str(XmlElement(Msa
, MsaHeader
+ "Copyright")).strip()
256 Abstract
= str(XmlElement(Msa
, MsaHeader
+ "Abstract")).strip()
257 Description
= str(XmlElement(Msa
, MsaHeader
+ "Description")).strip().replace(" ", " ").replace(" ", " ").replace(" ", " ")
258 if not CopyRight
.find("2007"):
259 CopyRight
= CopyRight
.replace("2006", "2007")
260 License
= str(XmlElement(Msa
, MsaHeader
+ "License")).strip().replace(" ", " ")
261 MsaDefs
= "/ModuleSurfaceArea/ModuleDefinitions/"
264 BinModule
= str(XmlElement(Msa
, MsaDefs
+ "BinaryModule")).strip()
268 SupportedArchitectures
= ""
270 SupportedArchitectures
= str(XmlElement(Msa
, MsaDefs
+ "SupportedArchitectures")).strip()
275 if (len(SupportedArchitectures
) > 0):
276 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
277 DefinesComments
.append("# VALID_ARCHITECTURES = " + SupportedArchitectures
+ "\n")
278 DefinesComments
.append("#\n")
280 MsaExtern
= "/ModuleSurfaceArea/Externs/"
283 PcdIsDriver
= str(XmlElement(Msa
, MsaExtern
+ "PcdIsDriver")).strip()
290 List
= XmlList(Msa
, MsaExtern
+ "Specification")
296 SpecList
.insert(0, str(XmlElementData(spec
)).strip())
301 Flag
= (DefinesComments
== [])
303 # Data structure to insert autogen code
304 AutoGenDriverModel
= []
305 AutoGenExitBootServices
= []
306 AutoGenVirtualAddressChanged
= []
307 AutoGenEntryPoint
= ""
312 AutoGenSourceFiles
= []
317 Externlist
= XmlList(Msa
, MsaExtern
+ "Extern")
321 if (len(Externlist
) > 0):
322 if (options
.debug
and options
.verbose
> 2):
323 print "In Extern Parsing Routine"
324 for extern
in Externlist
:
335 AutoGenDriverModelItem
= []
337 EntryPoint
= str(XmlElementData(extern
.getElementsByTagName("ModuleEntryPoint")[0])).strip()
338 AutoGenEntryPoint
= EntryPoint
339 #DriverModules.append(" %-30s = %s\n" % ("ENTRY_POINT" , EntryPoint))
344 Unload
= str(XmlElementData(extern
.getElementsByTagName("ModuleUnloadImage")[0])).strip()
345 AutoGenUnload
= Unload
346 DriverModules
.append(" %-30s = %s\n" % ("UNLOAD_IMAGE", Unload
))
351 DBinding
= str(XmlElementData(extern
.getElementsByTagName("DriverBinding")[0])).strip()
352 AutoGenDriverModelItem
.append("&" + DBinding
)
353 DefinesComments
.append("# %-29s = %-45s\n" % ("DRIVER_BINDING", DBinding
))
359 CompName
= str(XmlElementData(extern
.getElementsByTagName("ComponentName")[0])).strip()
360 AutoGenDriverModelItem
.append("&" + CompName
)
361 DefinesComments
.append("# %-29s = %-45s\n" % ("COMPONENT_NAME", CompName
))
365 AutoGenDriverModelItem
.append("NULL")
369 Config
= str(XmlElementData(extern
.getElementsByTagName("DriverConfig")[0])).strip()
370 AutoGenDriverModelItem
.append("&" + Config
)
371 DefinesComments
.append("# %-29s = %-45s\n" % ("DRIVER_CONFIG", Config
))
375 AutoGenDriverModelItem
.append("NULL")
379 Diag
= str(XmlElementData(extern
.getElementsByTagName("DriverDiag")[0])).strip()
380 AutoGenDriverModelItem
.append("&" + Diag
)
381 DefinesComments
.append("# %-29s = %-45s\n" % ("DRIVER_DIAG", Diag
))
385 AutoGenDriverModelItem
.append("NULL")
388 if len(AutoGenDriverModelItem
) > 0:
389 AutoGenDriverModel
.append(AutoGenDriverModelItem
)
392 Constr
= str(XmlElementData(extern
.getElementsByTagName("Constructor")[0])).strip()
393 LibraryModules
.append(" %-30s = %s\n" % ("CONSTRUCTOR", Constr
))
398 Destr
= str(XmlElementData(extern
.getElementsByTagName("Destructor")[0])).strip()
399 LibraryModules
.append(" %-30s = %s\n" % ("DESTRUCTOR", Destr
))
404 CallBack
= str(XmlElement(extern
, "Extern/SetVirtualAddressMapCallBack")).strip()
406 AutoGenVirtualAddressChanged
.append(CallBack
)
407 DefinesComments
.append("# %-29s = %-45s\n" % ("VIRTUAL_ADDRESS_MAP_CALLBACK", CallBack
))
414 CallBack
= str(XmlElement(extern
, "Extern/ExitBootServicesCallBack")).strip()
416 AutoGenExitBootServices
.append(CallBack
)
417 DefinesComments
.append("# %-29s = %-45s\n" % ("EXIT_BOOT_SERVICES_CALLBACK", CallBack
))
425 """ Get the Module's custom build options """
427 MBO
= "/ModuleSurfaceArea/ModuleBuildOptions/Options/Option"
430 mboList
= XmlList(Msa
, MBO
)
434 if (len(mboList
) > 0):
435 for Option
in mboList
:
441 bt
= str(Option
.getAttribute("BuildTargets"))
446 if (re
.findall(" ", bt
) > 0):
449 Targets
.insert(0, bt
)
451 Targets
.insert(0, "*")
453 if (options
.debug
and options
.verbose
> 2):
454 print "Targets", len(Targets
), Targets
458 pro
= Option
.getAttribute("SupArchList")
459 if (re
.findall(" ", pro
) > 0):
461 elif (re
.findall(",", pro
) > 0):
462 Archs
= pro
.split(",")
469 if (options
.debug
and options
.verbose
> 2):
470 print "Archs", len(Archs
), Archs
474 ToolCode
= str(Option
.getAttribute("ToolCode"))
478 if (len(ToolCode
) == 0):
483 value
= str(XmlElementData(Option
))
489 TagName
= str(Option
.getAttribute("TagName"))
493 if (len(TagName
) > 0) :
494 if (options
.debug
and options
.verbose
> 2):
495 print "TagName was defined:", TagName
496 Tags
.insert(0, TagName
)
498 if (options
.debug
and options
.verbose
> 2):
499 print "TagName was NOT defined!"
505 Family
= str(Option
.getAttribute("ToolChainFamily")).strip()
509 if (len(Family
) > 0):
511 print "Searching tools_def.txt for Tool Tags that belong to:", Family
, "family"
514 tdPath
= os
.path
.join(workspace
, "Tools")
515 tdPath
= os
.path
.join(tdPath
, "Conf")
516 tdPath
= os
.path
.join(tdPath
, "tools_def.txt")
517 tdPath
= tdPath
.replace("\\", "/")
518 if os
.path
.exists(tdPath
):
521 tdPath
= os
.path
.join(workspace
, "Conf")
522 tdPath
= os
.path
.join(tdPath
, "tools_def.txt")
523 if os
.path
.exists(tdPath
):
526 print "ERROR: E0001: WORKSPACE does not contain the tools_def.txt File.\n Please run EdkSetup from the EDK II install directory.\n"
529 if (options
.debug
and options
.verbose
> 2):
530 print "Opening:", tdFile
533 tools_def
= open(tdFile
, "r")
534 for tdline
in tools_def
:
537 if "FAMILY" in tdline
:
538 if (options
.debug
and options
.verbose
> 2):
539 print "Testing for FAMILY:", Family
, "in the line:", tdline
.strip()
541 enter
= tdline
.split("=")[0]
542 if (options
.debug
and options
.verbose
> 2):
543 print "Adding TNL:", tdline
544 TagNameList
.insert(0, enter
)
547 if (options
.debug
and options
.verbose
> 2):
548 print "TagNameList:", TagNameList
551 for eline
in TagNameList
:
554 if (options
.debug
and options
.verbose
> 2):
555 print "ToolsDef entry:", eline
557 olines
= MatchOption(eline
, Family
, Targets
, Archs
, ToolCode
, value
)
561 for oline
in olinesSet
:
562 if (options
.debug
and options
.verbose
> 2):
563 print "Adding:", str(oline
)
564 MBOlines
.insert(0, oline
)
568 oline
= " %s_%s_%s_%s_FLAGS = %s" % (targ
, Tags
[0], arch
, str(ToolCode
), str(Value
))
569 if (options
.debug
and options
.verbose
> 2):
570 print "Adding:", str(oline
)
571 MBOlines
.insert(0, oline
)
579 oline
= " " + str(targ
) + "_" + str(tag
) + "_" + str(arch
) + "_" + str(ToolCode
) + "_FLAGS = " + str(value
)
580 if (options
.debug
and options
.verbose
> 2):
581 print "Adding:", str(oline
)
582 #MBOlines.insert(0, oline)
585 """ Get the Library Class information """
586 MsaLcDefs
= "/ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass"
589 LcDefList
= XmlList(Msa
, MsaLcDefs
)
595 LibClassListIa32
= []
601 if (len(LcDefList
) > 0):
605 lcKeyword
= str(XmlElementData(Lc
.getElementsByTagName("Keyword")[0]))
607 raise SyntaxError, "The MSA is not correctly formed, a Library Class Keyword Element is required"
611 lcUsage
= str(XmlAttribute(Lc
, "Usage"))
613 raise SyntaxError, "The MSA is not correctly formed, a Usage Attribute is required for all Library Class Elements"
617 Archs
= str(XmlAttribute(Lc
, "SupArchList"))
621 Archs
= chkArch(Archs
)
623 if (options
.debug
and options
.verbose
> 2):
624 print "Attr: ", lcUsage
, lcKeyword
, Archs
626 if (options
.convert
):
627 lcKeyword
= AutoGenLibraryMapping
.get(lcKeyword
, lcKeyword
)
629 if re
.findall("PRODUCED", lcUsage
, re
.IGNORECASE
):
634 lcSupModList
= str(XmlAttribute(Lc
, "SupModuleList"))
640 AutoGenLibClass
.append(lcKeyword
)
641 if len(lcSupModList
) > 0:
642 lcLine
= lcLine
+ "|" + lcSupModList
643 IamLibrary
.insert(0, lcLine
)
646 elif lcKeyword
!= "UefiDriverModelLib":
647 AutoGenLibClass
.append(lcKeyword
)
648 # This section handles the library classes that are CONSUMED
650 LibClassListIa32
.insert(0, lcKeyword
)
652 LibClassListX64
.insert(0, lcKeyword
)
654 LibClassListIpf
.insert(0, lcKeyword
)
656 LibClassListEbc
.insert(0, lcKeyword
)
658 LibClassList
.insert(0, lcKeyword
)
659 if len(AutoGenDriverModel
) > 0 and "UefiLib" not in LibClassList
:
660 AutoGenLibClass
.append("UefiLib")
661 LibClassList
.insert(0, "UefiLib")
664 """ Get the Source File list """
666 SrcFilenamesIa32
= []
670 SrcFiles
= "/ModuleSurfaceArea/SourceFiles/Filename"
673 SrcList
= XmlList(Msa
, SrcFiles
)
677 if (len(SrcList
) > 0):
683 Archs
= fn
.getAttribute("SupArchList")
687 Archs
= chkArch(Archs
)
690 file = str(XmlElementData(fn
))
694 if file.endswith(".dxs"):
695 AutoGenDxsFiles
.append((file, Archs
))
697 AutoGenSourceFiles
.append(file)
699 SrcFilenamesIa32
.insert(0, file)
701 SrcFilenamesX64
.insert(0, file)
703 SrcFilenamesIpf
.insert(0, file)
705 SrcFilenamesEbc
.insert(0, file)
707 SrcFilenames
.insert(0, file)
709 """ Package Dependency section """
710 DbPkgList
= "/FrameworkDatabase/PackageList/Filename"
713 WorkspacePkgs
= XmlList(Fdb
, DbPkgList
)
715 print "Could not tet the package data from the database"
721 if (options
.debug
and options
.verbose
> 1):
722 print "Found %s packages in the WORKSPACE" % (len(WorkspacePkgs
))
726 if (len(WorkspacePkgs
) > 0):
727 SpdHeader
= "/PackageSurfaceArea/SpdHeader/"
728 for Pkg
in WorkspacePkgs
[:]:
733 file = str(XmlElementData(Pkg
))
737 if (options
.debug
and options
.verbose
> 2):
740 if fnmatch
.fnmatch(file, "*.dec"):
741 print "parsing " + os
.path
.join(workspace
, file)
745 Lines
= open(os
.path
.join(workspace
, file)).readlines()
747 print "Could not parse the Package file:", file
751 Line
= Line
.split("#")[0]
752 Items
= Line
.split("=")
756 Key
= Items
[0].strip().upper()
757 if Key
== "PACKAGE_GUID":
758 PackageGuid
= Items
[1].strip()
759 if Key
== "PACKAGE_VERSION":
760 PackageVersion
= Items
[1].strip()
763 Spd
= openSpd(os
.path
.join(workspace
, file))
765 print "Could not parse the Package file:", file
768 path
= os
.path
.split(file)[0]
769 file = file.replace(".nspd", ".dec")
770 file = file.replace(".spd", ".dec")
773 PackageGuid
= str(XmlElement(Spd
, SpdHeader
+ "GuidValue"))
778 PackageVersion
= str(XmlElement(Spd
, SpdHeader
+ "Version"))
782 file = file + "|" + PackageGuid
+ "|" + PackageVersion
783 PkgDb
.insert(0, file)
787 GuidEntries
= XmlList(Spd
, "/PackageSurfaceArea/GuidDeclarations/Entry")
791 if (len(GuidEntries
) > 0):
792 for Entry
in GuidEntries
[:]:
794 GuidDecls
.append(str(XmlElementData(Entry
.getElementsByTagName("C_Name")[0])).strip())
801 pHdrs
= XmlList(Spd
, "/PackageSurfaceArea/PackageHeaders/IncludePkgHeader")
808 ModTypeList
= str(Hdr
.getAttribute("ModuleType"))
809 if (ModType
in ModTypeList
):
810 HeaderName
= str(XmlElementData(Hdr
))[0]
811 Dirs
.insert(0, os
.path
.join(packagepath
,str(os
.path
.split(HeaderName
))))
815 # Get the Guid:Header from the Packages
816 SpdLcDec
= "/PackageSurfaceArea/LibraryClassDeclarations/LibraryClass"
819 lcList
= XmlList(Spd
, SpdLcDec
)
823 if (len(lcList
) > 0):
827 Name
= Lc
.getAttribute("Name")
833 Header
= XmlElementData(Lc
.getElementsByTagName("IncludeHeader")[0])
837 if ((len(Name
) > 0) and (len(Header
) > 0)):
838 line
= Name
+ "|" + os
.path
.join(path
, Header
)
839 if (options
.debug
and options
.verbose
> 2):
840 print "Adding:", line
841 HeaderLocations
.insert(0, line
)
845 IndStdHeaders
= "/PackageSurfaceArea/IndustryStdIncludes/IndustryStdHeader"
846 ishList
= XmlList(Spd
, IndStdHeaders
)
850 if (len(ishList
) > 0):
851 for Lc
in ishList
[:]:
854 Name
= str(Lc
.getAttribute("Name")).strip()
860 Header
= str(XmlElementData(Lc
.getElementsByTagName("IncludeHeader")[0])).strip()
864 if ((len(Name
) > 0) and (len(Header
) > 0)):
865 line
= Name
+ "|" + os
.path
.join(path
, Header
)
866 HeaderLocations
.insert(0, str(line
))
873 Pkgs
= "/ModuleSurfaceArea/PackageDependencies/Package"
876 pkgL
= XmlList(Msa
, Pkgs
)
883 if (options
.debug
and options
.verbose
> 1):
884 print "Found %s packages in the module" % (len(pkgL
))
892 Archs
= pkg
.getAttribute("SupArchList")
896 Archs
= chkArch(Archs
)
899 pkgGuid
= pkg
.getAttribute("PackageGuid")
904 if pkgGuid
.lower() == "5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec":
905 pkgGuid
= "1E73767F-8F52-4603-AEB4-F29B510B6766"
906 if pkgGuid
.lower() == "68169ab0-d41b-4009-9060-292c253ac43d":
907 pkgGuid
= "BA0D78D6-2CAF-414b-BD4D-B6762A894288"
908 AutoGenPackage
.append(pkgGuid
)
910 pkgVer
= pkg
.getAttribute("PackageVersion")
914 for PkgEntry
in PkgDb
[:]:
915 if pkgGuid
in PkgEntry
:
917 if pkgVer
in PkgEntry
:
920 PkgListIa32
.insert(0, PkgEntry
.split("|")[0])
922 PkgListX64
.insert(0, PkgEntry
.split("|")[0])
924 PkgListIpf
.insert(0, PkgEntry
.split("|")[0])
926 PkgListEbc
.insert(0, PkgEntry
.split("|")[0])
928 PkgList
.insert(0, PkgEntry
.split("|")[0])
932 PkgListIa32
.insert(0, PkgEntry
.split("|")[0])
934 PkgListX64
.insert(0, PkgEntry
.split("|")[0])
936 PkgListIpf
.insert(0, PkgEntry
.split("|")[0])
938 PkgListEbc
.insert(0, PkgEntry
.split("|")[0])
940 PkgList
.insert(0, PkgEntry
.split("|")[0])
943 gUnknownPkgGuid
[str(pkgGuid
)] = 1
945 for UnknownPkgGuid
in gUnknownPkgGuid
:
946 print "Cannot resolve package dependency Guid:", UnknownPkgGuid
949 PkgListIa32
.reverse()
954 print "Package List:", PkgList
958 """ Setup the Global GuidCName arrays that will hold data from various MSA locations """
970 """ Check for the GUIDs Element """
971 Guids
= "/ModuleSurfaceArea/Guids/GuidCNames"
974 GuidList
= XmlList(Msa
, Guids
)
978 if (len(GuidList
) > 0):
979 for Guid
in GuidList
:
985 Archs
= Guid
.getAttribute("SupArchList")
989 Archs
= chkArch(Archs
)
992 Usage
= Guid
.getAttribute("Usage")
997 CName
= str(XmlElementData(Guid
.getElementsByTagName("GuidCName")[0]))
998 if CName
in GuidDecls
:
999 if (options
.debug
and options
.verbose
> 1):
1000 print "Guids Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1001 AddGuid(Archs
, CName
, Usage
)
1002 AutoGenGuid
.append(CName
)
1004 raise AssertionError, "Guid %s defined in %s is not declared in any package (.dec) file!" % (CName
, filename
)
1008 if (options
.debug
and options
.verbose
> 2):
1009 print "Guid C Name List:", GuidCName
1011 """ Check for Events """
1012 Guids
= "/ModuleSurfaceArea/Events/CreateEvents/EventTypes"
1015 GuidList
= XmlList(Msa
, Guids
)
1019 if (len(GuidList
) > 0):
1020 for Guid
in GuidList
:
1026 Archs
= Guid
.getAttribute("SupArchList")
1030 Archs
= chkArch(Archs
)
1033 Usage
= Guid
.getAttribute("Usage")
1034 Type
= str(XmlElementData(Guid
.getElementsByTagName("EventType")[0]))
1035 Usage
+= " Create Event: " + Type
1040 CName
= str(Guid
.getAttribute("EventGuidCName"))
1041 if CName
in GuidDecls
:
1042 if (options
.debug
and options
.verbose
> 1):
1043 print "CreateEvent Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1044 AddGuid(Archs
, CName
, Usage
)
1045 AutoGenGuid
.append(CName
)
1047 if (len(DefinesComments
) == 0):
1048 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1049 DefinesComments
.append("# Create Event Guid C Name: " + CName
+ " Event Type: " + Type
+ "\n")
1055 DefinesComments
.append("#\n")
1058 Guids
= "/ModuleSurfaceArea/Events/SignalEvents/EventTypes"
1061 GuidList
= XmlList(Msa
, Guids
)
1065 if (len(GuidList
) > 0):
1066 for Guid
in GuidList
:
1072 Archs
= Guid
.getAttribute("SupArchList")
1076 Archs
= chkArch(Archs
)
1079 Usage
= Guid
.getAttribute("Usage")
1080 Type
= str(XmlElementData(Guid
.getElementsByTagName("EventType")[0]))
1081 Usage
+= " Signal Event: " + Type
1086 CName
= str(Guid
.getAttribute("EventGuidCName"))
1087 if CName
in GuidDecls
:
1088 if (options
.debug
and options
.verbose
> 1):
1089 print "SignalEvent Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1090 AddGuid(Archs
, CName
, Usage
)
1091 AutoGenGuid
.append(CName
)
1093 if (len(DefinesComments
) == 0):
1094 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1095 DefinesComments
.append("# Signal Event Guid C Name: " + CName
+ " Event Type: " + Type
+ "\n")
1101 DefinesComments
.append("#\n")
1104 """ Check the HOB guids """
1105 Guids
= "/ModuleSurfaceArea/Hobs/HobTypes"
1108 GuidList
= XmlList(Msa
, Guids
)
1112 if (len(GuidList
) > 0):
1113 for Guid
in GuidList
:
1119 Archs
= Guid
.getAttribute("SupArchList")
1123 Archs
= chkArch(Archs
)
1126 Usage
= Guid
.getAttribute("Usage")
1127 Type
= str(XmlElementData(Guid
.getElementsByTagName("HobType")[0]))
1128 Usage
+= " Hob: " + Type
1133 CName
= str(Guid
.getAttribute("HobGuidCName"))
1134 if CName
in GuidDecls
:
1135 if (options
.debug
and options
.verbose
> 1):
1136 print "Hob Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1137 AddGuid(Archs
, CName
, Usage
)
1138 AutoGenGuid
.append(CName
)
1140 if (len(DefinesComments
) == 0):
1141 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1142 DefinesComments
.append("# HOB Guid C Name: " + CName
+ " Hob Type: " + Type
+ "\n")
1145 if (len(DefinesComments
) == 0):
1146 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1147 DefinesComments
.append("# HOB: " + Type
+ "\n")
1152 DefinesComments
.append("#\n")
1155 """ Check for the SystemTables Element """
1156 Guids
= "/ModuleSurfaceArea/SystemTables/SystemTableCNames"
1159 GuidList
= XmlList(Msa
, Guids
)
1163 if (len(GuidList
) > 0):
1164 for Guid
in GuidList
:
1170 Archs
= Guid
.getAttribute("SupArchList")
1174 Archs
= chkArch(Archs
)
1177 Usage
= Guid
.getAttribute("Usage")
1178 Usage
+= " System Table"
1183 CName
= str(XmlElementData(Guid
.getElementsByTagName("SystemTableCName")[0]))
1184 if (options
.debug
and options
.verbose
> 1):
1185 print "System Table Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1186 AddGuid(Archs
, CName
, Usage
)
1187 AutoGenGuid
.append(CName
)
1191 """ Check for the DataHubs Element """
1192 Guids
= "/ModuleSurfaceArea/DataHubs/DataHubRecord"
1195 GuidList
= XmlList(Msa
, Guids
)
1199 if (len(GuidList
) > 0):
1200 for Guid
in GuidList
:
1206 Archs
= Guid
.getAttribute("SupArchList")
1210 Archs
= chkArch(Archs
)
1213 Usage
= Guid
.getAttribute("Usage")
1214 Usage
+= " Data Hub"
1219 CName
= str(XmlElementData(Guid
.getElementsByTagName("DataHubCName")[0]))
1220 if (options
.debug
and options
.verbose
> 1):
1221 print "Data Hub Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1222 AddGuid(Archs
, CName
, Usage
)
1223 AutoGenGuid
.append(CName
)
1227 """ Check for the HiiPackages Element """
1228 Guids
= "/ModuleSurfaceArea/HiiPackages/HiiPackage"
1231 GuidList
= XmlList(Msa
, Guids
)
1235 if (len(GuidList
) > 0):
1236 for Guid
in GuidList
:
1242 Archs
= Guid
.getAttribute("SupArchList")
1246 Archs
= chkArch(Archs
)
1249 Usage
= Guid
.getAttribute("Usage")
1250 Usage
+= " HII Formset"
1255 CName
= str(XmlElementData(Guid
.getElementsByTagName("HiiCName")[0]))
1256 if (options
.debug
and options
.verbose
> 1):
1257 print "Hii Formset Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1258 AddGuid(Archs
, CName
, Usage
)
1259 AutoGenGuid
.append(CName
)
1263 """ Check for the Variables Element """
1264 Guids
= "/ModuleSurfaceArea/Variables/Variable"
1267 GuidList
= XmlList(Msa
, Guids
)
1271 if (len(GuidList
) > 0):
1272 for Guid
in GuidList
:
1279 Archs
= Guid
.getAttribute("SupArchList")
1283 Archs
= chkArch(Archs
)
1286 Usage
= Guid
.getAttribute("Usage")
1291 VariableName
= str(XmlElementData(Guid
.getElementsByTagName("VariableName")[0]))
1292 CName
= str(XmlElementData(Guid
.getElementsByTagName("GuidC_Name")[0]))
1294 HexData
= VariableName
.strip().split()
1296 for dig
in HexData
[:]:
1297 UniString
+= str(unichr(eval(dig
)))
1302 if CName
in set(GuidDecls
):
1303 removeDups(CName
, GuidCName
)
1304 removeDups(CName
, GuidCNameIa32
)
1305 removeDups(CName
, GuidCNameX64
)
1306 removeDups(CName
, GuidCNameIPF
)
1307 removeDups(CName
, GuidCNameEBC
)
1310 print "Variable Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1311 AddGuid(Archs
, CName
, Usage
)
1312 AutoGenGuid
.append(CName
)
1314 if (len(DefinesComments
) == 0):
1315 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1316 DefinesComments
.append("# Variable Guid C Name: " + CName
+ " Variable Name:" + UniString
+ "\n")
1322 DefinesComments
.append("#\n")
1325 """ Check for the Protocol Element """
1326 Protocols
= "/ModuleSurfaceArea/Protocols/Protocol"
1329 ProtocolCNameIa32
= []
1330 ProtocolCNameX64
= []
1331 ProtocolCNameIPF
= []
1332 ProtocolCNameEBC
= []
1335 ProtocolList
= XmlList(Msa
, Protocols
)
1339 if (len(ProtocolList
) > 0):
1340 for Protocol
in ProtocolList
:
1346 Archs
= Protocol
.getAttribute("SupArchList")
1350 Archs
= chkArch(Archs
)
1353 Usage
= Protocol
.getAttribute("Usage")
1358 CName
= str(XmlElementData(Protocol
.getElementsByTagName("ProtocolCName")[0]))
1359 AutoGenGuid
.append(CName
)
1360 removeDups(CName
, GuidCName
)
1361 removeDups(CName
, GuidCNameIa32
)
1362 removeDups(CName
, GuidCNameX64
)
1363 removeDups(CName
, GuidCNameIPF
)
1364 removeDups(CName
, GuidCNameEBC
)
1366 if (options
.debug
and options
.verbose
> 1):
1367 print "Found %s - %s - %s " % (CName
, Usage
, str(len(Archs
)))
1370 ProtocolCNameIa32
.insert(0, str(" %-45s # PROTOCOL %s" % (CName
, Usage
)))
1372 ProtocolCNameX64
.insert(0, str(" %-45s # PROTOCOL %s" % (CName
, Usage
)))
1374 ProtocolCNameIPF
.insert(0, str(" %-45s # PROTOCOL %s" % (CName
, Usage
)))
1376 ProtocolCNameEBC
.insert(0, str(" %-45s # PROTOCOL %s" % (CName
, Usage
)))
1378 ProtocolCName
.insert(0, str(" %-45s # PROTOCOL %s" % (CName
, Usage
)))
1383 Protocols
= "/ModuleSurfaceArea/Protocols/ProtocolNotify"
1385 ProtocolList
= XmlList(Msa
, Protocols
)
1389 if (len(ProtocolList
) > 0):
1390 for Protocol
in ProtocolList
:
1396 Archs
= Protocol
.getAttribute("SupArchList")
1400 Archs
= chkArch(Archs
)
1403 Usage
= Protocol
.getAttribute("Usage")
1408 CName
= str(XmlElementData(Protocol
.getElementsByTagName("ProtocolNotifyCName")[0]))
1409 AutoGenGuid
.append(CName
)
1410 removeDups(CName
, GuidCName
)
1411 removeDups(CName
, GuidCNameIa32
)
1412 removeDups(CName
, GuidCNameX64
)
1413 removeDups(CName
, GuidCNameIPF
)
1414 removeDups(CName
, GuidCNameEBC
)
1417 ProtocolCNameIa32
.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName
, Usage
))
1419 ProtocolCNameX64
.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName
, Usage
))
1421 ProtocolCNameIPF
.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName
, Usage
))
1423 ProtocolCNameEBC
.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName
, Usage
))
1425 ProtocolCName
.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName
, Usage
))
1429 """ Check for the PPIs Element """
1430 PPIs
= "/ModuleSurfaceArea/PPIs/Ppi"
1439 PPIsList
= XmlList(Msa
, PPIs
)
1443 if (len(PPIsList
) > 0):
1444 for Ppi
in PPIsList
:
1450 Archs
= str(Ppi
.getAttribute("SupArchList"))
1454 Archs
= chkArch(Archs
)
1457 Usage
= str(Ppi
.getAttribute("Usage"))
1462 CName
= str(XmlElementData(Ppi
.getElementsByTagName("PpiCName")[0])).strip()
1463 AutoGenGuid
.append(CName
)
1464 removeDups(CName
, GuidCName
)
1465 removeDups(CName
, GuidCNameIa32
)
1466 removeDups(CName
, GuidCNameX64
)
1467 removeDups(CName
, GuidCNameIPF
)
1468 removeDups(CName
, GuidCNameEBC
)
1471 PpiCNameIa32
.insert(0, " %-45s # PPI %s" % (CName
, Usage
))
1473 PpiCNameX64
.insert(0, " %-45s # PPI %s" % (CName
, Usage
))
1475 PpiCNameIPF
.insert(0, " %-45s # PPI %s" % (CName
, Usage
))
1477 PpiCNameEBC
.insert(0, " %-45s # PPI %s" % (CName
, Usage
))
1479 PpiCName
.insert(0, " %-45s # PPI %s" % (CName
, Usage
))
1484 PPIs
= "/ModuleSurfaceArea/PPIs/PpiNotify"
1486 PPIsList
= XmlList(Msa
, PPIs
)
1490 if (len(PPIsList
) > 0):
1491 for Ppi
in PPIsList
:
1497 Archs
= Ppi
.getAttribute("SupArchList")
1501 Archs
= chkArch(Archs
)
1504 Usage
= Ppi
.getAttribute("Usage")
1509 CName
= str(XmlElementData(Ppi
.getElementsByTagName("PpiNotifyCName")[0]))
1510 AutoGenGuid
.append(CName
)
1511 removeDups(CName
, GuidCName
)
1512 removeDups(CName
, GuidCNameIa32
)
1513 removeDups(CName
, GuidCNameX64
)
1514 removeDups(CName
, GuidCNameIPF
)
1515 removeDups(CName
, GuidCNameEBC
)
1518 PpiCNameIa32
.insert(0, " %-45s # PPI_NOTIFY %s" % (CName
, Usage
))
1520 PpiCNameX64
.insert(0, " %-45s # PPI_NOTIFY %s" % (CName
, Usage
))
1522 PpiCNameIPF
.insert(0, " %-45s # PPI_NOTIFY %s" % (CName
, Usage
))
1524 PpiCNameEBC
.insert(0, " %-45s # PPI_NOTIFY %s" % (CName
, Usage
))
1526 PpiCName
.insert(0, " %-45s # PPI_NOTIFY %s" % (CName
, Usage
))
1531 """ Get the PCD entries now """
1532 PcdCoded
= "/ModuleSurfaceArea/PcdCoded/PcdEntry"
1535 PcdList
= XmlList(Msa
, PcdCoded
)
1539 (PcdFF
, PcdFFIa32
, PcdFFX64
, PcdFFIpf
, PcdFFEbc
) = ([],[],[],[],[])
1540 (PcdFAB
, PcdFABIa32
, PcdFABX64
, PcdFABIpf
, PcdFABEbc
) = ([],[],[],[],[])
1541 (PcdPIM
, PcdPIMIa32
, PcdPIMX64
, PcdPIMIpf
, PcdPIMEbc
) = ([],[],[],[],[])
1542 (PcdDY
, PcdDYIa32
, PcdDYX64
, PcdDYIpf
, PcdDYEbc
) = ([],[],[],[],[])
1543 (PcdDYE
, PcdDYEIa32
, PcdDYEX64
, PcdDYEIpf
, PcdDYEEbc
) = ([],[],[],[],[])
1545 if (len(PcdList
) > 0):
1553 Archs
= Pcd
.getAttribute("SupArchList")
1557 Archs
= chkArch(Archs
)
1560 ItemType
= Pcd
.getAttribute("PcdItemType")
1565 CName
= str(XmlElementData(Pcd
.getElementsByTagName("C_Name")[0]))
1567 raise SyntaxError, "ERROR: MSA has a PCD with no Pcd C_Name defined"
1570 TSGC
= str(XmlElementData(Pcd
.getElementsByTagName("TokenSpaceGuidCName")[0]))
1575 DefVal
= str(XmlElementData(Pcd
.getElementsByTagName("DefaultValue")))
1579 if (len(DefVal
) > 0):
1580 line
= TSGC
+ "." + CName
+ "|" + DefVal
1582 line
= TSGC
+ "." + CName
1584 if (ItemType
== "FEATURE_FLAG"):
1585 if ("IA32" in Archs
):
1586 PcdFFIa32
.insert(0, line
)
1587 if ("IPF" in Archs
):
1588 PcdFFIpf
.insert(0, line
)
1589 if ("X64" in Archs
):
1590 PcdFFX64
.insert(0, line
)
1591 if ("EBC" in Archs
):
1592 PcdFFEbc
.insert(0, line
)
1593 if ("ALL" in Archs
):
1594 PcdFF
.insert(0, line
)
1595 elif (ItemType
== "FIXED_AT_BUILD"):
1596 if ("IA32" in Archs
):
1597 PcdFABIa32
.insert(0, line
)
1598 if ("IPF" in Archs
):
1599 PcdFABIpf
.insert(0, line
)
1600 if ("X64" in Archs
):
1601 PcdFABX64
.insert(0, line
)
1602 if ("EBC" in Archs
):
1603 PcdFABEbc
.insert(0, line
)
1604 if ("ALL" in Archs
):
1605 PcdFAB
.insert(0, line
)
1606 elif (ItemType
== "PATCHABLE_IN_MODULE"):
1607 if ("IA32" in Archs
):
1608 PcdPIMIa32
.insert(0, line
)
1609 if ("IPF" in Archs
):
1610 PcdPIMIpf
.insert(0, line
)
1611 if ("X64" in Archs
):
1612 PcdPIMX64
.insert(0, line
)
1613 if ("EBC" in Archs
):
1614 PcdPIMEbc
.insert(0, line
)
1615 if ("ALL" in Archs
):
1616 PcdFAB
.insert(0, line
)
1617 elif (ItemType
== "DYNAMIC_EX"):
1618 if ("IA32" in Archs
):
1619 PcdDYEIa32
.insert(0, line
)
1620 if ("IPF" in Archs
):
1621 PcdDYEIpf
.insert(0, line
)
1622 if ("X64" in Archs
):
1623 PcdDYEX64
.insert(0, line
)
1624 if ("EBC" in Archs
):
1625 PcdDYEEbc
.insert(0, line
)
1626 if ("ALL" in Archs
):
1627 PcdDYE
.insert(0, line
)
1629 if ("IA32" in Archs
):
1630 PcdDYIa32
.insert(0, line
)
1631 if ("IPF" in Archs
):
1632 PcdDYIpf
.insert(0, line
)
1633 if ("X64" in Archs
):
1634 PcdDYX64
.insert(0, line
)
1635 if ("EBC" in Archs
):
1636 PcdDYEbc
.insert(0, line
)
1637 if ("ALL" in Archs
):
1638 PcdDY
.insert(0, line
)
1640 """ User Extensions Section """
1644 UESectionList
= XmlList(Msa
, "/ModuleSurfaceArea/UserExtensions")
1648 if (len(UESectionList
) > 0):
1649 for UE
in UESectionList
[:]:
1655 UserId
= str(UE
.getAttribute("UserID"))
1657 raise SyntaxError, "ERROR: Malformed MSA, No UserID Specified in UserExtensions element"
1660 Identifier
= str(UE
.getAttribute("Identifier"))
1662 raise SyntaxError, "ERROR: Malformed MSA, No Identifier Specified in UserExtensions element"
1665 print "FOUND A UE Element", UserId
, Identifier
1668 Value
= str(XmlElementData(UE
))
1672 Entry
= [UserId
, Identifier
, Value
]
1673 UEList
.insert(0, Entry
)
1677 if (len(Externlist
) > 0):
1679 AutoGenDefinitionSource
= ""
1680 AutoGenEntryPointSource
= ""
1681 AutoGenUnloadSource
= ""
1682 if (len(AutoGenDriverModel
) > 0):
1683 AutoGenCode
= AddDriverBindingProtocolStatement(AutoGenDriverModel
)
1684 AutoGenEntryPointSource
+= AutoGenCode
[0]
1685 AutoGenUnloadSource
+= AutoGenCode
[1]
1686 AutoGenDeclaration
+= AutoGenCode
[3]
1689 if (len(AutoGenExitBootServices
) > 0):
1690 print "[Warning] Please manually add Create Event statement for Exit Boot Service Event!"
1692 AutoGenCode
= AddBootServiceEventStatement(AutoGenExitBootServices
)
1693 AutoGenEntryPointSource
+= AutoGenCode
[0]
1694 AutoGenUnloadSource
+= AutoGenCode
[1]
1695 AutoGenDefinitionSource
+= AutoGenCode
[2]
1696 AutoGenDeclaration
+= AutoGenCode
[3]
1698 if (len(AutoGenVirtualAddressChanged
) > 0):
1699 print "[Warning] Please manually add Create Event statement for Virtual Address Change Event!"
1701 AutoGenCode
= AddVirtualAddressEventStatement(AutoGenVirtualAddressChanged
)
1702 AutoGenEntryPointSource
+= AutoGenCode
[0]
1703 AutoGenUnloadSource
+= AutoGenCode
[1]
1704 AutoGenDefinitionSource
+= AutoGenCode
[2]
1705 AutoGenDeclaration
+= AutoGenCode
[3]
1707 if AutoGenEntryPointSource
!= "":
1708 OldEntryPoint
= AutoGenEntryPoint
1709 AutoGenCode
= AddNewEntryPointContentsStatement(BaseName
, AutoGenEntryPoint
, AutoGenEntryPointSource
)
1710 AutoGenEntryPoint
= AutoGenCode
[0]
1711 AutoGenEntryPointSource
= AutoGenCode
[1]
1712 AutoGenDeclaration
+= AutoGenCode
[2]
1715 if AutoGenEntryPoint
!= "":
1716 DriverModules
.insert(0, " %-30s = %s\n" % ("ENTRY_POINT" , AutoGenEntryPoint
))
1718 AutoGenSource
= AutoGenDefinitionSource
+ AutoGenEntryPointSource
+ AutoGenUnloadSource
1721 DefinesComments
.append("#\n")
1723 if (Flag
and len(DefinesComments
) > 0):
1724 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1726 if (options
.debug
and options
.verbose
> 2):
1727 if (len(DriverModules
) > 0):
1729 if (len(LibraryModules
) > 0):
1730 print LibraryModules
1731 if (len(DefinesComments
) > 0):
1732 print DefinesComments
1740 for DxsFile
, Archs
in AutoGenDxsFiles
:
1741 fileContents
= openSourceFile(AutoGenModuleFolder
, DxsFile
)
1742 Contents
, Unresolved
= TranslateDpxSection(fileContents
)
1744 print "[warning] Cannot read dxs expression"
1746 if (len(Unresolved
) > 0):
1747 print "[warning] Guid Macro(s): %s cannot find corresponding cNames. Please resolve it in [depex] section in extened inf" % ",".join(Unresolved
)
1749 if ("IA32" in Archs
):
1750 DepexIa32
.insert(0, Contents
)
1751 if ("IPF" in Archs
):
1752 DepexIpf
.insert(0, Contents
)
1753 if ("X64" in Archs
):
1754 DepexX64
.insert(0, Contents
)
1755 if ("EBC" in Archs
):
1756 DepexEbc
.insert(0, Contents
)
1757 if ("ALL" in Archs
):
1758 Depex
.insert(0, Contents
)
1760 AutoGenSourceHeaderFormat
= "/**@file\n %s\n\n %s\n %s\n %s\n**/\n\n%s"
1761 includeCommonHeaderFileStatement
= "#include \"%s\"" % commonHeaderFilename
1763 AutoGenHeader
+= AddSystemIncludeStatement(ModType
, AutoGenPackage
)
1764 AutoGenHeader
+= AddGuidStatement(AutoGenGuid
)
1765 AutoGenHeader
+= AddLibraryClassStatement(AutoGenLibClass
)
1768 saveSourceFile(AutoGenModuleFolder
, "CommonHeader.txt", AutoGenHeader
)
1771 commonHeaderFilename2
= re
.sub("(?=[^a-z])", "_", commonHeaderFilename
)
1772 commonHeaderFilename2
= "_" + commonHeaderFilename2
.replace(".", "").upper() + "_"
1773 briefDiscription
= "Common header file shared by all source files."
1774 detailedDiscription
= "This file includes package header files, library classes and protocol, PPI & GUID definitions.\n"
1775 AutoGenHeader
+= AutoGenDeclaration
1776 AutoGenHeader
= "#ifndef %s\n#define %s\n\n\n%s\n#endif\n" % (commonHeaderFilename2
, commonHeaderFilename2
, AutoGenHeader
)
1777 AutoGenHeader
= AutoGenSourceHeaderFormat
% (briefDiscription
, detailedDiscription
, CopyRight
, License
, AutoGenHeader
)
1778 saveSourceFile(AutoGenModuleFolder
, commonHeaderFilename
, AutoGenHeader
)
1779 SrcFilenames
.append(commonHeaderFilename
)
1781 for source
in AutoGenSourceFiles
:
1782 extension
= os
.path
.splitext(source
)[1]
1783 if extension
== ".c":
1784 sourceContents
= openSourceFile(AutoGenModuleFolder
, source
)
1785 sourceContents
= AddCommonInclusionStatement(sourceContents
, includeCommonHeaderFileStatement
)
1786 saveSourceFile(AutoGenModuleFolder
, source
, sourceContents
)
1789 if AutoGenSource
!= "":
1790 briefDiscription
= "Entry Point Source file."
1791 detailedDiscription
= "This file contains the user entry point \n"
1792 AutoGenSource
= AutoGenSourceHeaderFormat
% (briefDiscription
, detailedDiscription
, CopyRight
, License
, AutoGenSource
)
1793 AutoGenSource
= AddCommonInclusionStatement(AutoGenSource
, includeCommonHeaderFileStatement
)
1795 saveSourceFile(AutoGenModuleFolder
, entryPointFilename
, AutoGenSource
)
1796 SrcFilenames
.append(entryPointFilename
)
1801 # DONE Getting data, now output it in INF format.
1806 """ Print the converted data format """
1807 head
= "#/** @file\n"
1808 head
+= "# " + str(Abstract
) + "\n#\n"
1809 head
+= "# " + str(Description
).strip().replace("\n", "\n# ") + "\n"
1810 head
+= "# " + str(CopyRight
) + "\n#\n"
1811 head
+= "# " + str(License
).replace("\n", "\n# ").replace(" ", " ").strip() + "\n#\n"
1818 ## Defines = "\n" + "#"*80+ "\n#\n"
1819 ## if (BinModule != "false"):
1820 ## Defines += "# Defines Section - statements that will be processed to generate a binary image.\n"
1822 ## Defines += "# Defines Section - statements that will be processed to create a Makefile.\n"
1823 ## Defines += "#\n" + "#"*80 + "\n"
1826 Defines
+= "[Defines]\n"
1827 Defines
+= " %-30s = %s\n" % ("INF_VERSION", "0x00010005")
1828 Defines
+= " %-30s = %s\n" % ("BASE_NAME", BaseName
)
1829 Defines
+= " %-30s = %s\n" % ("FILE_GUID", GuidValue
)
1830 Defines
+= " %-30s = %s\n" % ("MODULE_TYPE", ModType
)
1831 Defines
+= " %-30s = %s\n" % ("VERSION_STRING", VerString
)
1833 if (len(PcdIsDriver
) > 0):
1834 Defines
+= " %-30s = %s\n" % ("PCD_DRIVER", PcdIsDriver
)
1836 if (len(IamLibrary
) > 0):
1838 for lc
in IamLibrary
[:]:
1840 Defines
+= " %-30s = %s" % ("LIBRARY_CLASS", lcstr
)
1843 if (len(SpecList
) > 0):
1844 for spec
in SpecList
[:]:
1845 (specname
, specval
) = spec
.split()
1846 Defines
+= " %-30s = %s\n" % (specname
, specval
)
1849 if (len(DriverModules
) > 0):
1850 for line
in DriverModules
[:]:
1853 if (len(LibraryModules
) > 0):
1854 for line
in LibraryModules
[:]:
1857 if (len(DefinesComments
) > 0):
1858 for line
in DefinesComments
[:]:
1861 Output
.append(Defines
)
1866 if (BinModule
!= "false"):
1867 """ Binary Module, so sources are really binaries. """
1868 ## Sources = "\n" + "#"*80 + "\n#\n"
1869 ## Sources += "# Binaries Section - list of binary files that are required for the build\n# to succeed.\n"
1870 ## Sources += "#\n" + "#"*80 + "\n\n"
1872 if ModType
== "UEFI_APPLICATION":
1873 FileType
= "UEFI_APP"
1874 if options
.verbose
> 0:
1875 print "WARNING: Binary Module: %s is assuming UEFI_APPLICATION file type." % (options
.filename
)
1878 if options
.verbose
> 0:
1879 print "WARNING: Binary Module: %s is assuming FV file type." % (options
.filename
)
1881 if (len(SrcFilenames
) > 0):
1882 Sources
+= "[Binaries.common]\n"
1883 for file in SrcFilenames
[:]:
1884 file = file.replace("\\", "/")
1885 Sources
+= " " + FileType
+ "|" + file + "\n"
1888 if (len(SrcFilenamesIa32
) > 0):
1889 Sources
+= "[Binaries.Ia32]\n"
1890 for file in SrcFilenamesIa32
[:]:
1891 file = file.replace("\\", "/")
1892 Sources
+= " " + FileType
+ "|" + file + "\n"
1895 if (len(SrcFilenamesX64
) > 0):
1896 Sources
+= "[Binaries.X64]\n"
1897 for file in SrcFilenamesX64
[:]:
1898 file = file.replace("\\", "/")
1899 Sources
+= " " + FileType
+ "|" + file + "\n"
1902 if (len(SrcFilenamesIpf
) > 0):
1903 Sources
+= "[Binaries.IPF]\n"
1904 for file in SrcFilenamesIpf
[:]:
1905 file = file.replace("\\", "/")
1906 Sources
+= " " + FileType
+ "|" + file + "\n"
1909 if (len(SrcFilenamesEbc
) > 0):
1910 Sources
+= "[Binaries.EBC]\n"
1911 for file in SrcFilenamesEbc
[:]:
1912 file = file.replace("\\", "/")
1913 Sources
+= " " + FileType
+ "|" + file + "\n"
1916 Output
.append(Sources
)
1920 ## Sources = "\n" + "#"*80 + "\n#\n"
1921 ## Sources += "# Sources Section - list of files that are required for the build to succeed.\n"
1922 ## Sources += "#\n" + "#"*80 + "\n\n"
1924 if (len(SrcFilenames
) > 0):
1925 Sources
+= "[Sources.common]\n"
1926 for file in SrcFilenames
[:]:
1927 Sources
+= " " + file + "\n"
1930 if (len(SrcFilenamesIa32
) > 0):
1931 Sources
+= "[Sources.Ia32]\n"
1932 for file in SrcFilenamesIa32
[:]:
1933 Sources
+= " " + file + "\n"
1936 if (len(SrcFilenamesX64
) > 0):
1937 Sources
+= "[Sources.X64]\n"
1938 for file in SrcFilenamesX64
[:]:
1939 Sources
+= " " + file + "\n"
1942 if (len(SrcFilenamesIpf
) > 0):
1943 Sources
+= "[Sources.IPF]\n"
1944 for file in SrcFilenamesIpf
[:]:
1945 Sources
+= " " + file + "\n"
1948 if (len(SrcFilenamesEbc
) > 0):
1949 Sources
+= "[Sources.EBC]\n"
1950 for file in SrcFilenamesEbc
[:]:
1951 Sources
+= " " + file + "\n"
1954 Output
.append(Sources
)
1960 if ((len(HeaderLocations
) > 0) or (len(Dirs
) > 0)):
1961 allLcs
= set(LibClassList
+ LibClassListIa32
+ LibClassListX64
+ LibClassListIpf
+ LibClassListEbc
+ Dirs
)
1963 for line
in HeaderLocations
[:]:
1965 (keyword
, header
) = line
.split("|")
1968 print "FOUND", Lc
, "in", keyword
, "header", header
1969 path
= "$(WORKSPACE)/" + os
.path
.split(header
)[0]
1970 Lines
.insert(0, path
.strip())
1972 ## Includes = "\n" + "#"*80 + "\n#\n"
1973 ## Includes += "# Includes Section - list of Include locations that are required for\n"
1974 ## Includes += "# this module.\n"
1975 ## Includes += "#\n" + "#"*80 + "\n\n"
1976 ## Includes += "[Includes]\n"
1977 ## includeLines = []
1978 ## includeLines = set(Lines)
1979 ## if (options.debug):
1980 ## print "There are", len(includeLines), "entries"
1981 ## for Line in includeLines:
1982 ## Includes += " " + str(Line).strip().replace("\\", "/") + "\n"
1984 Output
.append(Includes
)
1990 if ((len(PkgList
) + len(PkgListIa32
) + len(PkgListX64
) + len(PkgListIpf
) + len(PkgListEbc
)) > 0):
1991 """ We do this if and only if we have Package Dependencies """
1992 ## PackageDepends = "\n" + "#"*80 + "\n#\n"
1993 ## PackageDepends += "# Package Dependency Section - list of Package files that are required for\n"
1994 ## PackageDepends += "# this module.\n"
1995 ## PackageDepends += "#\n" + "#"*80 + "\n\n"
1996 PackageDepends
= "\n"
1997 if (len(PkgList
) > 0):
1998 PackageDepends
+= "[Packages]\n"
1999 for lc
in PkgList
[:]:
2000 lc
= lc
.replace("\\", "/")
2001 PackageDepends
+= " " + lc
+ "\n"
2002 PackageDepends
+= "\n"
2004 if (len(PkgListIa32
) > 0):
2005 PackageDepends
+= "[Packages.IA32]\n"
2006 for lc
in PkgListIa32
[:]:
2007 lc
= lc
.replace("\\", "/")
2008 PackageDepends
+= " " + lc
+ "\n"
2009 PackageDepends
+= "\n"
2011 if (len(PkgListX64
) > 0):
2012 PackageDepends
+= "[Packages.X64]\n"
2013 for lc
in PkgListX64
[:]:
2014 lc
= lc
.replace("\\", "/")
2015 PackageDepends
+= " " + lc
+ "\n"
2016 PackageDepends
+= "\n"
2018 if (len(PkgListIpf
) > 0):
2019 PackageDepends
+= "[Packages.IPF]\n"
2020 for lc
in PkgListIpf
[:]:
2021 lc
= lc
.replace("\\", "/")
2022 PackageDepends
+= " " + lc
+ "\n"
2023 PackageDepends
+= "\n"
2025 if (len(PkgListEbc
) > 0):
2026 PackageDepends
+= "[Packages.EBC]\n"
2027 for lc
in PkgListEbc
[:]:
2028 lc
= lc
.replace("\\", "/")
2029 PackageDepends
+= " " + lc
+ "\n"
2030 PackageDepends
+= "\n"
2032 Output
.append(PackageDepends
)
2034 print PackageDepends
2036 if ((len(LibClassList
) + len(LibClassListIa32
) + len(LibClassListX64
) + len(LibClassListIpf
) + len(LibClassListEbc
)) > 0):
2037 ## LibraryClasses = "\n" + "#"*80 + "\n#\n"
2038 ## LibraryClasses += "# Library Class Section - list of Library Classes that are required for\n"
2039 ## LibraryClasses += "# this module.\n"
2040 ## LibraryClasses += "#\n" + "#"*80 + "\n\n"
2042 LibraryClasses
= "\n"
2043 if (len(LibClassList
) > 0):
2044 LibraryClasses
+= "[LibraryClasses]\n"
2045 for lc
in LibClassList
[:]:
2046 LibraryClasses
+= " " + lc
+ "\n"
2047 LibraryClasses
+= "\n"
2049 if (len(LibClassListIa32
) > 0):
2050 LibraryClasses
+= "[LibraryClasses.IA32]\n"
2051 for lc
in LibClassListIa32
[:]:
2052 LibraryClasses
+= " " + lc
+ "\n"
2053 LibraryClasses
+= "\n"
2055 if (len(LibClassListX64
) > 0):
2056 LibraryClasses
+= "[LibraryClasses.X64]\n"
2057 for lc
in LibClassListX64
[:]:
2058 LibraryClasses
+= " " + lc
+ "\n"
2059 LibraryClasses
+= "\n"
2061 if (len(LibClassListIpf
) > 0):
2062 LibraryClasses
+= "[LibraryClasses.IPF]\n"
2063 for lc
in LibClassListIpf
[:]:
2064 LibraryClasses
+= " " + lc
+ "\n"
2065 LibraryClasses
+= "\n"
2067 if (len(LibClassListEbc
) > 0):
2068 LibraryClasses
+= "[LibraryClasses.EBC]\n"
2069 for lc
in LibClassListEbc
[:]:
2070 LibraryClasses
+= " " + lc
+ "\n"
2071 LibraryClasses
+= "\n"
2073 Output
.append(LibraryClasses
)
2075 print LibraryClasses
2077 # Print the Guids sections
2078 if (len(GuidCName
) + len(GuidCNameIa32
) + len(GuidCNameIPF
) + len(GuidCNameX64
) + len(GuidCNameEBC
)) > 0:
2079 ## GuidSection = "\n" + "#"*80 + "\n#\n"
2080 ## GuidSection += "# Guid C Name Section - list of Guids that this module uses or produces.\n"
2081 ## GuidSection += "#\n" + "#"*80 + "\n\n"
2083 if (len(GuidCName
) > 0):
2084 GuidSection
+= "[Guids]\n"
2085 for Guid
in GuidCName
[:]:
2086 GuidSection
+= Guid
+ "\n"
2089 if (len(GuidCNameIa32
) > 0):
2090 GuidSection
+= "[Guids.IA32]\n"
2091 for Guid
in GuidCNameIa32
[:]:
2092 GuidSection
+= Guid
+ "\n"
2095 if (len(GuidCNameX64
) > 0):
2096 GuidSection
+= "[Guids.X64]\n"
2097 for Guid
in GuidCNameX64
[:]:
2098 GuidSection
+= Guid
+ "\n"
2101 if (len(GuidCNameIPF
) > 0):
2102 GuidSection
+= "[Guids.IPF]\n"
2103 for Guid
in GuidCNameIPF
[:]:
2104 GuidSection
+= Guid
+ "\n"
2107 if (len(GuidCNameEBC
) > 0):
2108 GuidSection
+= "[Guids.EBC]\n"
2109 for Guid
in GuidCNameEBC
[:]:
2110 GuidSection
+= Guid
+ "\n"
2113 Output
.append(GuidSection
)
2114 if (options
.debug
and options
.verbose
> 1):
2117 # Print the Protocol sections
2118 if (len(ProtocolCName
) + len(ProtocolCNameIa32
) + len(ProtocolCNameIPF
) + len(ProtocolCNameX64
) + len(ProtocolCNameEBC
)) > 0:
2119 ## ProtocolsSection = "\n" + "#"*80 + "\n#\n"
2120 ## ProtocolsSection += "# Protocol C Name Section - list of Protocol and Protocol Notify C Names\n"
2121 ## ProtocolsSection += "# that this module uses or produces.\n"
2122 ## ProtocolsSection += "#\n" + "#"*80 + "\n\n"
2124 ProtocolsSection
= "\n"
2125 if (len(ProtocolCName
) > 0):
2126 ProtocolsSection
+= "[Protocols]\n"
2127 for Guid
in ProtocolCName
[:]:
2128 ProtocolsSection
+= Guid
+ "\n"
2129 ProtocolsSection
+= "\n"
2131 if (len(ProtocolCNameIa32
) > 0):
2132 ProtocolsSection
+= "[Protocols.IA32]\n"
2133 for Guid
in ProtocolCNameIa32
[:]:
2134 ProtocolsSection
+= Guid
+ "\n"
2135 ProtocolsSection
+= "\n"
2137 if (len(ProtocolCNameX64
) > 0):
2138 ProtocolsSection
+= "[Protocols.X64]\n"
2139 for Guid
in ProtocolCNameX64
[:]:
2140 ProtocolsSection
+= Guid
+ "\n"
2141 ProtocolsSection
+= "\n"
2143 if (len(ProtocolCNameIPF
) > 0):
2144 ProtocolsSection
+= "[Protocols.IPF]\n"
2145 for Guid
in ProtocolCNameIPF
[:]:
2146 ProtocolsSection
+= Guid
+ "\n"
2147 ProtocolsSection
+= "\n"
2149 if (len(ProtocolCNameEBC
) > 0):
2150 ProtocolsSection
+= "[Protocols.EBC]\n"
2151 for Guid
in ProtocolCNameEBC
[:]:
2152 ProtocolsSection
+= Guid
+ "\n"
2153 ProtocolsSection
+= "\n"
2155 Output
.append(ProtocolsSection
)
2157 print ProtocolsSection
2159 # Print the PPI sections
2160 if (len(PpiCName
) + len(PpiCNameIa32
) + len(PpiCNameIPF
) + len(PpiCNameX64
) + len(PpiCNameEBC
)) > 0:
2161 ## PpiSection = "\n" + "#"*80 + "\n#\n"
2162 ## PpiSection += "# PPI C Name Section - list of PPI and PPI Notify C Names that this module\n"
2163 ## PpiSection += "# uses or produces.\n"
2164 ## PpiSection += "#\n" + "#"*80 + "\n\n"
2167 if (len(PpiCName
) > 0):
2168 PpiSection
+= "[Ppis]\n"
2169 for Guid
in PpiCName
[:]:
2170 PpiSection
+= Guid
+ "\n"
2173 if (len(PpiCNameIa32
) > 0):
2174 PpiSection
+= "[Ppis.IA32]\n"
2175 for Guid
in PpiCNameIa32
[:]:
2176 PpiSection
+= Guid
+ "\n"
2179 if (len(PpiCNameX64
) > 0):
2180 PpiSection
+= "[Ppis.X64]\n"
2181 for Guid
in PpiCNameX64
[:]:
2182 PpiSection
+= Guid
+ "\n"
2185 if (len(PpiCNameIPF
) > 0):
2186 PpiSection
+= "[Ppis.IPF]\n"
2187 for Guid
in PpiCNameIPF
[:]:
2188 PpiSection
+= Guid
+ "\n"
2191 if (len(PpiCNameEBC
) > 0):
2192 PpiSection
+= "[Ppis.EBC]\n"
2193 for Guid
in PpiCNameEBC
[:]:
2194 PpiSection
+= Guid
+ "\n"
2197 Output
.append(PpiSection
)
2201 # Print the PCD sections
2202 if ((len(PcdFF
)+len(PcdFFIa32
)+len(PcdFFX64
)+len(PcdFFIpf
)+len(PcdFFEbc
)) > 0):
2203 ## FeatureFlagSection = "\n" + "#"*80 + "\n#\n"
2204 ## FeatureFlagSection += "# Pcd FEATURE_FLAG - list of PCDs that this module is coded for.\n"
2205 ## FeatureFlagSection += "#\n" + "#"*80 + "\n\n"
2207 FeatureFlagSection
= "\n"
2208 if (len(PcdFF
) > 0):
2209 FeatureFlagSection
+= "[FeaturePcd.common]\n"
2210 for Entry
in PcdFF
[:]:
2211 FeatureFlagSection
+= " " + Entry
+ "\n"
2212 FeatureFlagSection
+= "\n"
2213 if (len(PcdFFIa32
) > 0):
2214 FeatureFlagSection
+= "[FeaturePcd.IA32]\n"
2215 for Entry
in PcdFFIa32
[:]:
2216 FeatureFlagSection
+= " " + Entry
+ "\n"
2217 FeatureFlagSection
+= "\n"
2218 if (len(PcdFFX64
) > 0):
2219 FeatureFlagSection
+= "[FeaturePcd.X64]\n"
2220 for Entry
in PcdFFX64
[:]:
2221 FeatureFlagSection
+= " " + Entry
+ "\n"
2222 FeatureFlagSection
+= "\n"
2223 if (len(PcdFFIpf
) > 0):
2224 FeatureFlagSection
+= "[PcdsFeatureFlag.IPF]\n"
2225 for Entry
in PcdFFIpf
[:]:
2226 FeatureFlagSection
+= " " + Entry
+ "\n"
2227 FeatureFlagSection
+= "\n"
2228 if (len(PcdFFEbc
) > 0):
2229 FeatureFlagSection
+= "[FeaturePcd.EBC]\n"
2230 for Entry
in PcdFFEbc
[:]:
2231 FeatureFlagSection
+= " " + Entry
+ "\n"
2232 FeatureFlagSection
+= "\n"
2234 Output
.append(FeatureFlagSection
)
2236 print FeatureFlagSection
2238 if ((len(PcdFAB
)+len(PcdFABIa32
)+len(PcdFABX64
)+len(PcdFABIpf
)+len(PcdFABEbc
)) > 0):
2239 ## FixedAtBuildSection = "\n" + "#"*80 + "\n#\n"
2240 ## FixedAtBuildSection += "# Pcd FIXED_AT_BUILD - list of PCDs that this module is coded for.\n"
2241 ## FixedAtBuildSection += "#\n" + "#"*80 + "\n\n"
2243 FixedAtBuildSection
= "\n"
2244 if (len(PcdFAB
) > 0):
2245 FixedAtBuildSection
+= "[FixedPcd.common]\n"
2246 for Entry
in PcdFAB
[:]:
2247 FixedAtBuildSection
+= " " + Entry
+ "\n"
2248 FixedAtBuildSection
+= "\n"
2249 if (len(PcdFABIa32
) > 0):
2250 FixedAtBuildSection
+= "[FixedPcd.IA32]\n"
2251 for Entry
in PcdFABIa32
[:]:
2252 FixedAtBuildSection
+= " " + Entry
+ "\n"
2253 FixedAtBuildSection
+= "\n"
2254 if (len(PcdFABX64
) > 0):
2255 FixedAtBuildSection
+= "[FixedPcd.X64]\n"
2256 for Entry
in PcdFABX64
[:]:
2257 FixedAtBuildSection
+= " " + Entry
+ "\n"
2258 FixedAtBuildSection
+= "\n"
2259 if (len(PcdFABIpf
) > 0):
2260 FixedAtBuildSection
+= "[FixedPcd.IPF]\n"
2261 for Entry
in PcdFABIpf
[:]:
2262 FixedAtBuildSection
+= " " + Entry
+ "\n"
2263 FixedAtBuildSection
+= "\n"
2264 if (len(PcdFABEbc
) > 0):
2265 FixedAtBuildSection
+= "[FixedPcd.EBC]\n"
2266 for Entry
in PcdFABEbc
[:]:
2267 FixedAtBuildSection
+= " " + Entry
+ "\n"
2268 FixedAtBuildSection
+= "\n"
2270 Output
.append(FixedAtBuildSection
)
2272 print FixedAtBuildSection
2274 if ((len(PcdPIM
)+len(PcdPIMIa32
)+len(PcdPIMX64
)+len(PcdPIMIpf
)+len(PcdPIMEbc
)) > 0):
2275 ## PatchableInModuleSection = "\n" + "#"*80 + "\n#\n"
2276 ## PatchableInModuleSection += "# Pcd PATCHABLE_IN_MODULE - list of PCDs that this module is coded for.\n"
2277 ## PatchableInModuleSection += "#\n" + "#"*80 + "\n\n"
2279 PatchableInModuleSection
= "\n"
2280 if (len(PcdPIM
) > 0):
2281 PatchableInModuleSection
+= "[PatchPcd.common]\n"
2282 for Entry
in PcdPIM
[:]:
2283 PatchableInModuleSection
+= " " + Entry
+ "\n"
2284 PatchableInModuleSection
+= "\n"
2285 if (len(PcdPIMIa32
) > 0):
2286 PatchableInModuleSection
+= "[PatchPcd.IA32]\n"
2287 for Entry
in PcdPIMIa32
[:]:
2288 PatchableInModuleSection
+= " " + Entry
+ "\n"
2289 PatchableInModuleSection
+= "\n"
2290 if (len(PcdPIMX64
) > 0):
2291 PatchableInModuleSection
+= "[PatchPcd.X64]\n"
2292 for Entry
in PcdPIMX64
[:]:
2293 PatchableInModuleSection
+= " " + Entry
+ "\n"
2294 PatchableInModuleSection
+= "\n"
2295 if (len(PcdPIMIpf
) > 0):
2296 PatchableInModuleSection
+= "[PatchPcd.IPF]\n"
2297 for Entry
in PcdPIMIpf
[:]:
2298 PatchableInModuleSection
+= " " + Entry
+ "\n"
2299 PatchableInModuleSection
+= "\n"
2300 if (len(PcdPIMEbc
) > 0):
2301 PatchableInModuleSection
+= "[PatchPcd.EBC]\n"
2302 for Entry
in PcdPIMEbc
[:]:
2303 PatchableInModuleSection
+= " " + Entry
+ "\n"
2304 PatchableInModuleSection
+= "\n"
2306 Output
.append(PatchableInModuleSection
)
2308 print PatchableInModuleSection
2310 if ((len(PcdDYE
)+len(PcdDYEIa32
)+len(PcdDYEX64
)+len(PcdDYEIpf
)+len(PcdDYEEbc
)) > 0):
2311 ## DynamicExSection = "\n" + "#"*80 + "\n#\n"
2312 ## DynamicExSection += "# Pcd DYNAMIC_EX - list of PCDs that this module is coded for.\n"
2313 ## DynamicExSection += "#\n" + "#"*80 + "\n\n"
2315 DynamicExSection
= "\n"
2316 if (len(PcdDYE
) > 0):
2317 DynamicExSection
+= "[PcdEx.common]\n"
2318 for Entry
in PcdDYE
[:]:
2319 DynamicExSection
+= " " + Entry
+ "\n"
2320 DynamicExSection
+= "\n"
2321 if (len(PcdDYEIa32
) > 0):
2322 DynamicExSection
+= "[PcdEx.IA32]\n"
2323 for Entry
in PcdDYEIa32
[:]:
2324 DynamicExSection
+= " " + Entry
+ "\n"
2325 DynamicExSection
+= "\n"
2326 if (len(PcdDYEX64
) > 0):
2327 DynamicExSection
+= "[PcdEx.X64]\n"
2328 for Entry
in PcdDYEX64
[:]:
2329 DynamicExSection
+= " " + Entry
+ "\n"
2330 DynamicExSection
+= "\n"
2331 if (len(PcdDYEIpf
) > 0):
2332 DynamicExSection
+= "[PcdEx.IPF]\n"
2333 for Entry
in PcdDYEIpf
[:]:
2334 DynamicExSection
+= " " + Entry
+ "\n"
2335 DynamicExSection
+= "\n"
2336 if (len(PcdDYEEbc
) > 0):
2337 DynamicExSection
+= "[PcdEx.EBC]\n"
2338 for Entry
in PcdDYEEbc
[:]:
2339 DynamicExSection
+= " " + Entry
+ "\n"
2340 DynamicExSection
+= "\n"
2342 Output
.append(DynamicExSection
)
2344 print DynamicExSection
2346 if ((len(PcdDY
)+len(PcdDYIa32
)+len(PcdDYX64
)+len(PcdDYIpf
)+len(PcdDYEbc
)) > 0):
2347 ## DynamicSection = "\n" + "#"*80 + "\n#\n"
2348 ## DynamicSection += "# Pcd DYNAMIC - list of PCDs that this module is coded for.\n"
2349 ## DynamicSection += "#\n" + "#"*80 + "\n\n"
2351 DynamicSection
= "\n"
2352 if (len(PcdDY
) > 0):
2353 DynamicSection
+= "[Pcd.common]\n"
2354 for Entry
in PcdDY
[:]:
2355 DynamicSection
+= " " + Entry
+ "\n"
2356 DynamicSection
+= "\n"
2357 if (len(PcdDYIa32
) > 0):
2358 DynamicSection
+= "[Pcd.IA32]\n"
2359 for Entry
in PcdDYIa32
[:]:
2360 DynamicSection
+= " " + Entry
+ "\n"
2361 DynamicSection
+= "\n"
2362 if (len(PcdDYX64
) > 0):
2363 DynamicSection
+= "[Pcd.X64]\n"
2364 for Entry
in PcdDYX64
[:]:
2365 DynamicSection
+= " " + Entry
+ "\n"
2366 DynamicSection
+= "\n"
2367 if (len(PcdDYIpf
) > 0):
2368 DynamicSection
+= "[Pcd.IPF]\n"
2369 for Entry
in PcdDYIpf
[:]:
2370 DynamicSection
+= " " + Entry
+ "\n"
2371 DynamicSection
+= "\n"
2372 if (len(PcdDYEbc
) > 0):
2373 DynamicSection
+= "[Pcd.EBC]\n"
2374 for Entry
in PcdDYEbc
[:]:
2375 DynamicSection
+= " " + Entry
+ "\n"
2376 DynamicSection
+= "\n"
2378 Output
.append(DynamicSection
)
2380 print DynamicSection
2382 if ((len(Depex
) + len(DepexIa32
) + len(DepexX64
) + len(DepexIpf
) + len(DepexEbc
)) > 0):
2383 """ We do this if and only if we have Package Dependencies """
2384 ## Dpx = "\n" + "#"*80 + "\n#\n"
2385 ## Dpx += "# Dependency Expression Section - list of Dependency expressions that are required for\n"
2386 ## Dpx += "# this module.\n"
2387 ## Dpx += "#\n" + "#"*80 + "\n\n"
2389 if (len(Depex
) > 0):
2392 Dpx
+= " " + lc
+ "\n"
2395 if (len(DepexIa32
) > 0):
2396 Dpx
+= "[Depex.IA32]\n"
2397 for lc
in DepexIa32
[:]:
2398 Dpx
+= " " + lc
+ "\n"
2401 if (len(DepexX64
) > 0):
2402 Dpx
+= "[Depex.X64]\n"
2403 for lc
in DepexX64
[:]:
2404 Dpx
+= " " + lc
+ "\n"
2407 if (len(DepexIpf
) > 0):
2408 Dpx
+= "[Depex.IPF]\n"
2409 for lc
in DepexIpf
[:]:
2410 Dpx
+= " " + lc
+ "\n"
2413 if (len(DepexEbc
) > 0):
2414 Dpx
+= "[Depex.EBC]\n"
2415 for lc
in DepexEbc
[:]:
2416 Dpx
+= " " + lc
+ "\n"
2423 if (len(MBOlines
) > 0):
2425 ## BuildSection = "\n" + "#"*80 + "\n#\n"
2426 ## BuildSection += "# Build Options - list of custom build options for this module.\n"
2427 ## BuildSection += "#\n" + "#"*80 + "\n\n"
2428 BuildSection
+= "\n[BuildOptions]\n"
2429 for mbo
in MBOlines
:
2430 tool
, targs
= mbo
.split("=",2)
2431 BuildSection
+= " %-40s = %s\n" % (tool
.strip(), targs
.strip())
2433 Output
.append(BuildSection
)
2438 if (len(UEList
) > 0):
2439 UserExtensionSection
= ""
2440 for UE
in UEList
[:]:
2441 UserExtensionSection
+= "[UserExtensions." + UE
[0] + '."' + UE
[1] + '"]\n'
2442 if (len(UE
[2]) > 0):
2443 UserExtensionSection
+= '"' + UE
[2] + '"\n'
2445 UserExtensionSection
+= "\n"
2447 Output
.append(UserExtensionSection
)
2449 print UserExtensionSection
2451 print "write file", outputFile
2452 if (options
.autowrite
):
2453 fo
= open(outputFile
, "w")
2454 for Section
in Output
[:]:
2455 fo
.writelines(Section
)
2456 if (options
.verbose
> 1):
2459 elif (options
.outfile
):
2460 fo
= open(outputFile
, "w")
2461 for Section
in Output
[:]:
2462 fo
.writelines(Section
)
2465 for Section
in Output
[:]:
2469 if __name__
== '__main__':
2473 options
,args
= myOptionParser()