4 # Copyright (c) 2007 - 2010, 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.
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 *
21 from Common
.BuildVersion
import gBUILD_VERSION
23 versionNumber
= ("0.9" + " " + gBUILD_VERSION
)
24 __version__
= "%prog Version " + versionNumber
25 __copyright__
= "Copyright (c) 2007 - 2010, Intel Corporation All rights reserved."
27 commonHeaderFilename
= "CommonHeader.h"
28 entryPointFilename
= "EntryPoint.c"
30 AutoGenLibraryMapping
= {
31 "HiiLib":"HiiLibFramework",
32 "EdkIfrSupportLib":"IfrSupportLibFramework",
33 "EdkScsiLib":"ScsiLib",
35 "EdkFvbServiceLib":"FvbServiceLib",
36 "EdkGraphicsLib":"GraphicsLib"
40 """ Argument Parser """
41 usage
= "%prog [options] -f input_filename"
42 parser
= OptionParser(usage
=usage
,description
=__copyright__
,version
="%prog " + str(versionNumber
))
43 parser
.add_option("-f", "--file", dest
="filename", help="Name of MSA file to convert")
44 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.")
45 parser
.add_option("-a", "--auto", action
="store_true", dest
="autowrite", default
=False, help="Automatically create output files and write the INF file")
46 parser
.add_option("-i", "--interactive", action
="store_true", dest
="interactive", default
=False, help="Set Interactive mode, user must approve each change.")
47 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")
48 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")
49 parser
.add_option("-d", "--debug", action
="store_true", dest
="debug", default
=False, help="Enable printing of debug messages.")
50 parser
.add_option("-c", "--convert", action
="store_true", dest
="convert", default
=False, help="Convert package: OldMdePkg->MdePkg EdkModulePkg->MdeModulePkg.")
51 parser
.add_option("-e", "--event", action
="store_true", dest
="event", default
=False, help="Enable handling of Exit Boot Services & Virtual Address Changed Event")
52 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")
53 parser
.add_option("-w", "--workspace", dest
="workspace", default
=str(os
.environ
.get('WORKSPACE')), help="Specify workspace directory.")
54 (options
, args
) = parser
.parse_args(sys
.argv
[1:])
60 """ Parse XML in the FrameworkDatabase.db file pointed to by f """
61 if (options
.debug
and options
.verbose
> 1):
62 print "Opening the database file:", f
70 """ Parse XML in the SPD file pointed to by s """
71 if (options
.debug
and options
.verbose
> 1):
72 print "Opening the SPD file:", s
80 """ Parse XML in the MSA file pointed to by m """
81 if (options
.debug
and options
.verbose
> 1):
82 print "Opening the MSA file:", m
89 def AddGuid(ArchList
, CName
, Usage
):
90 """ Add a GUID to the Architecture array that the GUID is valid for. """
91 if "IA32" in ArchList
:
92 GuidCNameIa32
.insert(0, str(" %-45s # %s" % (CName
, Usage
)))
94 GuidCNameX64
.insert(0, str(" %-45s # %s" % (CName
, Usage
)))
96 GuidCNameIPF
.insert(0, str(" %-45s # %s" % (CName
, Usage
)))
98 GuidCNameEBC
.insert(0, str(" %-45s # %s" % (CName
, Usage
)))
100 GuidCName
.insert(0, str(" %-45s # %s" % (CName
, Usage
)))
103 def removeDups(CN
, ListName
):
104 """ Remove Duplicate Entries from the Guid List passed in """
105 for Entry
in ListName
[:]:
106 if " " + CN
+ " " in Entry
:
107 if (options
.verbose
> 1):
108 print "Removing C Name %s Entry from Guids List." % (CN
)
109 ListName
.remove(Entry
)
112 """ Process the supported architectures passed in to combine if possible """
113 Archs
= Archs
.upper()
114 if (("IA32" in Archs
) & ("X64" in Archs
) & ("IPF" in Archs
) & ("EBC" in Archs
)):
116 if (len(Archs
) == 0):
120 def saveSourceFile(moduleDir
, sourceFilename
, sourceFileContents
):
121 newFilename
= os
.path
.join(moduleDir
, sourceFilename
)
124 f
= open(newFilename
, "w+")
125 f
.write(sourceFileContents
)
128 print "IO error in saving %s" % sourceFilename
130 return sourceFilename
132 def openSourceFile(moduleDir
, sourceFilename
):
133 newFilename
= os
.path
.join(moduleDir
, sourceFilename
)
134 sourceFileContents
= ""
136 f
= open(newFilename
, "r")
137 sourceFileContents
= f
.read()
140 print "IO error in opening %s" % sourceFilename
142 return sourceFileContents
144 def MatchOption(eline
, ToolChainFamily
, Targets
, Archs
, ToolCode
, Value
):
145 IDs
= eline
.split("_")
151 if (Targets
[0] == "*") or IDs
[0] in Targets
:
152 MatchedTargets
.append(IDs
[0])
154 MatchedTargets
= Targets
157 if Archs
[0] == "*" or IDs
[2] in Archs
:
158 MatchedArchs
.append(IDs
[2])
162 if IDs
[3] != ToolCode
and IDs
[3] != "*":
166 for arch
in MatchedArchs
:
167 for target
in MatchedTargets
:
168 line
= "%s:%s_%s_%s_%s_FLAGS = %s" % (ToolChainFamily
, target
, IDs
[1], arch
, ToolCode
, Value
)
177 AutoGenDeclaration
= ""
178 AutoGenModuleFolder
= None
182 if (options
.workspace
== None):
183 print "ERROR: E0000: WORKSPACE not defined.\n Please set the WORKSPACE environment variable to the location of the EDK II install directory."
186 workspace
= options
.workspace
188 print "Using Workspace:", workspace
197 FdbPath
= os
.path
.join(workspace
, "Conf")
198 FdbPath
= os
.path
.join(FdbPath
, "FrameworkDatabase.db")
199 if os
.path
.exists(FdbPath
):
202 print "ERROR: E0001: WORKSPACE does not contain the FrameworkDatabase File.\n Please run EdkSetup from the EDK II install directory.\n"
205 Fdb
= openDatabase(FdbFile
)
207 print "ERROR: E0002 Could not open the Framework Database file:", FdbFile
211 print "FrameworkDataBase.db file:", FdbFile
214 InitializeAutoGen(workspace
, Fdb
)
216 if (options
.filename
):
217 filename
= options
.filename
218 if ((options
.verbose
> 1) |
(options
.autowrite
)):
219 print "Filename:", filename
221 print "ERROR: E0001 - You must specify an input filename"
224 if (options
.outfile
):
225 outputFile
= options
.outfile
227 outputFile
= filename
.replace('.msa', '.inf')
229 if ((options
.verbose
> 2) or (options
.debug
)):
230 print "Output Filename:", outputFile
232 Msa
= openMsa(filename
)
234 ## Maybe developer think WORKSPACE macro is the root directory of file name
235 ## So we will try to add WORKSPACE path into filename
237 MsaFileName
= os
.path
.join(workspace
, filename
)
238 Msa
= openMsa(MsaFileName
)
240 print "ERROR: E0002: Could not open the file:", filename
243 AutoGenModuleFolder
= os
.path
.dirname(filename
)
245 MsaHeader
= "/ModuleSurfaceArea/MsaHeader/"
246 MsaDefs
= "/ModuleSurfaceArea/ModuleDefinitions/"
247 BaseName
= str(XmlElement(Msa
, MsaDefs
+ "OutputFileBasename")).strip()
249 if (len(BaseName
) < 1):
250 BaseName
= str(XmlElement(Msa
, MsaHeader
+ "BaseName")).strip()
251 BaseName
= re
.sub(' ', '_', BaseName
)
253 GuidValue
= str(XmlElement(Msa
, MsaHeader
+ "GuidValue")).strip()
254 VerString
= str(XmlElement(Msa
, MsaHeader
+ "Version")).strip()
255 ModType
= str(XmlElement(Msa
, MsaHeader
+ "ModuleType")).strip()
256 CopyRight
= str(XmlElement(Msa
, MsaHeader
+ "Copyright")).strip()
257 Abstract
= str(XmlElement(Msa
, MsaHeader
+ "Abstract")).strip()
258 Description
= str(XmlElement(Msa
, MsaHeader
+ "Description")).strip().replace(" ", " ").replace(" ", " ").replace(" ", " ")
259 if not CopyRight
.find("2007"):
260 CopyRight
= CopyRight
.replace("2006", "2007")
261 License
= str(XmlElement(Msa
, MsaHeader
+ "License")).strip().replace(" ", " ")
262 MsaDefs
= "/ModuleSurfaceArea/ModuleDefinitions/"
265 BinModule
= str(XmlElement(Msa
, MsaDefs
+ "BinaryModule")).strip()
269 SupportedArchitectures
= ""
271 SupportedArchitectures
= str(XmlElement(Msa
, MsaDefs
+ "SupportedArchitectures")).strip()
276 if (len(SupportedArchitectures
) > 0):
277 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
278 DefinesComments
.append("# VALID_ARCHITECTURES = " + SupportedArchitectures
+ "\n")
279 DefinesComments
.append("#\n")
281 MsaExtern
= "/ModuleSurfaceArea/Externs/"
284 PcdIsDriver
= str(XmlElement(Msa
, MsaExtern
+ "PcdIsDriver")).strip()
291 List
= XmlList(Msa
, MsaExtern
+ "Specification")
297 SpecList
.insert(0, str(XmlElementData(spec
)).strip())
302 Flag
= (DefinesComments
== [])
304 # Data structure to insert autogen code
305 AutoGenDriverModel
= []
306 AutoGenExitBootServices
= []
307 AutoGenVirtualAddressChanged
= []
308 AutoGenEntryPoint
= ""
313 AutoGenSourceFiles
= []
318 Externlist
= XmlList(Msa
, MsaExtern
+ "Extern")
322 if (len(Externlist
) > 0):
323 if (options
.debug
and options
.verbose
> 2):
324 print "In Extern Parsing Routine"
325 for extern
in Externlist
:
336 AutoGenDriverModelItem
= []
338 EntryPoint
= str(XmlElementData(extern
.getElementsByTagName("ModuleEntryPoint")[0])).strip()
339 AutoGenEntryPoint
= EntryPoint
340 #DriverModules.append(" %-30s = %s\n" % ("ENTRY_POINT" , EntryPoint))
345 Unload
= str(XmlElementData(extern
.getElementsByTagName("ModuleUnloadImage")[0])).strip()
346 AutoGenUnload
= Unload
347 DriverModules
.append(" %-30s = %s\n" % ("UNLOAD_IMAGE", Unload
))
352 DBinding
= str(XmlElementData(extern
.getElementsByTagName("DriverBinding")[0])).strip()
353 AutoGenDriverModelItem
.append("&" + DBinding
)
354 DefinesComments
.append("# %-29s = %-45s\n" % ("DRIVER_BINDING", DBinding
))
360 CompName
= str(XmlElementData(extern
.getElementsByTagName("ComponentName")[0])).strip()
361 AutoGenDriverModelItem
.append("&" + CompName
)
362 DefinesComments
.append("# %-29s = %-45s\n" % ("COMPONENT_NAME", CompName
))
366 AutoGenDriverModelItem
.append("NULL")
370 Config
= str(XmlElementData(extern
.getElementsByTagName("DriverConfig")[0])).strip()
371 AutoGenDriverModelItem
.append("&" + Config
)
372 DefinesComments
.append("# %-29s = %-45s\n" % ("DRIVER_CONFIG", Config
))
376 AutoGenDriverModelItem
.append("NULL")
380 Diag
= str(XmlElementData(extern
.getElementsByTagName("DriverDiag")[0])).strip()
381 AutoGenDriverModelItem
.append("&" + Diag
)
382 DefinesComments
.append("# %-29s = %-45s\n" % ("DRIVER_DIAG", Diag
))
386 AutoGenDriverModelItem
.append("NULL")
389 if len(AutoGenDriverModelItem
) > 0:
390 AutoGenDriverModel
.append(AutoGenDriverModelItem
)
393 Constr
= str(XmlElementData(extern
.getElementsByTagName("Constructor")[0])).strip()
394 LibraryModules
.append(" %-30s = %s\n" % ("CONSTRUCTOR", Constr
))
399 Destr
= str(XmlElementData(extern
.getElementsByTagName("Destructor")[0])).strip()
400 LibraryModules
.append(" %-30s = %s\n" % ("DESTRUCTOR", Destr
))
405 CallBack
= str(XmlElement(extern
, "Extern/SetVirtualAddressMapCallBack")).strip()
407 AutoGenVirtualAddressChanged
.append(CallBack
)
408 DefinesComments
.append("# %-29s = %-45s\n" % ("VIRTUAL_ADDRESS_MAP_CALLBACK", CallBack
))
415 CallBack
= str(XmlElement(extern
, "Extern/ExitBootServicesCallBack")).strip()
417 AutoGenExitBootServices
.append(CallBack
)
418 DefinesComments
.append("# %-29s = %-45s\n" % ("EXIT_BOOT_SERVICES_CALLBACK", CallBack
))
426 """ Get the Module's custom build options """
428 MBO
= "/ModuleSurfaceArea/ModuleBuildOptions/Options/Option"
431 mboList
= XmlList(Msa
, MBO
)
435 if (len(mboList
) > 0):
436 for Option
in mboList
:
442 bt
= str(Option
.getAttribute("BuildTargets"))
447 if (re
.findall(" ", bt
) > 0):
450 Targets
.insert(0, bt
)
452 Targets
.insert(0, "*")
454 if (options
.debug
and options
.verbose
> 2):
455 print "Targets", len(Targets
), Targets
459 pro
= Option
.getAttribute("SupArchList")
460 if (re
.findall(" ", pro
) > 0):
462 elif (re
.findall(",", pro
) > 0):
463 Archs
= pro
.split(",")
470 if (options
.debug
and options
.verbose
> 2):
471 print "Archs", len(Archs
), Archs
475 ToolCode
= str(Option
.getAttribute("ToolCode"))
479 if (len(ToolCode
) == 0):
484 value
= str(XmlElementData(Option
))
490 TagName
= str(Option
.getAttribute("TagName"))
494 if (len(TagName
) > 0) :
495 if (options
.debug
and options
.verbose
> 2):
496 print "TagName was defined:", TagName
497 Tags
.insert(0, TagName
)
499 if (options
.debug
and options
.verbose
> 2):
500 print "TagName was NOT defined!"
506 Family
= str(Option
.getAttribute("ToolChainFamily")).strip()
510 if (len(Family
) > 0):
512 print "Searching tools_def.txt for Tool Tags that belong to:", Family
, "family"
515 tdPath
= os
.path
.join(workspace
, "Tools")
516 tdPath
= os
.path
.join(tdPath
, "Conf")
517 tdPath
= os
.path
.join(tdPath
, "tools_def.txt")
518 tdPath
= tdPath
.replace("\\", "/")
519 if os
.path
.exists(tdPath
):
522 tdPath
= os
.path
.join(workspace
, "Conf")
523 tdPath
= os
.path
.join(tdPath
, "tools_def.txt")
524 if os
.path
.exists(tdPath
):
527 print "ERROR: E0001: WORKSPACE does not contain the tools_def.txt File.\n Please run EdkSetup from the EDK II install directory.\n"
530 if (options
.debug
and options
.verbose
> 2):
531 print "Opening:", tdFile
534 tools_def
= open(tdFile
, "r")
535 for tdline
in tools_def
:
538 if "FAMILY" in tdline
:
539 if (options
.debug
and options
.verbose
> 2):
540 print "Testing for FAMILY:", Family
, "in the line:", tdline
.strip()
542 enter
= tdline
.split("=")[0]
543 if (options
.debug
and options
.verbose
> 2):
544 print "Adding TNL:", tdline
545 TagNameList
.insert(0, enter
)
548 if (options
.debug
and options
.verbose
> 2):
549 print "TagNameList:", TagNameList
552 for eline
in TagNameList
:
555 if (options
.debug
and options
.verbose
> 2):
556 print "ToolsDef entry:", eline
558 olines
= MatchOption(eline
, Family
, Targets
, Archs
, ToolCode
, value
)
562 for oline
in olinesSet
:
563 if (options
.debug
and options
.verbose
> 2):
564 print "Adding:", str(oline
)
565 MBOlines
.insert(0, oline
)
569 oline
= " %s_%s_%s_%s_FLAGS = %s" % (targ
, Tags
[0], arch
, str(ToolCode
), str(Value
))
570 if (options
.debug
and options
.verbose
> 2):
571 print "Adding:", str(oline
)
572 MBOlines
.insert(0, oline
)
580 oline
= " " + str(targ
) + "_" + str(tag
) + "_" + str(arch
) + "_" + str(ToolCode
) + "_FLAGS = " + str(value
)
581 if (options
.debug
and options
.verbose
> 2):
582 print "Adding:", str(oline
)
583 #MBOlines.insert(0, oline)
586 """ Get the Library Class information """
587 MsaLcDefs
= "/ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass"
590 LcDefList
= XmlList(Msa
, MsaLcDefs
)
596 LibClassListIa32
= []
602 if (len(LcDefList
) > 0):
606 lcKeyword
= str(XmlElementData(Lc
.getElementsByTagName("Keyword")[0]))
608 raise SyntaxError, "The MSA is not correctly formed, a Library Class Keyword Element is required"
612 lcUsage
= str(XmlAttribute(Lc
, "Usage"))
614 raise SyntaxError, "The MSA is not correctly formed, a Usage Attribute is required for all Library Class Elements"
618 Archs
= str(XmlAttribute(Lc
, "SupArchList"))
622 Archs
= chkArch(Archs
)
624 if (options
.debug
and options
.verbose
> 2):
625 print "Attr: ", lcUsage
, lcKeyword
, Archs
627 if (options
.convert
):
628 lcKeyword
= AutoGenLibraryMapping
.get(lcKeyword
, lcKeyword
)
630 if re
.findall("PRODUCED", lcUsage
, re
.IGNORECASE
):
635 lcSupModList
= str(XmlAttribute(Lc
, "SupModuleList"))
641 AutoGenLibClass
.append(lcKeyword
)
642 if len(lcSupModList
) > 0:
643 lcLine
= lcLine
+ "|" + lcSupModList
644 IamLibrary
.insert(0, lcLine
)
647 elif lcKeyword
!= "UefiDriverModelLib":
648 AutoGenLibClass
.append(lcKeyword
)
649 # This section handles the library classes that are CONSUMED
651 LibClassListIa32
.insert(0, lcKeyword
)
653 LibClassListX64
.insert(0, lcKeyword
)
655 LibClassListIpf
.insert(0, lcKeyword
)
657 LibClassListEbc
.insert(0, lcKeyword
)
659 LibClassList
.insert(0, lcKeyword
)
660 if len(AutoGenDriverModel
) > 0 and "UefiLib" not in LibClassList
:
661 AutoGenLibClass
.append("UefiLib")
662 LibClassList
.insert(0, "UefiLib")
665 """ Get the Source File list """
667 SrcFilenamesIa32
= []
671 SrcFiles
= "/ModuleSurfaceArea/SourceFiles/Filename"
674 SrcList
= XmlList(Msa
, SrcFiles
)
678 if (len(SrcList
) > 0):
684 Archs
= fn
.getAttribute("SupArchList")
688 Archs
= chkArch(Archs
)
691 file = str(XmlElementData(fn
))
695 if file.endswith(".dxs"):
696 AutoGenDxsFiles
.append((file, Archs
))
698 AutoGenSourceFiles
.append(file)
700 SrcFilenamesIa32
.insert(0, file)
702 SrcFilenamesX64
.insert(0, file)
704 SrcFilenamesIpf
.insert(0, file)
706 SrcFilenamesEbc
.insert(0, file)
708 SrcFilenames
.insert(0, file)
710 """ Package Dependency section """
711 DbPkgList
= "/FrameworkDatabase/PackageList/Filename"
714 WorkspacePkgs
= XmlList(Fdb
, DbPkgList
)
716 print "Could not tet the package data from the database"
722 if (options
.debug
and options
.verbose
> 1):
723 print "Found %s packages in the WORKSPACE" % (len(WorkspacePkgs
))
727 if (len(WorkspacePkgs
) > 0):
728 SpdHeader
= "/PackageSurfaceArea/SpdHeader/"
729 for Pkg
in WorkspacePkgs
[:]:
734 file = str(XmlElementData(Pkg
))
738 if (options
.debug
and options
.verbose
> 2):
741 if fnmatch
.fnmatch(file, "*.dec"):
742 print "parsing " + os
.path
.join(workspace
, file)
746 Lines
= open(os
.path
.join(workspace
, file)).readlines()
748 print "Could not parse the Package file:", file
752 Line
= Line
.split("#")[0]
753 Items
= Line
.split("=")
757 Key
= Items
[0].strip().upper()
758 if Key
== "PACKAGE_GUID":
759 PackageGuid
= Items
[1].strip()
760 if Key
== "PACKAGE_VERSION":
761 PackageVersion
= Items
[1].strip()
764 Spd
= openSpd(os
.path
.join(workspace
, file))
766 print "Could not parse the Package file:", file
769 path
= os
.path
.split(file)[0]
770 file = file.replace(".nspd", ".dec")
771 file = file.replace(".spd", ".dec")
774 PackageGuid
= str(XmlElement(Spd
, SpdHeader
+ "GuidValue"))
779 PackageVersion
= str(XmlElement(Spd
, SpdHeader
+ "Version"))
783 file = file + "|" + PackageGuid
+ "|" + PackageVersion
784 PkgDb
.insert(0, file)
788 GuidEntries
= XmlList(Spd
, "/PackageSurfaceArea/GuidDeclarations/Entry")
792 if (len(GuidEntries
) > 0):
793 for Entry
in GuidEntries
[:]:
795 GuidDecls
.append(str(XmlElementData(Entry
.getElementsByTagName("C_Name")[0])).strip())
802 pHdrs
= XmlList(Spd
, "/PackageSurfaceArea/PackageHeaders/IncludePkgHeader")
809 ModTypeList
= str(Hdr
.getAttribute("ModuleType"))
810 if (ModType
in ModTypeList
):
811 HeaderName
= str(XmlElementData(Hdr
))[0]
812 Dirs
.insert(0, os
.path
.join(packagepath
,str(os
.path
.split(HeaderName
))))
816 # Get the Guid:Header from the Packages
817 SpdLcDec
= "/PackageSurfaceArea/LibraryClassDeclarations/LibraryClass"
820 lcList
= XmlList(Spd
, SpdLcDec
)
824 if (len(lcList
) > 0):
828 Name
= Lc
.getAttribute("Name")
834 Header
= XmlElementData(Lc
.getElementsByTagName("IncludeHeader")[0])
838 if ((len(Name
) > 0) and (len(Header
) > 0)):
839 line
= Name
+ "|" + os
.path
.join(path
, Header
)
840 if (options
.debug
and options
.verbose
> 2):
841 print "Adding:", line
842 HeaderLocations
.insert(0, line
)
846 IndStdHeaders
= "/PackageSurfaceArea/IndustryStdIncludes/IndustryStdHeader"
847 ishList
= XmlList(Spd
, IndStdHeaders
)
851 if (len(ishList
) > 0):
852 for Lc
in ishList
[:]:
855 Name
= str(Lc
.getAttribute("Name")).strip()
861 Header
= str(XmlElementData(Lc
.getElementsByTagName("IncludeHeader")[0])).strip()
865 if ((len(Name
) > 0) and (len(Header
) > 0)):
866 line
= Name
+ "|" + os
.path
.join(path
, Header
)
867 HeaderLocations
.insert(0, str(line
))
874 Pkgs
= "/ModuleSurfaceArea/PackageDependencies/Package"
877 pkgL
= XmlList(Msa
, Pkgs
)
884 if (options
.debug
and options
.verbose
> 1):
885 print "Found %s packages in the module" % (len(pkgL
))
893 Archs
= pkg
.getAttribute("SupArchList")
897 Archs
= chkArch(Archs
)
900 pkgGuid
= pkg
.getAttribute("PackageGuid")
905 if pkgGuid
.lower() == "5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec":
906 pkgGuid
= "1E73767F-8F52-4603-AEB4-F29B510B6766"
907 if pkgGuid
.lower() == "68169ab0-d41b-4009-9060-292c253ac43d":
908 pkgGuid
= "BA0D78D6-2CAF-414b-BD4D-B6762A894288"
909 AutoGenPackage
.append(pkgGuid
)
911 pkgVer
= pkg
.getAttribute("PackageVersion")
915 for PkgEntry
in PkgDb
[:]:
916 if pkgGuid
in PkgEntry
:
918 if pkgVer
in PkgEntry
:
921 PkgListIa32
.insert(0, PkgEntry
.split("|")[0])
923 PkgListX64
.insert(0, PkgEntry
.split("|")[0])
925 PkgListIpf
.insert(0, PkgEntry
.split("|")[0])
927 PkgListEbc
.insert(0, PkgEntry
.split("|")[0])
929 PkgList
.insert(0, PkgEntry
.split("|")[0])
933 PkgListIa32
.insert(0, PkgEntry
.split("|")[0])
935 PkgListX64
.insert(0, PkgEntry
.split("|")[0])
937 PkgListIpf
.insert(0, PkgEntry
.split("|")[0])
939 PkgListEbc
.insert(0, PkgEntry
.split("|")[0])
941 PkgList
.insert(0, PkgEntry
.split("|")[0])
944 gUnknownPkgGuid
[str(pkgGuid
)] = 1
946 for UnknownPkgGuid
in gUnknownPkgGuid
:
947 print "Cannot resolve package dependency Guid:", UnknownPkgGuid
950 PkgListIa32
.reverse()
955 print "Package List:", PkgList
959 """ Setup the Global GuidCName arrays that will hold data from various MSA locations """
971 """ Check for the GUIDs Element """
972 Guids
= "/ModuleSurfaceArea/Guids/GuidCNames"
975 GuidList
= XmlList(Msa
, Guids
)
979 if (len(GuidList
) > 0):
980 for Guid
in GuidList
:
986 Archs
= Guid
.getAttribute("SupArchList")
990 Archs
= chkArch(Archs
)
993 Usage
= Guid
.getAttribute("Usage")
998 CName
= str(XmlElementData(Guid
.getElementsByTagName("GuidCName")[0]))
999 if CName
in GuidDecls
:
1000 if (options
.debug
and options
.verbose
> 1):
1001 print "Guids Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1002 AddGuid(Archs
, CName
, Usage
)
1003 AutoGenGuid
.append(CName
)
1005 raise AssertionError, "Guid %s defined in %s is not declared in any package (.dec) file!" % (CName
, filename
)
1009 if (options
.debug
and options
.verbose
> 2):
1010 print "Guid C Name List:", GuidCName
1012 """ Check for Events """
1013 Guids
= "/ModuleSurfaceArea/Events/CreateEvents/EventTypes"
1016 GuidList
= XmlList(Msa
, Guids
)
1020 if (len(GuidList
) > 0):
1021 for Guid
in GuidList
:
1027 Archs
= Guid
.getAttribute("SupArchList")
1031 Archs
= chkArch(Archs
)
1034 Usage
= Guid
.getAttribute("Usage")
1035 Type
= str(XmlElementData(Guid
.getElementsByTagName("EventType")[0]))
1036 Usage
+= " Create Event: " + Type
1041 CName
= str(Guid
.getAttribute("EventGuidCName"))
1042 if CName
in GuidDecls
:
1043 if (options
.debug
and options
.verbose
> 1):
1044 print "CreateEvent Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1045 AddGuid(Archs
, CName
, Usage
)
1046 AutoGenGuid
.append(CName
)
1048 if (len(DefinesComments
) == 0):
1049 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1050 DefinesComments
.append("# Create Event Guid C Name: " + CName
+ " Event Type: " + Type
+ "\n")
1056 DefinesComments
.append("#\n")
1059 Guids
= "/ModuleSurfaceArea/Events/SignalEvents/EventTypes"
1062 GuidList
= XmlList(Msa
, Guids
)
1066 if (len(GuidList
) > 0):
1067 for Guid
in GuidList
:
1073 Archs
= Guid
.getAttribute("SupArchList")
1077 Archs
= chkArch(Archs
)
1080 Usage
= Guid
.getAttribute("Usage")
1081 Type
= str(XmlElementData(Guid
.getElementsByTagName("EventType")[0]))
1082 Usage
+= " Signal Event: " + Type
1087 CName
= str(Guid
.getAttribute("EventGuidCName"))
1088 if CName
in GuidDecls
:
1089 if (options
.debug
and options
.verbose
> 1):
1090 print "SignalEvent Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1091 AddGuid(Archs
, CName
, Usage
)
1092 AutoGenGuid
.append(CName
)
1094 if (len(DefinesComments
) == 0):
1095 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1096 DefinesComments
.append("# Signal Event Guid C Name: " + CName
+ " Event Type: " + Type
+ "\n")
1102 DefinesComments
.append("#\n")
1105 """ Check the HOB guids """
1106 Guids
= "/ModuleSurfaceArea/Hobs/HobTypes"
1109 GuidList
= XmlList(Msa
, Guids
)
1113 if (len(GuidList
) > 0):
1114 for Guid
in GuidList
:
1120 Archs
= Guid
.getAttribute("SupArchList")
1124 Archs
= chkArch(Archs
)
1127 Usage
= Guid
.getAttribute("Usage")
1128 Type
= str(XmlElementData(Guid
.getElementsByTagName("HobType")[0]))
1129 Usage
+= " Hob: " + Type
1134 CName
= str(Guid
.getAttribute("HobGuidCName"))
1135 if CName
in GuidDecls
:
1136 if (options
.debug
and options
.verbose
> 1):
1137 print "Hob Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1138 AddGuid(Archs
, CName
, Usage
)
1139 AutoGenGuid
.append(CName
)
1141 if (len(DefinesComments
) == 0):
1142 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1143 DefinesComments
.append("# HOB Guid C Name: " + CName
+ " Hob Type: " + Type
+ "\n")
1146 if (len(DefinesComments
) == 0):
1147 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1148 DefinesComments
.append("# HOB: " + Type
+ "\n")
1153 DefinesComments
.append("#\n")
1156 """ Check for the SystemTables Element """
1157 Guids
= "/ModuleSurfaceArea/SystemTables/SystemTableCNames"
1160 GuidList
= XmlList(Msa
, Guids
)
1164 if (len(GuidList
) > 0):
1165 for Guid
in GuidList
:
1171 Archs
= Guid
.getAttribute("SupArchList")
1175 Archs
= chkArch(Archs
)
1178 Usage
= Guid
.getAttribute("Usage")
1179 Usage
+= " System Table"
1184 CName
= str(XmlElementData(Guid
.getElementsByTagName("SystemTableCName")[0]))
1185 if (options
.debug
and options
.verbose
> 1):
1186 print "System Table Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1187 AddGuid(Archs
, CName
, Usage
)
1188 AutoGenGuid
.append(CName
)
1192 """ Check for the DataHubs Element """
1193 Guids
= "/ModuleSurfaceArea/DataHubs/DataHubRecord"
1196 GuidList
= XmlList(Msa
, Guids
)
1200 if (len(GuidList
) > 0):
1201 for Guid
in GuidList
:
1207 Archs
= Guid
.getAttribute("SupArchList")
1211 Archs
= chkArch(Archs
)
1214 Usage
= Guid
.getAttribute("Usage")
1215 Usage
+= " Data Hub"
1220 CName
= str(XmlElementData(Guid
.getElementsByTagName("DataHubCName")[0]))
1221 if (options
.debug
and options
.verbose
> 1):
1222 print "Data Hub Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1223 AddGuid(Archs
, CName
, Usage
)
1224 AutoGenGuid
.append(CName
)
1228 """ Check for the HiiPackages Element """
1229 Guids
= "/ModuleSurfaceArea/HiiPackages/HiiPackage"
1232 GuidList
= XmlList(Msa
, Guids
)
1236 if (len(GuidList
) > 0):
1237 for Guid
in GuidList
:
1243 Archs
= Guid
.getAttribute("SupArchList")
1247 Archs
= chkArch(Archs
)
1250 Usage
= Guid
.getAttribute("Usage")
1251 Usage
+= " HII Formset"
1256 CName
= str(XmlElementData(Guid
.getElementsByTagName("HiiCName")[0]))
1257 if (options
.debug
and options
.verbose
> 1):
1258 print "Hii Formset Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1259 AddGuid(Archs
, CName
, Usage
)
1260 AutoGenGuid
.append(CName
)
1264 """ Check for the Variables Element """
1265 Guids
= "/ModuleSurfaceArea/Variables/Variable"
1268 GuidList
= XmlList(Msa
, Guids
)
1272 if (len(GuidList
) > 0):
1273 for Guid
in GuidList
:
1280 Archs
= Guid
.getAttribute("SupArchList")
1284 Archs
= chkArch(Archs
)
1287 Usage
= Guid
.getAttribute("Usage")
1292 VariableName
= str(XmlElementData(Guid
.getElementsByTagName("VariableName")[0]))
1293 CName
= str(XmlElementData(Guid
.getElementsByTagName("GuidC_Name")[0]))
1295 HexData
= VariableName
.strip().split()
1297 for dig
in HexData
[:]:
1298 UniString
+= str(unichr(eval(dig
)))
1303 if CName
in set(GuidDecls
):
1304 removeDups(CName
, GuidCName
)
1305 removeDups(CName
, GuidCNameIa32
)
1306 removeDups(CName
, GuidCNameX64
)
1307 removeDups(CName
, GuidCNameIPF
)
1308 removeDups(CName
, GuidCNameEBC
)
1311 print "Variable Adding Guid CName: %-45s # %s Archs: %s" % (CName
, Usage
, Archs
)
1312 AddGuid(Archs
, CName
, Usage
)
1313 AutoGenGuid
.append(CName
)
1315 if (len(DefinesComments
) == 0):
1316 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1317 DefinesComments
.append("# Variable Guid C Name: " + CName
+ " Variable Name:" + UniString
+ "\n")
1323 DefinesComments
.append("#\n")
1326 """ Check for the Protocol Element """
1327 Protocols
= "/ModuleSurfaceArea/Protocols/Protocol"
1330 ProtocolCNameIa32
= []
1331 ProtocolCNameX64
= []
1332 ProtocolCNameIPF
= []
1333 ProtocolCNameEBC
= []
1336 ProtocolList
= XmlList(Msa
, Protocols
)
1340 if (len(ProtocolList
) > 0):
1341 for Protocol
in ProtocolList
:
1347 Archs
= Protocol
.getAttribute("SupArchList")
1351 Archs
= chkArch(Archs
)
1354 Usage
= Protocol
.getAttribute("Usage")
1359 CName
= str(XmlElementData(Protocol
.getElementsByTagName("ProtocolCName")[0]))
1360 AutoGenGuid
.append(CName
)
1361 removeDups(CName
, GuidCName
)
1362 removeDups(CName
, GuidCNameIa32
)
1363 removeDups(CName
, GuidCNameX64
)
1364 removeDups(CName
, GuidCNameIPF
)
1365 removeDups(CName
, GuidCNameEBC
)
1367 if (options
.debug
and options
.verbose
> 1):
1368 print "Found %s - %s - %s " % (CName
, Usage
, str(len(Archs
)))
1371 ProtocolCNameIa32
.insert(0, str(" %-45s # PROTOCOL %s" % (CName
, Usage
)))
1373 ProtocolCNameX64
.insert(0, str(" %-45s # PROTOCOL %s" % (CName
, Usage
)))
1375 ProtocolCNameIPF
.insert(0, str(" %-45s # PROTOCOL %s" % (CName
, Usage
)))
1377 ProtocolCNameEBC
.insert(0, str(" %-45s # PROTOCOL %s" % (CName
, Usage
)))
1379 ProtocolCName
.insert(0, str(" %-45s # PROTOCOL %s" % (CName
, Usage
)))
1384 Protocols
= "/ModuleSurfaceArea/Protocols/ProtocolNotify"
1386 ProtocolList
= XmlList(Msa
, Protocols
)
1390 if (len(ProtocolList
) > 0):
1391 for Protocol
in ProtocolList
:
1397 Archs
= Protocol
.getAttribute("SupArchList")
1401 Archs
= chkArch(Archs
)
1404 Usage
= Protocol
.getAttribute("Usage")
1409 CName
= str(XmlElementData(Protocol
.getElementsByTagName("ProtocolNotifyCName")[0]))
1410 AutoGenGuid
.append(CName
)
1411 removeDups(CName
, GuidCName
)
1412 removeDups(CName
, GuidCNameIa32
)
1413 removeDups(CName
, GuidCNameX64
)
1414 removeDups(CName
, GuidCNameIPF
)
1415 removeDups(CName
, GuidCNameEBC
)
1418 ProtocolCNameIa32
.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName
, Usage
))
1420 ProtocolCNameX64
.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName
, Usage
))
1422 ProtocolCNameIPF
.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName
, Usage
))
1424 ProtocolCNameEBC
.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName
, Usage
))
1426 ProtocolCName
.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName
, Usage
))
1430 """ Check for the PPIs Element """
1431 PPIs
= "/ModuleSurfaceArea/PPIs/Ppi"
1440 PPIsList
= XmlList(Msa
, PPIs
)
1444 if (len(PPIsList
) > 0):
1445 for Ppi
in PPIsList
:
1451 Archs
= str(Ppi
.getAttribute("SupArchList"))
1455 Archs
= chkArch(Archs
)
1458 Usage
= str(Ppi
.getAttribute("Usage"))
1463 CName
= str(XmlElementData(Ppi
.getElementsByTagName("PpiCName")[0])).strip()
1464 AutoGenGuid
.append(CName
)
1465 removeDups(CName
, GuidCName
)
1466 removeDups(CName
, GuidCNameIa32
)
1467 removeDups(CName
, GuidCNameX64
)
1468 removeDups(CName
, GuidCNameIPF
)
1469 removeDups(CName
, GuidCNameEBC
)
1472 PpiCNameIa32
.insert(0, " %-45s # PPI %s" % (CName
, Usage
))
1474 PpiCNameX64
.insert(0, " %-45s # PPI %s" % (CName
, Usage
))
1476 PpiCNameIPF
.insert(0, " %-45s # PPI %s" % (CName
, Usage
))
1478 PpiCNameEBC
.insert(0, " %-45s # PPI %s" % (CName
, Usage
))
1480 PpiCName
.insert(0, " %-45s # PPI %s" % (CName
, Usage
))
1485 PPIs
= "/ModuleSurfaceArea/PPIs/PpiNotify"
1487 PPIsList
= XmlList(Msa
, PPIs
)
1491 if (len(PPIsList
) > 0):
1492 for Ppi
in PPIsList
:
1498 Archs
= Ppi
.getAttribute("SupArchList")
1502 Archs
= chkArch(Archs
)
1505 Usage
= Ppi
.getAttribute("Usage")
1510 CName
= str(XmlElementData(Ppi
.getElementsByTagName("PpiNotifyCName")[0]))
1511 AutoGenGuid
.append(CName
)
1512 removeDups(CName
, GuidCName
)
1513 removeDups(CName
, GuidCNameIa32
)
1514 removeDups(CName
, GuidCNameX64
)
1515 removeDups(CName
, GuidCNameIPF
)
1516 removeDups(CName
, GuidCNameEBC
)
1519 PpiCNameIa32
.insert(0, " %-45s # PPI_NOTIFY %s" % (CName
, Usage
))
1521 PpiCNameX64
.insert(0, " %-45s # PPI_NOTIFY %s" % (CName
, Usage
))
1523 PpiCNameIPF
.insert(0, " %-45s # PPI_NOTIFY %s" % (CName
, Usage
))
1525 PpiCNameEBC
.insert(0, " %-45s # PPI_NOTIFY %s" % (CName
, Usage
))
1527 PpiCName
.insert(0, " %-45s # PPI_NOTIFY %s" % (CName
, Usage
))
1532 """ Get the PCD entries now """
1533 PcdCoded
= "/ModuleSurfaceArea/PcdCoded/PcdEntry"
1536 PcdList
= XmlList(Msa
, PcdCoded
)
1540 (PcdFF
, PcdFFIa32
, PcdFFX64
, PcdFFIpf
, PcdFFEbc
) = ([],[],[],[],[])
1541 (PcdFAB
, PcdFABIa32
, PcdFABX64
, PcdFABIpf
, PcdFABEbc
) = ([],[],[],[],[])
1542 (PcdPIM
, PcdPIMIa32
, PcdPIMX64
, PcdPIMIpf
, PcdPIMEbc
) = ([],[],[],[],[])
1543 (PcdDY
, PcdDYIa32
, PcdDYX64
, PcdDYIpf
, PcdDYEbc
) = ([],[],[],[],[])
1544 (PcdDYE
, PcdDYEIa32
, PcdDYEX64
, PcdDYEIpf
, PcdDYEEbc
) = ([],[],[],[],[])
1546 if (len(PcdList
) > 0):
1554 Archs
= Pcd
.getAttribute("SupArchList")
1558 Archs
= chkArch(Archs
)
1561 ItemType
= Pcd
.getAttribute("PcdItemType")
1566 CName
= str(XmlElementData(Pcd
.getElementsByTagName("C_Name")[0]))
1568 raise SyntaxError, "ERROR: MSA has a PCD with no Pcd C_Name defined"
1571 TSGC
= str(XmlElementData(Pcd
.getElementsByTagName("TokenSpaceGuidCName")[0]))
1576 DefVal
= str(XmlElementData(Pcd
.getElementsByTagName("DefaultValue")))
1580 if (len(DefVal
) > 0):
1581 line
= TSGC
+ "." + CName
+ "|" + DefVal
1583 line
= TSGC
+ "." + CName
1585 if (ItemType
== "FEATURE_FLAG"):
1586 if ("IA32" in Archs
):
1587 PcdFFIa32
.insert(0, line
)
1588 if ("IPF" in Archs
):
1589 PcdFFIpf
.insert(0, line
)
1590 if ("X64" in Archs
):
1591 PcdFFX64
.insert(0, line
)
1592 if ("EBC" in Archs
):
1593 PcdFFEbc
.insert(0, line
)
1594 if ("ALL" in Archs
):
1595 PcdFF
.insert(0, line
)
1596 elif (ItemType
== "FIXED_AT_BUILD"):
1597 if ("IA32" in Archs
):
1598 PcdFABIa32
.insert(0, line
)
1599 if ("IPF" in Archs
):
1600 PcdFABIpf
.insert(0, line
)
1601 if ("X64" in Archs
):
1602 PcdFABX64
.insert(0, line
)
1603 if ("EBC" in Archs
):
1604 PcdFABEbc
.insert(0, line
)
1605 if ("ALL" in Archs
):
1606 PcdFAB
.insert(0, line
)
1607 elif (ItemType
== "PATCHABLE_IN_MODULE"):
1608 if ("IA32" in Archs
):
1609 PcdPIMIa32
.insert(0, line
)
1610 if ("IPF" in Archs
):
1611 PcdPIMIpf
.insert(0, line
)
1612 if ("X64" in Archs
):
1613 PcdPIMX64
.insert(0, line
)
1614 if ("EBC" in Archs
):
1615 PcdPIMEbc
.insert(0, line
)
1616 if ("ALL" in Archs
):
1617 PcdFAB
.insert(0, line
)
1618 elif (ItemType
== "DYNAMIC_EX"):
1619 if ("IA32" in Archs
):
1620 PcdDYEIa32
.insert(0, line
)
1621 if ("IPF" in Archs
):
1622 PcdDYEIpf
.insert(0, line
)
1623 if ("X64" in Archs
):
1624 PcdDYEX64
.insert(0, line
)
1625 if ("EBC" in Archs
):
1626 PcdDYEEbc
.insert(0, line
)
1627 if ("ALL" in Archs
):
1628 PcdDYE
.insert(0, line
)
1630 if ("IA32" in Archs
):
1631 PcdDYIa32
.insert(0, line
)
1632 if ("IPF" in Archs
):
1633 PcdDYIpf
.insert(0, line
)
1634 if ("X64" in Archs
):
1635 PcdDYX64
.insert(0, line
)
1636 if ("EBC" in Archs
):
1637 PcdDYEbc
.insert(0, line
)
1638 if ("ALL" in Archs
):
1639 PcdDY
.insert(0, line
)
1641 """ User Extensions Section """
1645 UESectionList
= XmlList(Msa
, "/ModuleSurfaceArea/UserExtensions")
1649 if (len(UESectionList
) > 0):
1650 for UE
in UESectionList
[:]:
1656 UserId
= str(UE
.getAttribute("UserID"))
1658 raise SyntaxError, "ERROR: Malformed MSA, No UserID Specified in UserExtensions element"
1661 Identifier
= str(UE
.getAttribute("Identifier"))
1663 raise SyntaxError, "ERROR: Malformed MSA, No Identifier Specified in UserExtensions element"
1666 print "FOUND A UE Element", UserId
, Identifier
1669 Value
= str(XmlElementData(UE
))
1673 Entry
= [UserId
, Identifier
, Value
]
1674 UEList
.insert(0, Entry
)
1678 if (len(Externlist
) > 0):
1680 AutoGenDefinitionSource
= ""
1681 AutoGenEntryPointSource
= ""
1682 AutoGenUnloadSource
= ""
1683 if (len(AutoGenDriverModel
) > 0):
1684 AutoGenCode
= AddDriverBindingProtocolStatement(AutoGenDriverModel
)
1685 AutoGenEntryPointSource
+= AutoGenCode
[0]
1686 AutoGenUnloadSource
+= AutoGenCode
[1]
1687 AutoGenDeclaration
+= AutoGenCode
[3]
1690 if (len(AutoGenExitBootServices
) > 0):
1691 print "[Warning] Please manually add Create Event statement for Exit Boot Service Event!"
1693 AutoGenCode
= AddBootServiceEventStatement(AutoGenExitBootServices
)
1694 AutoGenEntryPointSource
+= AutoGenCode
[0]
1695 AutoGenUnloadSource
+= AutoGenCode
[1]
1696 AutoGenDefinitionSource
+= AutoGenCode
[2]
1697 AutoGenDeclaration
+= AutoGenCode
[3]
1699 if (len(AutoGenVirtualAddressChanged
) > 0):
1700 print "[Warning] Please manually add Create Event statement for Virtual Address Change Event!"
1702 AutoGenCode
= AddVirtualAddressEventStatement(AutoGenVirtualAddressChanged
)
1703 AutoGenEntryPointSource
+= AutoGenCode
[0]
1704 AutoGenUnloadSource
+= AutoGenCode
[1]
1705 AutoGenDefinitionSource
+= AutoGenCode
[2]
1706 AutoGenDeclaration
+= AutoGenCode
[3]
1708 if AutoGenEntryPointSource
!= "":
1709 OldEntryPoint
= AutoGenEntryPoint
1710 AutoGenCode
= AddNewEntryPointContentsStatement(BaseName
, AutoGenEntryPoint
, AutoGenEntryPointSource
)
1711 AutoGenEntryPoint
= AutoGenCode
[0]
1712 AutoGenEntryPointSource
= AutoGenCode
[1]
1713 AutoGenDeclaration
+= AutoGenCode
[2]
1716 if AutoGenEntryPoint
!= "":
1717 DriverModules
.insert(0, " %-30s = %s\n" % ("ENTRY_POINT" , AutoGenEntryPoint
))
1719 AutoGenSource
= AutoGenDefinitionSource
+ AutoGenEntryPointSource
+ AutoGenUnloadSource
1722 DefinesComments
.append("#\n")
1724 if (Flag
and len(DefinesComments
) > 0):
1725 DefinesComments
.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1727 if (options
.debug
and options
.verbose
> 2):
1728 if (len(DriverModules
) > 0):
1730 if (len(LibraryModules
) > 0):
1731 print LibraryModules
1732 if (len(DefinesComments
) > 0):
1733 print DefinesComments
1741 for DxsFile
, Archs
in AutoGenDxsFiles
:
1742 fileContents
= openSourceFile(AutoGenModuleFolder
, DxsFile
)
1743 Contents
, Unresolved
= TranslateDpxSection(fileContents
)
1745 print "[warning] Cannot read dxs expression"
1747 if (len(Unresolved
) > 0):
1748 print "[warning] Guid Macro(s): %s cannot find corresponding cNames. Please resolve it in [depex] section in extened inf" % ",".join(Unresolved
)
1750 if ("IA32" in Archs
):
1751 DepexIa32
.insert(0, Contents
)
1752 if ("IPF" in Archs
):
1753 DepexIpf
.insert(0, Contents
)
1754 if ("X64" in Archs
):
1755 DepexX64
.insert(0, Contents
)
1756 if ("EBC" in Archs
):
1757 DepexEbc
.insert(0, Contents
)
1758 if ("ALL" in Archs
):
1759 Depex
.insert(0, Contents
)
1761 AutoGenSourceHeaderFormat
= "/**@file\n %s\n\n %s\n %s\n %s\n**/\n\n%s"
1762 includeCommonHeaderFileStatement
= "#include \"%s\"" % commonHeaderFilename
1764 AutoGenHeader
+= AddSystemIncludeStatement(ModType
, AutoGenPackage
)
1765 AutoGenHeader
+= AddGuidStatement(AutoGenGuid
)
1766 AutoGenHeader
+= AddLibraryClassStatement(AutoGenLibClass
)
1769 saveSourceFile(AutoGenModuleFolder
, "CommonHeader.txt", AutoGenHeader
)
1772 commonHeaderFilename2
= re
.sub("(?=[^a-z])", "_", commonHeaderFilename
)
1773 commonHeaderFilename2
= "_" + commonHeaderFilename2
.replace(".", "").upper() + "_"
1774 briefDiscription
= "Common header file shared by all source files."
1775 detailedDiscription
= "This file includes package header files, library classes and protocol, PPI & GUID definitions.\n"
1776 AutoGenHeader
+= AutoGenDeclaration
1777 AutoGenHeader
= "#ifndef %s\n#define %s\n\n\n%s\n#endif\n" % (commonHeaderFilename2
, commonHeaderFilename2
, AutoGenHeader
)
1778 AutoGenHeader
= AutoGenSourceHeaderFormat
% (briefDiscription
, detailedDiscription
, CopyRight
, License
, AutoGenHeader
)
1779 saveSourceFile(AutoGenModuleFolder
, commonHeaderFilename
, AutoGenHeader
)
1780 SrcFilenames
.append(commonHeaderFilename
)
1782 for source
in AutoGenSourceFiles
:
1783 extension
= os
.path
.splitext(source
)[1]
1784 if extension
== ".c":
1785 sourceContents
= openSourceFile(AutoGenModuleFolder
, source
)
1786 sourceContents
= AddCommonInclusionStatement(sourceContents
, includeCommonHeaderFileStatement
)
1787 saveSourceFile(AutoGenModuleFolder
, source
, sourceContents
)
1790 if AutoGenSource
!= "":
1791 briefDiscription
= "Entry Point Source file."
1792 detailedDiscription
= "This file contains the user entry point \n"
1793 AutoGenSource
= AutoGenSourceHeaderFormat
% (briefDiscription
, detailedDiscription
, CopyRight
, License
, AutoGenSource
)
1794 AutoGenSource
= AddCommonInclusionStatement(AutoGenSource
, includeCommonHeaderFileStatement
)
1796 saveSourceFile(AutoGenModuleFolder
, entryPointFilename
, AutoGenSource
)
1797 SrcFilenames
.append(entryPointFilename
)
1802 # DONE Getting data, now output it in INF format.
1807 """ Print the converted data format """
1808 head
= "#/** @file\n"
1809 head
+= "# " + str(Abstract
) + "\n#\n"
1810 head
+= "# " + str(Description
).strip().replace("\n", "\n# ") + "\n"
1811 head
+= "# " + str(CopyRight
) + "\n#\n"
1812 head
+= "# " + str(License
).replace("\n", "\n# ").replace(" ", " ").strip() + "\n#\n"
1819 ## Defines = "\n" + "#"*80+ "\n#\n"
1820 ## if (BinModule != "false"):
1821 ## Defines += "# Defines Section - statements that will be processed to generate a binary image.\n"
1823 ## Defines += "# Defines Section - statements that will be processed to create a Makefile.\n"
1824 ## Defines += "#\n" + "#"*80 + "\n"
1827 Defines
+= "[Defines]\n"
1828 Defines
+= " %-30s = %s\n" % ("INF_VERSION", "0x00010005")
1829 Defines
+= " %-30s = %s\n" % ("BASE_NAME", BaseName
)
1830 Defines
+= " %-30s = %s\n" % ("FILE_GUID", GuidValue
)
1831 Defines
+= " %-30s = %s\n" % ("MODULE_TYPE", ModType
)
1832 Defines
+= " %-30s = %s\n" % ("VERSION_STRING", VerString
)
1834 if (len(PcdIsDriver
) > 0):
1835 Defines
+= " %-30s = %s\n" % ("PCD_DRIVER", PcdIsDriver
)
1837 if (len(IamLibrary
) > 0):
1839 for lc
in IamLibrary
[:]:
1841 Defines
+= " %-30s = %s" % ("LIBRARY_CLASS", lcstr
)
1844 if (len(SpecList
) > 0):
1845 for spec
in SpecList
[:]:
1846 (specname
, specval
) = spec
.split()
1847 Defines
+= " %-30s = %s\n" % (specname
, specval
)
1850 if (len(DriverModules
) > 0):
1851 for line
in DriverModules
[:]:
1854 if (len(LibraryModules
) > 0):
1855 for line
in LibraryModules
[:]:
1858 if (len(DefinesComments
) > 0):
1859 for line
in DefinesComments
[:]:
1862 Output
.append(Defines
)
1867 if (BinModule
!= "false"):
1868 """ Binary Module, so sources are really binaries. """
1869 ## Sources = "\n" + "#"*80 + "\n#\n"
1870 ## Sources += "# Binaries Section - list of binary files that are required for the build\n# to succeed.\n"
1871 ## Sources += "#\n" + "#"*80 + "\n\n"
1873 if ModType
== "UEFI_APPLICATION":
1874 FileType
= "UEFI_APP"
1875 if options
.verbose
> 0:
1876 print "WARNING: Binary Module: %s is assuming UEFI_APPLICATION file type." % (options
.filename
)
1879 if options
.verbose
> 0:
1880 print "WARNING: Binary Module: %s is assuming FV file type." % (options
.filename
)
1882 if (len(SrcFilenames
) > 0):
1883 Sources
+= "[Binaries.common]\n"
1884 for file in SrcFilenames
[:]:
1885 file = file.replace("\\", "/")
1886 Sources
+= " " + FileType
+ "|" + file + "\n"
1889 if (len(SrcFilenamesIa32
) > 0):
1890 Sources
+= "[Binaries.Ia32]\n"
1891 for file in SrcFilenamesIa32
[:]:
1892 file = file.replace("\\", "/")
1893 Sources
+= " " + FileType
+ "|" + file + "\n"
1896 if (len(SrcFilenamesX64
) > 0):
1897 Sources
+= "[Binaries.X64]\n"
1898 for file in SrcFilenamesX64
[:]:
1899 file = file.replace("\\", "/")
1900 Sources
+= " " + FileType
+ "|" + file + "\n"
1903 if (len(SrcFilenamesIpf
) > 0):
1904 Sources
+= "[Binaries.IPF]\n"
1905 for file in SrcFilenamesIpf
[:]:
1906 file = file.replace("\\", "/")
1907 Sources
+= " " + FileType
+ "|" + file + "\n"
1910 if (len(SrcFilenamesEbc
) > 0):
1911 Sources
+= "[Binaries.EBC]\n"
1912 for file in SrcFilenamesEbc
[:]:
1913 file = file.replace("\\", "/")
1914 Sources
+= " " + FileType
+ "|" + file + "\n"
1917 Output
.append(Sources
)
1921 ## Sources = "\n" + "#"*80 + "\n#\n"
1922 ## Sources += "# Sources Section - list of files that are required for the build to succeed.\n"
1923 ## Sources += "#\n" + "#"*80 + "\n\n"
1925 if (len(SrcFilenames
) > 0):
1926 Sources
+= "[Sources.common]\n"
1927 for file in SrcFilenames
[:]:
1928 Sources
+= " " + file + "\n"
1931 if (len(SrcFilenamesIa32
) > 0):
1932 Sources
+= "[Sources.Ia32]\n"
1933 for file in SrcFilenamesIa32
[:]:
1934 Sources
+= " " + file + "\n"
1937 if (len(SrcFilenamesX64
) > 0):
1938 Sources
+= "[Sources.X64]\n"
1939 for file in SrcFilenamesX64
[:]:
1940 Sources
+= " " + file + "\n"
1943 if (len(SrcFilenamesIpf
) > 0):
1944 Sources
+= "[Sources.IPF]\n"
1945 for file in SrcFilenamesIpf
[:]:
1946 Sources
+= " " + file + "\n"
1949 if (len(SrcFilenamesEbc
) > 0):
1950 Sources
+= "[Sources.EBC]\n"
1951 for file in SrcFilenamesEbc
[:]:
1952 Sources
+= " " + file + "\n"
1955 Output
.append(Sources
)
1961 if ((len(HeaderLocations
) > 0) or (len(Dirs
) > 0)):
1962 allLcs
= set(LibClassList
+ LibClassListIa32
+ LibClassListX64
+ LibClassListIpf
+ LibClassListEbc
+ Dirs
)
1964 for line
in HeaderLocations
[:]:
1966 (keyword
, header
) = line
.split("|")
1969 print "FOUND", Lc
, "in", keyword
, "header", header
1970 path
= "$(WORKSPACE)/" + os
.path
.split(header
)[0]
1971 Lines
.insert(0, path
.strip())
1973 ## Includes = "\n" + "#"*80 + "\n#\n"
1974 ## Includes += "# Includes Section - list of Include locations that are required for\n"
1975 ## Includes += "# this module.\n"
1976 ## Includes += "#\n" + "#"*80 + "\n\n"
1977 ## Includes += "[Includes]\n"
1978 ## includeLines = []
1979 ## includeLines = set(Lines)
1980 ## if (options.debug):
1981 ## print "There are", len(includeLines), "entries"
1982 ## for Line in includeLines:
1983 ## Includes += " " + str(Line).strip().replace("\\", "/") + "\n"
1985 Output
.append(Includes
)
1991 if ((len(PkgList
) + len(PkgListIa32
) + len(PkgListX64
) + len(PkgListIpf
) + len(PkgListEbc
)) > 0):
1992 """ We do this if and only if we have Package Dependencies """
1993 ## PackageDepends = "\n" + "#"*80 + "\n#\n"
1994 ## PackageDepends += "# Package Dependency Section - list of Package files that are required for\n"
1995 ## PackageDepends += "# this module.\n"
1996 ## PackageDepends += "#\n" + "#"*80 + "\n\n"
1997 PackageDepends
= "\n"
1998 if (len(PkgList
) > 0):
1999 PackageDepends
+= "[Packages]\n"
2000 for lc
in PkgList
[:]:
2001 lc
= lc
.replace("\\", "/")
2002 PackageDepends
+= " " + lc
+ "\n"
2003 PackageDepends
+= "\n"
2005 if (len(PkgListIa32
) > 0):
2006 PackageDepends
+= "[Packages.IA32]\n"
2007 for lc
in PkgListIa32
[:]:
2008 lc
= lc
.replace("\\", "/")
2009 PackageDepends
+= " " + lc
+ "\n"
2010 PackageDepends
+= "\n"
2012 if (len(PkgListX64
) > 0):
2013 PackageDepends
+= "[Packages.X64]\n"
2014 for lc
in PkgListX64
[:]:
2015 lc
= lc
.replace("\\", "/")
2016 PackageDepends
+= " " + lc
+ "\n"
2017 PackageDepends
+= "\n"
2019 if (len(PkgListIpf
) > 0):
2020 PackageDepends
+= "[Packages.IPF]\n"
2021 for lc
in PkgListIpf
[:]:
2022 lc
= lc
.replace("\\", "/")
2023 PackageDepends
+= " " + lc
+ "\n"
2024 PackageDepends
+= "\n"
2026 if (len(PkgListEbc
) > 0):
2027 PackageDepends
+= "[Packages.EBC]\n"
2028 for lc
in PkgListEbc
[:]:
2029 lc
= lc
.replace("\\", "/")
2030 PackageDepends
+= " " + lc
+ "\n"
2031 PackageDepends
+= "\n"
2033 Output
.append(PackageDepends
)
2035 print PackageDepends
2037 if ((len(LibClassList
) + len(LibClassListIa32
) + len(LibClassListX64
) + len(LibClassListIpf
) + len(LibClassListEbc
)) > 0):
2038 ## LibraryClasses = "\n" + "#"*80 + "\n#\n"
2039 ## LibraryClasses += "# Library Class Section - list of Library Classes that are required for\n"
2040 ## LibraryClasses += "# this module.\n"
2041 ## LibraryClasses += "#\n" + "#"*80 + "\n\n"
2043 LibraryClasses
= "\n"
2044 if (len(LibClassList
) > 0):
2045 LibraryClasses
+= "[LibraryClasses]\n"
2046 for lc
in LibClassList
[:]:
2047 LibraryClasses
+= " " + lc
+ "\n"
2048 LibraryClasses
+= "\n"
2050 if (len(LibClassListIa32
) > 0):
2051 LibraryClasses
+= "[LibraryClasses.IA32]\n"
2052 for lc
in LibClassListIa32
[:]:
2053 LibraryClasses
+= " " + lc
+ "\n"
2054 LibraryClasses
+= "\n"
2056 if (len(LibClassListX64
) > 0):
2057 LibraryClasses
+= "[LibraryClasses.X64]\n"
2058 for lc
in LibClassListX64
[:]:
2059 LibraryClasses
+= " " + lc
+ "\n"
2060 LibraryClasses
+= "\n"
2062 if (len(LibClassListIpf
) > 0):
2063 LibraryClasses
+= "[LibraryClasses.IPF]\n"
2064 for lc
in LibClassListIpf
[:]:
2065 LibraryClasses
+= " " + lc
+ "\n"
2066 LibraryClasses
+= "\n"
2068 if (len(LibClassListEbc
) > 0):
2069 LibraryClasses
+= "[LibraryClasses.EBC]\n"
2070 for lc
in LibClassListEbc
[:]:
2071 LibraryClasses
+= " " + lc
+ "\n"
2072 LibraryClasses
+= "\n"
2074 Output
.append(LibraryClasses
)
2076 print LibraryClasses
2078 # Print the Guids sections
2079 if (len(GuidCName
) + len(GuidCNameIa32
) + len(GuidCNameIPF
) + len(GuidCNameX64
) + len(GuidCNameEBC
)) > 0:
2080 ## GuidSection = "\n" + "#"*80 + "\n#\n"
2081 ## GuidSection += "# Guid C Name Section - list of Guids that this module uses or produces.\n"
2082 ## GuidSection += "#\n" + "#"*80 + "\n\n"
2084 if (len(GuidCName
) > 0):
2085 GuidSection
+= "[Guids]\n"
2086 for Guid
in GuidCName
[:]:
2087 GuidSection
+= Guid
+ "\n"
2090 if (len(GuidCNameIa32
) > 0):
2091 GuidSection
+= "[Guids.IA32]\n"
2092 for Guid
in GuidCNameIa32
[:]:
2093 GuidSection
+= Guid
+ "\n"
2096 if (len(GuidCNameX64
) > 0):
2097 GuidSection
+= "[Guids.X64]\n"
2098 for Guid
in GuidCNameX64
[:]:
2099 GuidSection
+= Guid
+ "\n"
2102 if (len(GuidCNameIPF
) > 0):
2103 GuidSection
+= "[Guids.IPF]\n"
2104 for Guid
in GuidCNameIPF
[:]:
2105 GuidSection
+= Guid
+ "\n"
2108 if (len(GuidCNameEBC
) > 0):
2109 GuidSection
+= "[Guids.EBC]\n"
2110 for Guid
in GuidCNameEBC
[:]:
2111 GuidSection
+= Guid
+ "\n"
2114 Output
.append(GuidSection
)
2115 if (options
.debug
and options
.verbose
> 1):
2118 # Print the Protocol sections
2119 if (len(ProtocolCName
) + len(ProtocolCNameIa32
) + len(ProtocolCNameIPF
) + len(ProtocolCNameX64
) + len(ProtocolCNameEBC
)) > 0:
2120 ## ProtocolsSection = "\n" + "#"*80 + "\n#\n"
2121 ## ProtocolsSection += "# Protocol C Name Section - list of Protocol and Protocol Notify C Names\n"
2122 ## ProtocolsSection += "# that this module uses or produces.\n"
2123 ## ProtocolsSection += "#\n" + "#"*80 + "\n\n"
2125 ProtocolsSection
= "\n"
2126 if (len(ProtocolCName
) > 0):
2127 ProtocolsSection
+= "[Protocols]\n"
2128 for Guid
in ProtocolCName
[:]:
2129 ProtocolsSection
+= Guid
+ "\n"
2130 ProtocolsSection
+= "\n"
2132 if (len(ProtocolCNameIa32
) > 0):
2133 ProtocolsSection
+= "[Protocols.IA32]\n"
2134 for Guid
in ProtocolCNameIa32
[:]:
2135 ProtocolsSection
+= Guid
+ "\n"
2136 ProtocolsSection
+= "\n"
2138 if (len(ProtocolCNameX64
) > 0):
2139 ProtocolsSection
+= "[Protocols.X64]\n"
2140 for Guid
in ProtocolCNameX64
[:]:
2141 ProtocolsSection
+= Guid
+ "\n"
2142 ProtocolsSection
+= "\n"
2144 if (len(ProtocolCNameIPF
) > 0):
2145 ProtocolsSection
+= "[Protocols.IPF]\n"
2146 for Guid
in ProtocolCNameIPF
[:]:
2147 ProtocolsSection
+= Guid
+ "\n"
2148 ProtocolsSection
+= "\n"
2150 if (len(ProtocolCNameEBC
) > 0):
2151 ProtocolsSection
+= "[Protocols.EBC]\n"
2152 for Guid
in ProtocolCNameEBC
[:]:
2153 ProtocolsSection
+= Guid
+ "\n"
2154 ProtocolsSection
+= "\n"
2156 Output
.append(ProtocolsSection
)
2158 print ProtocolsSection
2160 # Print the PPI sections
2161 if (len(PpiCName
) + len(PpiCNameIa32
) + len(PpiCNameIPF
) + len(PpiCNameX64
) + len(PpiCNameEBC
)) > 0:
2162 ## PpiSection = "\n" + "#"*80 + "\n#\n"
2163 ## PpiSection += "# PPI C Name Section - list of PPI and PPI Notify C Names that this module\n"
2164 ## PpiSection += "# uses or produces.\n"
2165 ## PpiSection += "#\n" + "#"*80 + "\n\n"
2168 if (len(PpiCName
) > 0):
2169 PpiSection
+= "[Ppis]\n"
2170 for Guid
in PpiCName
[:]:
2171 PpiSection
+= Guid
+ "\n"
2174 if (len(PpiCNameIa32
) > 0):
2175 PpiSection
+= "[Ppis.IA32]\n"
2176 for Guid
in PpiCNameIa32
[:]:
2177 PpiSection
+= Guid
+ "\n"
2180 if (len(PpiCNameX64
) > 0):
2181 PpiSection
+= "[Ppis.X64]\n"
2182 for Guid
in PpiCNameX64
[:]:
2183 PpiSection
+= Guid
+ "\n"
2186 if (len(PpiCNameIPF
) > 0):
2187 PpiSection
+= "[Ppis.IPF]\n"
2188 for Guid
in PpiCNameIPF
[:]:
2189 PpiSection
+= Guid
+ "\n"
2192 if (len(PpiCNameEBC
) > 0):
2193 PpiSection
+= "[Ppis.EBC]\n"
2194 for Guid
in PpiCNameEBC
[:]:
2195 PpiSection
+= Guid
+ "\n"
2198 Output
.append(PpiSection
)
2202 # Print the PCD sections
2203 if ((len(PcdFF
)+len(PcdFFIa32
)+len(PcdFFX64
)+len(PcdFFIpf
)+len(PcdFFEbc
)) > 0):
2204 ## FeatureFlagSection = "\n" + "#"*80 + "\n#\n"
2205 ## FeatureFlagSection += "# Pcd FEATURE_FLAG - list of PCDs that this module is coded for.\n"
2206 ## FeatureFlagSection += "#\n" + "#"*80 + "\n\n"
2208 FeatureFlagSection
= "\n"
2209 if (len(PcdFF
) > 0):
2210 FeatureFlagSection
+= "[FeaturePcd.common]\n"
2211 for Entry
in PcdFF
[:]:
2212 FeatureFlagSection
+= " " + Entry
+ "\n"
2213 FeatureFlagSection
+= "\n"
2214 if (len(PcdFFIa32
) > 0):
2215 FeatureFlagSection
+= "[FeaturePcd.IA32]\n"
2216 for Entry
in PcdFFIa32
[:]:
2217 FeatureFlagSection
+= " " + Entry
+ "\n"
2218 FeatureFlagSection
+= "\n"
2219 if (len(PcdFFX64
) > 0):
2220 FeatureFlagSection
+= "[FeaturePcd.X64]\n"
2221 for Entry
in PcdFFX64
[:]:
2222 FeatureFlagSection
+= " " + Entry
+ "\n"
2223 FeatureFlagSection
+= "\n"
2224 if (len(PcdFFIpf
) > 0):
2225 FeatureFlagSection
+= "[PcdsFeatureFlag.IPF]\n"
2226 for Entry
in PcdFFIpf
[:]:
2227 FeatureFlagSection
+= " " + Entry
+ "\n"
2228 FeatureFlagSection
+= "\n"
2229 if (len(PcdFFEbc
) > 0):
2230 FeatureFlagSection
+= "[FeaturePcd.EBC]\n"
2231 for Entry
in PcdFFEbc
[:]:
2232 FeatureFlagSection
+= " " + Entry
+ "\n"
2233 FeatureFlagSection
+= "\n"
2235 Output
.append(FeatureFlagSection
)
2237 print FeatureFlagSection
2239 if ((len(PcdFAB
)+len(PcdFABIa32
)+len(PcdFABX64
)+len(PcdFABIpf
)+len(PcdFABEbc
)) > 0):
2240 ## FixedAtBuildSection = "\n" + "#"*80 + "\n#\n"
2241 ## FixedAtBuildSection += "# Pcd FIXED_AT_BUILD - list of PCDs that this module is coded for.\n"
2242 ## FixedAtBuildSection += "#\n" + "#"*80 + "\n\n"
2244 FixedAtBuildSection
= "\n"
2245 if (len(PcdFAB
) > 0):
2246 FixedAtBuildSection
+= "[FixedPcd.common]\n"
2247 for Entry
in PcdFAB
[:]:
2248 FixedAtBuildSection
+= " " + Entry
+ "\n"
2249 FixedAtBuildSection
+= "\n"
2250 if (len(PcdFABIa32
) > 0):
2251 FixedAtBuildSection
+= "[FixedPcd.IA32]\n"
2252 for Entry
in PcdFABIa32
[:]:
2253 FixedAtBuildSection
+= " " + Entry
+ "\n"
2254 FixedAtBuildSection
+= "\n"
2255 if (len(PcdFABX64
) > 0):
2256 FixedAtBuildSection
+= "[FixedPcd.X64]\n"
2257 for Entry
in PcdFABX64
[:]:
2258 FixedAtBuildSection
+= " " + Entry
+ "\n"
2259 FixedAtBuildSection
+= "\n"
2260 if (len(PcdFABIpf
) > 0):
2261 FixedAtBuildSection
+= "[FixedPcd.IPF]\n"
2262 for Entry
in PcdFABIpf
[:]:
2263 FixedAtBuildSection
+= " " + Entry
+ "\n"
2264 FixedAtBuildSection
+= "\n"
2265 if (len(PcdFABEbc
) > 0):
2266 FixedAtBuildSection
+= "[FixedPcd.EBC]\n"
2267 for Entry
in PcdFABEbc
[:]:
2268 FixedAtBuildSection
+= " " + Entry
+ "\n"
2269 FixedAtBuildSection
+= "\n"
2271 Output
.append(FixedAtBuildSection
)
2273 print FixedAtBuildSection
2275 if ((len(PcdPIM
)+len(PcdPIMIa32
)+len(PcdPIMX64
)+len(PcdPIMIpf
)+len(PcdPIMEbc
)) > 0):
2276 ## PatchableInModuleSection = "\n" + "#"*80 + "\n#\n"
2277 ## PatchableInModuleSection += "# Pcd PATCHABLE_IN_MODULE - list of PCDs that this module is coded for.\n"
2278 ## PatchableInModuleSection += "#\n" + "#"*80 + "\n\n"
2280 PatchableInModuleSection
= "\n"
2281 if (len(PcdPIM
) > 0):
2282 PatchableInModuleSection
+= "[PatchPcd.common]\n"
2283 for Entry
in PcdPIM
[:]:
2284 PatchableInModuleSection
+= " " + Entry
+ "\n"
2285 PatchableInModuleSection
+= "\n"
2286 if (len(PcdPIMIa32
) > 0):
2287 PatchableInModuleSection
+= "[PatchPcd.IA32]\n"
2288 for Entry
in PcdPIMIa32
[:]:
2289 PatchableInModuleSection
+= " " + Entry
+ "\n"
2290 PatchableInModuleSection
+= "\n"
2291 if (len(PcdPIMX64
) > 0):
2292 PatchableInModuleSection
+= "[PatchPcd.X64]\n"
2293 for Entry
in PcdPIMX64
[:]:
2294 PatchableInModuleSection
+= " " + Entry
+ "\n"
2295 PatchableInModuleSection
+= "\n"
2296 if (len(PcdPIMIpf
) > 0):
2297 PatchableInModuleSection
+= "[PatchPcd.IPF]\n"
2298 for Entry
in PcdPIMIpf
[:]:
2299 PatchableInModuleSection
+= " " + Entry
+ "\n"
2300 PatchableInModuleSection
+= "\n"
2301 if (len(PcdPIMEbc
) > 0):
2302 PatchableInModuleSection
+= "[PatchPcd.EBC]\n"
2303 for Entry
in PcdPIMEbc
[:]:
2304 PatchableInModuleSection
+= " " + Entry
+ "\n"
2305 PatchableInModuleSection
+= "\n"
2307 Output
.append(PatchableInModuleSection
)
2309 print PatchableInModuleSection
2311 if ((len(PcdDYE
)+len(PcdDYEIa32
)+len(PcdDYEX64
)+len(PcdDYEIpf
)+len(PcdDYEEbc
)) > 0):
2312 ## DynamicExSection = "\n" + "#"*80 + "\n#\n"
2313 ## DynamicExSection += "# Pcd DYNAMIC_EX - list of PCDs that this module is coded for.\n"
2314 ## DynamicExSection += "#\n" + "#"*80 + "\n\n"
2316 DynamicExSection
= "\n"
2317 if (len(PcdDYE
) > 0):
2318 DynamicExSection
+= "[PcdEx.common]\n"
2319 for Entry
in PcdDYE
[:]:
2320 DynamicExSection
+= " " + Entry
+ "\n"
2321 DynamicExSection
+= "\n"
2322 if (len(PcdDYEIa32
) > 0):
2323 DynamicExSection
+= "[PcdEx.IA32]\n"
2324 for Entry
in PcdDYEIa32
[:]:
2325 DynamicExSection
+= " " + Entry
+ "\n"
2326 DynamicExSection
+= "\n"
2327 if (len(PcdDYEX64
) > 0):
2328 DynamicExSection
+= "[PcdEx.X64]\n"
2329 for Entry
in PcdDYEX64
[:]:
2330 DynamicExSection
+= " " + Entry
+ "\n"
2331 DynamicExSection
+= "\n"
2332 if (len(PcdDYEIpf
) > 0):
2333 DynamicExSection
+= "[PcdEx.IPF]\n"
2334 for Entry
in PcdDYEIpf
[:]:
2335 DynamicExSection
+= " " + Entry
+ "\n"
2336 DynamicExSection
+= "\n"
2337 if (len(PcdDYEEbc
) > 0):
2338 DynamicExSection
+= "[PcdEx.EBC]\n"
2339 for Entry
in PcdDYEEbc
[:]:
2340 DynamicExSection
+= " " + Entry
+ "\n"
2341 DynamicExSection
+= "\n"
2343 Output
.append(DynamicExSection
)
2345 print DynamicExSection
2347 if ((len(PcdDY
)+len(PcdDYIa32
)+len(PcdDYX64
)+len(PcdDYIpf
)+len(PcdDYEbc
)) > 0):
2348 ## DynamicSection = "\n" + "#"*80 + "\n#\n"
2349 ## DynamicSection += "# Pcd DYNAMIC - list of PCDs that this module is coded for.\n"
2350 ## DynamicSection += "#\n" + "#"*80 + "\n\n"
2352 DynamicSection
= "\n"
2353 if (len(PcdDY
) > 0):
2354 DynamicSection
+= "[Pcd.common]\n"
2355 for Entry
in PcdDY
[:]:
2356 DynamicSection
+= " " + Entry
+ "\n"
2357 DynamicSection
+= "\n"
2358 if (len(PcdDYIa32
) > 0):
2359 DynamicSection
+= "[Pcd.IA32]\n"
2360 for Entry
in PcdDYIa32
[:]:
2361 DynamicSection
+= " " + Entry
+ "\n"
2362 DynamicSection
+= "\n"
2363 if (len(PcdDYX64
) > 0):
2364 DynamicSection
+= "[Pcd.X64]\n"
2365 for Entry
in PcdDYX64
[:]:
2366 DynamicSection
+= " " + Entry
+ "\n"
2367 DynamicSection
+= "\n"
2368 if (len(PcdDYIpf
) > 0):
2369 DynamicSection
+= "[Pcd.IPF]\n"
2370 for Entry
in PcdDYIpf
[:]:
2371 DynamicSection
+= " " + Entry
+ "\n"
2372 DynamicSection
+= "\n"
2373 if (len(PcdDYEbc
) > 0):
2374 DynamicSection
+= "[Pcd.EBC]\n"
2375 for Entry
in PcdDYEbc
[:]:
2376 DynamicSection
+= " " + Entry
+ "\n"
2377 DynamicSection
+= "\n"
2379 Output
.append(DynamicSection
)
2381 print DynamicSection
2383 if ((len(Depex
) + len(DepexIa32
) + len(DepexX64
) + len(DepexIpf
) + len(DepexEbc
)) > 0):
2384 """ We do this if and only if we have Package Dependencies """
2385 ## Dpx = "\n" + "#"*80 + "\n#\n"
2386 ## Dpx += "# Dependency Expression Section - list of Dependency expressions that are required for\n"
2387 ## Dpx += "# this module.\n"
2388 ## Dpx += "#\n" + "#"*80 + "\n\n"
2390 if (len(Depex
) > 0):
2393 Dpx
+= " " + lc
+ "\n"
2396 if (len(DepexIa32
) > 0):
2397 Dpx
+= "[Depex.IA32]\n"
2398 for lc
in DepexIa32
[:]:
2399 Dpx
+= " " + lc
+ "\n"
2402 if (len(DepexX64
) > 0):
2403 Dpx
+= "[Depex.X64]\n"
2404 for lc
in DepexX64
[:]:
2405 Dpx
+= " " + lc
+ "\n"
2408 if (len(DepexIpf
) > 0):
2409 Dpx
+= "[Depex.IPF]\n"
2410 for lc
in DepexIpf
[:]:
2411 Dpx
+= " " + lc
+ "\n"
2414 if (len(DepexEbc
) > 0):
2415 Dpx
+= "[Depex.EBC]\n"
2416 for lc
in DepexEbc
[:]:
2417 Dpx
+= " " + lc
+ "\n"
2424 if (len(MBOlines
) > 0):
2426 ## BuildSection = "\n" + "#"*80 + "\n#\n"
2427 ## BuildSection += "# Build Options - list of custom build options for this module.\n"
2428 ## BuildSection += "#\n" + "#"*80 + "\n\n"
2429 BuildSection
+= "\n[BuildOptions]\n"
2430 for mbo
in MBOlines
:
2431 tool
, targs
= mbo
.split("=",2)
2432 BuildSection
+= " %-40s = %s\n" % (tool
.strip(), targs
.strip())
2434 Output
.append(BuildSection
)
2439 if (len(UEList
) > 0):
2440 UserExtensionSection
= ""
2441 for UE
in UEList
[:]:
2442 UserExtensionSection
+= "[UserExtensions." + UE
[0] + '."' + UE
[1] + '"]\n'
2443 if (len(UE
[2]) > 0):
2444 UserExtensionSection
+= '"' + UE
[2] + '"\n'
2446 UserExtensionSection
+= "\n"
2448 Output
.append(UserExtensionSection
)
2450 print UserExtensionSection
2452 print "write file", outputFile
2453 if (options
.autowrite
):
2454 fo
= open(outputFile
, "w")
2455 for Section
in Output
[:]:
2456 fo
.writelines(Section
)
2457 if (options
.verbose
> 1):
2460 elif (options
.outfile
):
2461 fo
= open(outputFile
, "w")
2462 for Section
in Output
[:]:
2463 fo
.writelines(Section
)
2466 for Section
in Output
[:]:
2470 if __name__
== '__main__':
2474 options
,args
= myOptionParser()