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
197 FdbPath = os.path.join(workspace, "Tools")
198 FdbPath = os.path.join(FdbPath, "Conf")
199 FdbPath = os.path.join(FdbPath, "FrameworkDatabase.db")
200 if os.path.exists(FdbPath):
203 FdbPath = os.path.join(workspace, "Conf")
204 FdbPath = os.path.join(FdbPath, "FrameworkDatabase.db")
205 if os.path.exists(FdbPath):
208 print "ERROR: E0001: WORKSPACE does not contain the FrameworkDatabase File.\n Please run EdkSetup from the EDK II install directory.\n"
211 Fdb = openDatabase(FdbFile)
213 print "ERROR: E0002 Could not open the Framework Database file:", FdbFile
217 print "FrameworkDataBase.db file:", FdbFile
220 InitializeAutoGen(workspace, Fdb)
222 if (options.filename):
223 filename = options.filename
224 if ((options.verbose > 1) | (options.autowrite)):
225 print "Filename:", filename
227 print "ERROR: E0001 - You must specify an input filename"
230 if (options.outfile):
231 outputFile = options.outfile
233 outputFile = filename.replace('.msa', '.inf')
235 if ((options.verbose > 2) or (options.debug)):
236 print "Output Filename:", outputFile
238 Msa = openMsa(filename)
240 ## Maybe developer think WORKSPACE macro is the root directory of file name
241 ## So we will try to add WORKSPACE path into filename
243 MsaFileName = os.path.join(workspace, filename)
244 Msa = openMsa(MsaFileName)
246 print "ERROR: E0002: Could not open the file:", filename
249 AutoGenModuleFolder = os.path.dirname(filename)
251 MsaHeader = "/ModuleSurfaceArea/MsaHeader/"
252 MsaDefs = "/ModuleSurfaceArea/ModuleDefinitions/"
253 BaseName = str(XmlElement(Msa, MsaDefs + "OutputFileBasename")).strip()
255 if (len(BaseName) < 1):
256 BaseName = str(XmlElement(Msa, MsaHeader + "BaseName")).strip()
257 BaseName = re.sub(' ', '_', BaseName)
259 GuidValue = str(XmlElement(Msa, MsaHeader + "GuidValue")).strip()
260 VerString = str(XmlElement(Msa, MsaHeader + "Version")).strip()
261 ModType = str(XmlElement(Msa, MsaHeader + "ModuleType")).strip()
262 CopyRight = str(XmlElement(Msa, MsaHeader + "Copyright")).strip()
263 Abstract = str(XmlElement(Msa, MsaHeader + "Abstract")).strip()
264 Description = str(XmlElement(Msa, MsaHeader + "Description")).strip().replace(" ", " ").replace(" ", " ").replace(" ", " ")
265 if not CopyRight.find("2007"):
266 CopyRight = CopyRight.replace("2006", "2007")
267 License = str(XmlElement(Msa, MsaHeader + "License")).strip().replace(" ", " ")
268 MsaDefs = "/ModuleSurfaceArea/ModuleDefinitions/"
271 BinModule = str(XmlElement(Msa, MsaDefs + "BinaryModule")).strip()
275 SupportedArchitectures = ""
277 SupportedArchitectures = str(XmlElement(Msa, MsaDefs + "SupportedArchitectures")).strip()
282 if (len(SupportedArchitectures) > 0):
283 DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
284 DefinesComments.append("# VALID_ARCHITECTURES = " + SupportedArchitectures + "\n")
285 DefinesComments.append("#\n")
287 MsaExtern = "/ModuleSurfaceArea/Externs/"
290 PcdIsDriver = str(XmlElement(Msa, MsaExtern + "PcdIsDriver")).strip()
297 List = XmlList(Msa, MsaExtern + "Specification")
303 SpecList.insert(0, str(XmlElementData(spec)).strip())
308 Flag = (DefinesComments == [])
310 # Data structure to insert autogen code
311 AutoGenDriverModel = []
312 AutoGenExitBootServices = []
313 AutoGenVirtualAddressChanged = []
314 AutoGenEntryPoint = ""
319 AutoGenSourceFiles = []
324 Externlist = XmlList(Msa, MsaExtern + "Extern")
328 if (len(Externlist) > 0):
329 if (options.debug and options.verbose > 2):
330 print "In Extern Parsing Routine"
331 for extern in Externlist:
342 AutoGenDriverModelItem = []
344 EntryPoint = str(XmlElementData(extern.getElementsByTagName("ModuleEntryPoint")[0])).strip()
345 AutoGenEntryPoint = EntryPoint
346 #DriverModules.append(" %-30s = %s\n" % ("ENTRY_POINT" , EntryPoint))
351 Unload = str(XmlElementData(extern.getElementsByTagName("ModuleUnloadImage")[0])).strip()
352 AutoGenUnload = Unload
353 DriverModules.append(" %-30s = %s\n" % ("UNLOAD_IMAGE", Unload))
358 DBinding = str(XmlElementData(extern.getElementsByTagName("DriverBinding")[0])).strip()
359 AutoGenDriverModelItem.append("&" + DBinding)
360 DefinesComments.append("# %-29s = %-45s\n" % ("DRIVER_BINDING", DBinding))
366 CompName = str(XmlElementData(extern.getElementsByTagName("ComponentName")[0])).strip()
367 AutoGenDriverModelItem.append("&" + CompName)
368 DefinesComments.append("# %-29s = %-45s\n" % ("COMPONENT_NAME", CompName))
372 AutoGenDriverModelItem.append("NULL")
376 Config = str(XmlElementData(extern.getElementsByTagName("DriverConfig")[0])).strip()
377 AutoGenDriverModelItem.append("&" + Config)
378 DefinesComments.append("# %-29s = %-45s\n" % ("DRIVER_CONFIG", Config))
382 AutoGenDriverModelItem.append("NULL")
386 Diag = str(XmlElementData(extern.getElementsByTagName("DriverDiag")[0])).strip()
387 AutoGenDriverModelItem.append("&" + Diag)
388 DefinesComments.append("# %-29s = %-45s\n" % ("DRIVER_DIAG", Diag))
392 AutoGenDriverModelItem.append("NULL")
395 if len(AutoGenDriverModelItem) > 0:
396 AutoGenDriverModel.append(AutoGenDriverModelItem)
399 Constr = str(XmlElementData(extern.getElementsByTagName("Constructor")[0])).strip()
400 LibraryModules.append(" %-30s = %s\n" % ("CONSTRUCTOR", Constr))
405 Destr = str(XmlElementData(extern.getElementsByTagName("Destructor")[0])).strip()
406 LibraryModules.append(" %-30s = %s\n" % ("DESTRUCTOR", Destr))
411 CallBack = str(XmlElement(extern, "Extern/SetVirtualAddressMapCallBack")).strip()
413 AutoGenVirtualAddressChanged.append(CallBack)
414 DefinesComments.append("# %-29s = %-45s\n" % ("VIRTUAL_ADDRESS_MAP_CALLBACK", CallBack))
421 CallBack = str(XmlElement(extern, "Extern/ExitBootServicesCallBack")).strip()
423 AutoGenExitBootServices.append(CallBack)
424 DefinesComments.append("# %-29s = %-45s\n" % ("EXIT_BOOT_SERVICES_CALLBACK", CallBack))
432 """ Get the Module's custom build options """
434 MBO = "/ModuleSurfaceArea/ModuleBuildOptions/Options/Option"
437 mboList = XmlList(Msa, MBO)
441 if (len(mboList) > 0):
442 for Option in mboList:
448 bt = str(Option.getAttribute("BuildTargets"))
453 if (re.findall(" ", bt) > 0):
456 Targets.insert(0, bt)
458 Targets.insert(0, "*")
460 if (options.debug and options.verbose > 2):
461 print "Targets", len(Targets), Targets
465 pro = Option.getAttribute("SupArchList")
466 if (re.findall(" ", pro) > 0):
468 elif (re.findall(",", pro) > 0):
469 Archs = pro.split(",")
476 if (options.debug and options.verbose > 2):
477 print "Archs", len(Archs), Archs
481 ToolCode = str(Option.getAttribute("ToolCode"))
485 if (len(ToolCode) == 0):
490 value = str(XmlElementData(Option))
496 TagName = str(Option.getAttribute("TagName"))
500 if (len(TagName) > 0) :
501 if (options.debug and options.verbose > 2):
502 print "TagName was defined:", TagName
503 Tags.insert(0, TagName)
505 if (options.debug and options.verbose > 2):
506 print "TagName was NOT defined!"
512 Family = str(Option.getAttribute("ToolChainFamily")).strip()
516 if (len(Family) > 0):
518 print "Searching tools_def.txt for Tool Tags that belong to:", Family, "family"
521 tdPath = os.path.join(workspace, "Tools")
522 tdPath = os.path.join(tdPath, "Conf")
523 tdPath = os.path.join(tdPath, "tools_def.txt")
524 tdPath = tdPath.replace("\\", "/")
525 if os.path.exists(tdPath):
528 tdPath = os.path.join(workspace, "Conf")
529 tdPath = os.path.join(tdPath, "tools_def.txt")
530 if os.path.exists(tdPath):
533 print "ERROR: E0001: WORKSPACE does not contain the tools_def.txt File.\n Please run EdkSetup from the EDK II install directory.\n"
536 if (options.debug and options.verbose > 2):
537 print "Opening:", tdFile
540 tools_def = open(tdFile, "r")
541 for tdline in tools_def:
544 if "FAMILY" in tdline:
545 if (options.debug and options.verbose > 2):
546 print "Testing for FAMILY:", Family, "in the line:", tdline.strip()
548 enter = tdline.split("=")[0]
549 if (options.debug and options.verbose > 2):
550 print "Adding TNL:", tdline
551 TagNameList.insert(0, enter)
554 if (options.debug and options.verbose > 2):
555 print "TagNameList:", TagNameList
558 for eline in TagNameList:
561 if (options.debug and options.verbose > 2):
562 print "ToolsDef entry:", eline
564 olines = MatchOption(eline, Family, Targets, Archs, ToolCode, value)
568 for oline in olinesSet:
569 if (options.debug and options.verbose > 2):
570 print "Adding:", str(oline)
571 MBOlines.insert(0, oline)
575 oline = " %s_%s_%s_%s_FLAGS = %s" % (targ, Tags[0], arch, str(ToolCode), str(Value))
576 if (options.debug and options.verbose > 2):
577 print "Adding:", str(oline)
578 MBOlines.insert(0, oline)
586 oline = " " + str(targ) + "_" + str(tag) + "_" + str(arch) + "_" + str(ToolCode) + "_FLAGS = " + str(value)
587 if (options.debug and options.verbose > 2):
588 print "Adding:", str(oline)
589 #MBOlines.insert(0, oline)
592 """ Get the Library Class information """
593 MsaLcDefs = "/ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass"
596 LcDefList = XmlList(Msa, MsaLcDefs)
602 LibClassListIa32 = []
608 if (len(LcDefList) > 0):
612 lcKeyword = str(XmlElementData(Lc.getElementsByTagName("Keyword")[0]))
614 raise SyntaxError, "The MSA is not correctly formed, a Library Class Keyword Element is required"
618 lcUsage = str(XmlAttribute(Lc, "Usage"))
620 raise SyntaxError, "The MSA is not correctly formed, a Usage Attribute is required for all Library Class Elements"
624 Archs = str(XmlAttribute(Lc, "SupArchList"))
628 Archs = chkArch(Archs)
630 if (options.debug and options.verbose > 2):
631 print "Attr: ", lcUsage, lcKeyword, Archs
633 if (options.convert):
634 lcKeyword = AutoGenLibraryMapping.get(lcKeyword, lcKeyword)
636 if re.findall("PRODUCED", lcUsage, re.IGNORECASE):
641 lcSupModList = str(XmlAttribute(Lc, "SupModuleList"))
647 AutoGenLibClass.append(lcKeyword)
648 if len(lcSupModList) > 0:
649 lcLine = lcLine + "|" + lcSupModList
650 IamLibrary.insert(0, lcLine)
653 elif lcKeyword != "UefiDriverModelLib":
654 AutoGenLibClass.append(lcKeyword)
655 # This section handles the library classes that are CONSUMED
657 LibClassListIa32.insert(0, lcKeyword)
659 LibClassListX64.insert(0, lcKeyword)
661 LibClassListIpf.insert(0, lcKeyword)
663 LibClassListEbc.insert(0, lcKeyword)
665 LibClassList.insert(0, lcKeyword)
666 if len(AutoGenDriverModel) > 0 and "UefiLib" not in LibClassList:
667 AutoGenLibClass.append("UefiLib")
668 LibClassList.insert(0, "UefiLib")
671 """ Get the Source File list """
673 SrcFilenamesIa32 = []
677 SrcFiles = "/ModuleSurfaceArea/SourceFiles/Filename"
680 SrcList = XmlList(Msa, SrcFiles)
684 if (len(SrcList) > 0):
690 Archs = fn.getAttribute("SupArchList")
694 Archs = chkArch(Archs)
697 file = str(XmlElementData(fn))
701 if file.endswith(".dxs"):
702 AutoGenDxsFiles.append((file, Archs))
704 AutoGenSourceFiles.append(file)
706 SrcFilenamesIa32.insert(0, file)
708 SrcFilenamesX64.insert(0, file)
710 SrcFilenamesIpf.insert(0, file)
712 SrcFilenamesEbc.insert(0, file)
714 SrcFilenames.insert(0, file)
716 """ Package Dependency section """
717 DbPkgList = "/FrameworkDatabase/PackageList/Filename"
720 WorkspacePkgs = XmlList(Fdb, DbPkgList)
722 print "Could not tet the package data from the database"
728 if (options.debug and options.verbose > 1):
729 print "Found %s packages in the WORKSPACE" % (len(WorkspacePkgs))
733 if (len(WorkspacePkgs) > 0):
734 SpdHeader = "/PackageSurfaceArea/SpdHeader/"
735 for Pkg in WorkspacePkgs[:]:
740 file = str(XmlElementData(Pkg))
744 if (options.debug and options.verbose > 2):
747 if fnmatch.fnmatch(file, "*.dec"):
748 print "parsing " + os.path.join(workspace, file)
752 Lines = open(os.path.join(workspace, file)).readlines()
754 print "Could not parse the Package file:", file
758 Line = Line.split("#")[0]
759 Items = Line.split("=")
763 Key = Items[0].strip().upper()
764 if Key == "PACKAGE_GUID":
765 PackageGuid = Items[1].strip()
766 if Key == "PACKAGE_VERSION":
767 PackageVersion = Items[1].strip()
770 Spd = openSpd(os.path.join(workspace, file))
772 print "Could not parse the Package file:", file
775 path = os.path.split(file)[0]
776 file = file.replace(".nspd", ".dec")
777 file = file.replace(".spd", ".dec")
780 PackageGuid = str(XmlElement(Spd, SpdHeader + "GuidValue"))
785 PackageVersion = str(XmlElement(Spd, SpdHeader + "Version"))
789 file = file + "|" + PackageGuid + "|" + PackageVersion
790 PkgDb.insert(0, file)
794 GuidEntries = XmlList(Spd, "/PackageSurfaceArea/GuidDeclarations/Entry")
798 if (len(GuidEntries) > 0):
799 for Entry in GuidEntries[:]:
801 GuidDecls.append(str(XmlElementData(Entry.getElementsByTagName("C_Name")[0])).strip())
808 pHdrs = XmlList(Spd, "/PackageSurfaceArea/PackageHeaders/IncludePkgHeader")
815 ModTypeList = str(Hdr.getAttribute("ModuleType"))
816 if (ModType in ModTypeList):
817 HeaderName= str(XmlElementData(Hdr))[0]
818 Dirs.insert(0, os.path.join(packagepath,str(os.path.split(HeaderName))))
822 # Get the Guid:Header from the Packages
823 SpdLcDec = "/PackageSurfaceArea/LibraryClassDeclarations/LibraryClass"
826 lcList = XmlList(Spd, SpdLcDec)
830 if (len(lcList) > 0):
834 Name = Lc.getAttribute("Name")
840 Header = XmlElementData(Lc.getElementsByTagName("IncludeHeader")[0])
844 if ((len(Name) > 0) and (len(Header) > 0)):
845 line = Name + "|" + os.path.join(path, Header)
846 if (options.debug and options.verbose > 2):
847 print "Adding:", line
848 HeaderLocations.insert(0, line)
852 IndStdHeaders = "/PackageSurfaceArea/IndustryStdIncludes/IndustryStdHeader"
853 ishList = XmlList(Spd, IndStdHeaders)
857 if (len(ishList) > 0):
858 for Lc in ishList[:]:
861 Name = str(Lc.getAttribute("Name")).strip()
867 Header = str(XmlElementData(Lc.getElementsByTagName("IncludeHeader")[0])).strip()
871 if ((len(Name) > 0) and (len(Header) > 0)):
872 line = Name + "|" + os.path.join(path, Header)
873 HeaderLocations.insert(0, str(line))
880 Pkgs = "/ModuleSurfaceArea/PackageDependencies/Package"
883 pkgL = XmlList(Msa, Pkgs)
890 if (options.debug and options.verbose > 1):
891 print "Found %s packages in the module" % (len(pkgL))
899 Archs = pkg.getAttribute("SupArchList")
903 Archs = chkArch(Archs)
906 pkgGuid = pkg.getAttribute("PackageGuid")
911 if pkgGuid.lower() == "5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec":
912 pkgGuid = "1E73767F-8F52-4603-AEB4-F29B510B6766"
913 if pkgGuid.lower() == "68169ab0-d41b-4009-9060-292c253ac43d":
914 pkgGuid = "BA0D78D6-2CAF-414b-BD4D-B6762A894288"
915 AutoGenPackage.append(pkgGuid)
917 pkgVer = pkg.getAttribute("PackageVersion")
921 for PkgEntry in PkgDb[:]:
922 if pkgGuid in PkgEntry:
924 if pkgVer in PkgEntry:
927 PkgListIa32.insert(0, PkgEntry.split("|")[0])
929 PkgListX64.insert(0, PkgEntry.split("|")[0])
931 PkgListIpf.insert(0, PkgEntry.split("|")[0])
933 PkgListEbc.insert(0, PkgEntry.split("|")[0])
935 PkgList.insert(0, PkgEntry.split("|")[0])
939 PkgListIa32.insert(0, PkgEntry.split("|")[0])
941 PkgListX64.insert(0, PkgEntry.split("|")[0])
943 PkgListIpf.insert(0, PkgEntry.split("|")[0])
945 PkgListEbc.insert(0, PkgEntry.split("|")[0])
947 PkgList.insert(0, PkgEntry.split("|")[0])
950 gUnknownPkgGuid[str(pkgGuid)] = 1
952 for UnknownPkgGuid in gUnknownPkgGuid:
953 print "Cannot resolve package dependency Guid:", UnknownPkgGuid
956 PkgListIa32.reverse()
961 print "Package List:", PkgList
965 """ Setup the Global GuidCName arrays that will hold data from various MSA locations """
977 """ Check for the GUIDs Element """
978 Guids = "/ModuleSurfaceArea/Guids/GuidCNames"
981 GuidList = XmlList(Msa, Guids)
985 if (len(GuidList) > 0):
986 for Guid in GuidList:
992 Archs = Guid.getAttribute("SupArchList")
996 Archs = chkArch(Archs)
999 Usage = Guid.getAttribute("Usage")
1004 CName = str(XmlElementData(Guid.getElementsByTagName("GuidCName")[0]))
1005 if CName in GuidDecls:
1006 if (options.debug and options.verbose > 1):
1007 print "Guids Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
1008 AddGuid(Archs, CName, Usage)
1009 AutoGenGuid.append(CName)
1011 raise AssertionError, "Guid %s defined in %s is not declared in any package (.dec) file!" % (CName, filename)
1015 if (options.debug and options.verbose > 2):
1016 print "Guid C Name List:", GuidCName
1018 """ Check for Events """
1019 Guids = "/ModuleSurfaceArea/Events/CreateEvents/EventTypes"
1022 GuidList = XmlList(Msa, Guids)
1026 if (len(GuidList) > 0):
1027 for Guid in GuidList:
1033 Archs = Guid.getAttribute("SupArchList")
1037 Archs = chkArch(Archs)
1040 Usage = Guid.getAttribute("Usage")
1041 Type = str(XmlElementData(Guid.getElementsByTagName("EventType")[0]))
1042 Usage += " Create Event: " + Type
1047 CName = str(Guid.getAttribute("EventGuidCName"))
1048 if CName in GuidDecls:
1049 if (options.debug and options.verbose > 1):
1050 print "CreateEvent Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
1051 AddGuid(Archs, CName, Usage)
1052 AutoGenGuid.append(CName)
1054 if (len(DefinesComments) == 0):
1055 DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1056 DefinesComments.append("# Create Event Guid C Name: " + CName + " Event Type: " + Type + "\n")
1062 DefinesComments.append("#\n")
1065 Guids = "/ModuleSurfaceArea/Events/SignalEvents/EventTypes"
1068 GuidList = XmlList(Msa, Guids)
1072 if (len(GuidList) > 0):
1073 for Guid in GuidList:
1079 Archs = Guid.getAttribute("SupArchList")
1083 Archs = chkArch(Archs)
1086 Usage = Guid.getAttribute("Usage")
1087 Type = str(XmlElementData(Guid.getElementsByTagName("EventType")[0]))
1088 Usage += " Signal Event: " + Type
1093 CName = str(Guid.getAttribute("EventGuidCName"))
1094 if CName in GuidDecls:
1095 if (options.debug and options.verbose > 1):
1096 print "SignalEvent Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
1097 AddGuid(Archs, CName, Usage)
1098 AutoGenGuid.append(CName)
1100 if (len(DefinesComments) == 0):
1101 DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1102 DefinesComments.append("# Signal Event Guid C Name: " + CName + " Event Type: " + Type + "\n")
1108 DefinesComments.append("#\n")
1111 """ Check the HOB guids """
1112 Guids = "/ModuleSurfaceArea/Hobs/HobTypes"
1115 GuidList = XmlList(Msa, Guids)
1119 if (len(GuidList) > 0):
1120 for Guid in GuidList:
1126 Archs = Guid.getAttribute("SupArchList")
1130 Archs = chkArch(Archs)
1133 Usage = Guid.getAttribute("Usage")
1134 Type = str(XmlElementData(Guid.getElementsByTagName("HobType")[0]))
1135 Usage += " Hob: " + Type
1140 CName = str(Guid.getAttribute("HobGuidCName"))
1141 if CName in GuidDecls:
1142 if (options.debug and options.verbose > 1):
1143 print "Hob Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
1144 AddGuid(Archs, CName, Usage)
1145 AutoGenGuid.append(CName)
1147 if (len(DefinesComments) == 0):
1148 DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1149 DefinesComments.append("# HOB Guid C Name: " + CName + " Hob Type: " + Type + "\n")
1152 if (len(DefinesComments) == 0):
1153 DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1154 DefinesComments.append("# HOB: " + Type + "\n")
1159 DefinesComments.append("#\n")
1162 """ Check for the SystemTables Element """
1163 Guids = "/ModuleSurfaceArea/SystemTables/SystemTableCNames"
1166 GuidList = XmlList(Msa, Guids)
1170 if (len(GuidList) > 0):
1171 for Guid in GuidList:
1177 Archs = Guid.getAttribute("SupArchList")
1181 Archs = chkArch(Archs)
1184 Usage = Guid.getAttribute("Usage")
1185 Usage += " System Table"
1190 CName = str(XmlElementData(Guid.getElementsByTagName("SystemTableCName")[0]))
1191 if (options.debug and options.verbose > 1):
1192 print "System Table Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
1193 AddGuid(Archs, CName, Usage)
1194 AutoGenGuid.append(CName)
1198 """ Check for the DataHubs Element """
1199 Guids = "/ModuleSurfaceArea/DataHubs/DataHubRecord"
1202 GuidList = XmlList(Msa, Guids)
1206 if (len(GuidList) > 0):
1207 for Guid in GuidList:
1213 Archs = Guid.getAttribute("SupArchList")
1217 Archs = chkArch(Archs)
1220 Usage = Guid.getAttribute("Usage")
1221 Usage += " Data Hub"
1226 CName = str(XmlElementData(Guid.getElementsByTagName("DataHubCName")[0]))
1227 if (options.debug and options.verbose > 1):
1228 print "Data Hub Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
1229 AddGuid(Archs, CName, Usage)
1230 AutoGenGuid.append(CName)
1234 """ Check for the HiiPackages Element """
1235 Guids = "/ModuleSurfaceArea/HiiPackages/HiiPackage"
1238 GuidList = XmlList(Msa, Guids)
1242 if (len(GuidList) > 0):
1243 for Guid in GuidList:
1249 Archs = Guid.getAttribute("SupArchList")
1253 Archs = chkArch(Archs)
1256 Usage = Guid.getAttribute("Usage")
1257 Usage += " HII Formset"
1262 CName = str(XmlElementData(Guid.getElementsByTagName("HiiCName")[0]))
1263 if (options.debug and options.verbose > 1):
1264 print "Hii Formset Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
1265 AddGuid(Archs, CName, Usage)
1266 AutoGenGuid.append(CName)
1270 """ Check for the Variables Element """
1271 Guids = "/ModuleSurfaceArea/Variables/Variable"
1274 GuidList = XmlList(Msa, Guids)
1278 if (len(GuidList) > 0):
1279 for Guid in GuidList:
1286 Archs = Guid.getAttribute("SupArchList")
1290 Archs = chkArch(Archs)
1293 Usage = Guid.getAttribute("Usage")
1298 VariableName = str(XmlElementData(Guid.getElementsByTagName("VariableName")[0]))
1299 CName = str(XmlElementData(Guid.getElementsByTagName("GuidC_Name")[0]))
1301 HexData = VariableName.strip().split()
1303 for dig in HexData[:]:
1304 UniString += str(unichr(eval(dig)))
1309 if CName in set(GuidDecls):
1310 removeDups(CName, GuidCName)
1311 removeDups(CName, GuidCNameIa32)
1312 removeDups(CName, GuidCNameX64)
1313 removeDups(CName, GuidCNameIPF)
1314 removeDups(CName, GuidCNameEBC)
1317 print "Variable Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs)
1318 AddGuid(Archs, CName, Usage)
1319 AutoGenGuid.append(CName)
1321 if (len(DefinesComments) == 0):
1322 DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1323 DefinesComments.append("# Variable Guid C Name: " + CName + " Variable Name:" + UniString + "\n")
1329 DefinesComments.append("#\n")
1332 """ Check for the Protocol Element """
1333 Protocols = "/ModuleSurfaceArea/Protocols/Protocol"
1336 ProtocolCNameIa32 = []
1337 ProtocolCNameX64 = []
1338 ProtocolCNameIPF = []
1339 ProtocolCNameEBC = []
1342 ProtocolList = XmlList(Msa, Protocols)
1346 if (len(ProtocolList) > 0):
1347 for Protocol in ProtocolList:
1353 Archs = Protocol.getAttribute("SupArchList")
1357 Archs = chkArch(Archs)
1360 Usage = Protocol.getAttribute("Usage")
1365 CName = str(XmlElementData(Protocol.getElementsByTagName("ProtocolCName")[0]))
1366 AutoGenGuid.append(CName)
1367 removeDups(CName, GuidCName)
1368 removeDups(CName, GuidCNameIa32)
1369 removeDups(CName, GuidCNameX64)
1370 removeDups(CName, GuidCNameIPF)
1371 removeDups(CName, GuidCNameEBC)
1373 if (options.debug and options.verbose > 1):
1374 print "Found %s - %s - %s " % (CName, Usage, str(len(Archs)))
1377 ProtocolCNameIa32.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage)))
1379 ProtocolCNameX64.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage)))
1381 ProtocolCNameIPF.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage)))
1383 ProtocolCNameEBC.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage)))
1385 ProtocolCName.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage)))
1390 Protocols = "/ModuleSurfaceArea/Protocols/ProtocolNotify"
1392 ProtocolList = XmlList(Msa, Protocols)
1396 if (len(ProtocolList) > 0):
1397 for Protocol in ProtocolList:
1403 Archs = Protocol.getAttribute("SupArchList")
1407 Archs = chkArch(Archs)
1410 Usage = Protocol.getAttribute("Usage")
1415 CName = str(XmlElementData(Protocol.getElementsByTagName("ProtocolNotifyCName")[0]))
1416 AutoGenGuid.append(CName)
1417 removeDups(CName, GuidCName)
1418 removeDups(CName, GuidCNameIa32)
1419 removeDups(CName, GuidCNameX64)
1420 removeDups(CName, GuidCNameIPF)
1421 removeDups(CName, GuidCNameEBC)
1424 ProtocolCNameIa32.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage))
1426 ProtocolCNameX64.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage))
1428 ProtocolCNameIPF.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage))
1430 ProtocolCNameEBC.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage))
1432 ProtocolCName.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage))
1436 """ Check for the PPIs Element """
1437 PPIs = "/ModuleSurfaceArea/PPIs/Ppi"
1446 PPIsList = XmlList(Msa, PPIs)
1450 if (len(PPIsList) > 0):
1451 for Ppi in PPIsList:
1457 Archs = str(Ppi.getAttribute("SupArchList"))
1461 Archs = chkArch(Archs)
1464 Usage = str(Ppi.getAttribute("Usage"))
1469 CName = str(XmlElementData(Ppi.getElementsByTagName("PpiCName")[0])).strip()
1470 AutoGenGuid.append(CName)
1471 removeDups(CName, GuidCName)
1472 removeDups(CName, GuidCNameIa32)
1473 removeDups(CName, GuidCNameX64)
1474 removeDups(CName, GuidCNameIPF)
1475 removeDups(CName, GuidCNameEBC)
1478 PpiCNameIa32.insert(0, " %-45s # PPI %s" % (CName, Usage))
1480 PpiCNameX64.insert(0, " %-45s # PPI %s" % (CName, Usage))
1482 PpiCNameIPF.insert(0, " %-45s # PPI %s" % (CName, Usage))
1484 PpiCNameEBC.insert(0, " %-45s # PPI %s" % (CName, Usage))
1486 PpiCName.insert(0, " %-45s # PPI %s" % (CName, Usage))
1491 PPIs = "/ModuleSurfaceArea/PPIs/PpiNotify"
1493 PPIsList = XmlList(Msa, PPIs)
1497 if (len(PPIsList) > 0):
1498 for Ppi in PPIsList:
1504 Archs = Ppi.getAttribute("SupArchList")
1508 Archs = chkArch(Archs)
1511 Usage = Ppi.getAttribute("Usage")
1516 CName = str(XmlElementData(Ppi.getElementsByTagName("PpiNotifyCName")[0]))
1517 AutoGenGuid.append(CName)
1518 removeDups(CName, GuidCName)
1519 removeDups(CName, GuidCNameIa32)
1520 removeDups(CName, GuidCNameX64)
1521 removeDups(CName, GuidCNameIPF)
1522 removeDups(CName, GuidCNameEBC)
1525 PpiCNameIa32.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage))
1527 PpiCNameX64.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage))
1529 PpiCNameIPF.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage))
1531 PpiCNameEBC.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage))
1533 PpiCName.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage))
1538 """ Get the PCD entries now """
1539 PcdCoded = "/ModuleSurfaceArea/PcdCoded/PcdEntry"
1542 PcdList = XmlList(Msa, PcdCoded)
1546 (PcdFF, PcdFFIa32, PcdFFX64, PcdFFIpf, PcdFFEbc) = ([],[],[],[],[])
1547 (PcdFAB, PcdFABIa32, PcdFABX64, PcdFABIpf, PcdFABEbc) = ([],[],[],[],[])
1548 (PcdPIM, PcdPIMIa32, PcdPIMX64, PcdPIMIpf, PcdPIMEbc) = ([],[],[],[],[])
1549 (PcdDY, PcdDYIa32, PcdDYX64, PcdDYIpf, PcdDYEbc) = ([],[],[],[],[])
1550 (PcdDYE, PcdDYEIa32, PcdDYEX64, PcdDYEIpf, PcdDYEEbc) = ([],[],[],[],[])
1552 if (len(PcdList) > 0):
1560 Archs = Pcd.getAttribute("SupArchList")
1564 Archs = chkArch(Archs)
1567 ItemType = Pcd.getAttribute("PcdItemType")
1572 CName = str(XmlElementData(Pcd.getElementsByTagName("C_Name")[0]))
1574 raise SyntaxError, "ERROR: MSA has a PCD with no Pcd C_Name defined"
1577 TSGC = str(XmlElementData(Pcd.getElementsByTagName("TokenSpaceGuidCName")[0]))
1582 DefVal = str(XmlElementData(Pcd.getElementsByTagName("DefaultValue")))
1586 if (len(DefVal) > 0):
1587 line = TSGC + "." + CName + "|" + DefVal
1589 line = TSGC + "." + CName
1591 if (ItemType == "FEATURE_FLAG"):
1592 if ("IA32" in Archs):
1593 PcdFFIa32.insert(0, line)
1594 if ("IPF" in Archs):
1595 PcdFFIpf.insert(0, line)
1596 if ("X64" in Archs):
1597 PcdFFX64.insert(0, line)
1598 if ("EBC" in Archs):
1599 PcdFFEbc.insert(0, line)
1600 if ("ALL" in Archs):
1601 PcdFF.insert(0, line)
1602 elif (ItemType == "FIXED_AT_BUILD"):
1603 if ("IA32" in Archs):
1604 PcdFABIa32.insert(0, line)
1605 if ("IPF" in Archs):
1606 PcdFABIpf.insert(0, line)
1607 if ("X64" in Archs):
1608 PcdFABX64.insert(0, line)
1609 if ("EBC" in Archs):
1610 PcdFABEbc.insert(0, line)
1611 if ("ALL" in Archs):
1612 PcdFAB.insert(0, line)
1613 elif (ItemType == "PATCHABLE_IN_MODULE"):
1614 if ("IA32" in Archs):
1615 PcdPIMIa32.insert(0, line)
1616 if ("IPF" in Archs):
1617 PcdPIMIpf.insert(0, line)
1618 if ("X64" in Archs):
1619 PcdPIMX64.insert(0, line)
1620 if ("EBC" in Archs):
1621 PcdPIMEbc.insert(0, line)
1622 if ("ALL" in Archs):
1623 PcdFAB.insert(0, line)
1624 elif (ItemType == "DYNAMIC_EX"):
1625 if ("IA32" in Archs):
1626 PcdDYEIa32.insert(0, line)
1627 if ("IPF" in Archs):
1628 PcdDYEIpf.insert(0, line)
1629 if ("X64" in Archs):
1630 PcdDYEX64.insert(0, line)
1631 if ("EBC" in Archs):
1632 PcdDYEEbc.insert(0, line)
1633 if ("ALL" in Archs):
1634 PcdDYE.insert(0, line)
1636 if ("IA32" in Archs):
1637 PcdDYIa32.insert(0, line)
1638 if ("IPF" in Archs):
1639 PcdDYIpf.insert(0, line)
1640 if ("X64" in Archs):
1641 PcdDYX64.insert(0, line)
1642 if ("EBC" in Archs):
1643 PcdDYEbc.insert(0, line)
1644 if ("ALL" in Archs):
1645 PcdDY.insert(0, line)
1647 """ User Extensions Section """
1651 UESectionList = XmlList(Msa, "/ModuleSurfaceArea/UserExtensions")
1655 if (len(UESectionList) > 0):
1656 for UE in UESectionList[:]:
1662 UserId = str(UE.getAttribute("UserID"))
1664 raise SyntaxError, "ERROR: Malformed MSA, No UserID Specified in UserExtensions element"
1667 Identifier = str(UE.getAttribute("Identifier"))
1669 raise SyntaxError, "ERROR: Malformed MSA, No Identifier Specified in UserExtensions element"
1672 print "FOUND A UE Element", UserId, Identifier
1675 Value = str(XmlElementData(UE))
1679 Entry = [UserId, Identifier, Value]
1680 UEList.insert(0, Entry)
1684 if (len(Externlist) > 0):
1686 AutoGenDefinitionSource = ""
1687 AutoGenEntryPointSource = ""
1688 AutoGenUnloadSource = ""
1689 if (len(AutoGenDriverModel) > 0):
1690 AutoGenCode = AddDriverBindingProtocolStatement(AutoGenDriverModel)
1691 AutoGenEntryPointSource += AutoGenCode[0]
1692 AutoGenUnloadSource += AutoGenCode[1]
1693 AutoGenDeclaration += AutoGenCode[3]
1696 if (len(AutoGenExitBootServices) > 0):
1697 print "[Warning] Please manually add Create Event statement for Exit Boot Service Event!"
1699 AutoGenCode = AddBootServiceEventStatement(AutoGenExitBootServices)
1700 AutoGenEntryPointSource += AutoGenCode[0]
1701 AutoGenUnloadSource += AutoGenCode[1]
1702 AutoGenDefinitionSource += AutoGenCode[2]
1703 AutoGenDeclaration += AutoGenCode[3]
1705 if (len(AutoGenVirtualAddressChanged) > 0):
1706 print "[Warning] Please manually add Create Event statement for Virtual Address Change Event!"
1708 AutoGenCode = AddVirtualAddressEventStatement(AutoGenVirtualAddressChanged)
1709 AutoGenEntryPointSource += AutoGenCode[0]
1710 AutoGenUnloadSource += AutoGenCode[1]
1711 AutoGenDefinitionSource += AutoGenCode[2]
1712 AutoGenDeclaration += AutoGenCode[3]
1714 if AutoGenEntryPointSource != "":
1715 OldEntryPoint = AutoGenEntryPoint
1716 AutoGenCode = AddNewEntryPointContentsStatement(BaseName, AutoGenEntryPoint, AutoGenEntryPointSource)
1717 AutoGenEntryPoint = AutoGenCode[0]
1718 AutoGenEntryPointSource = AutoGenCode[1]
1719 AutoGenDeclaration += AutoGenCode[2]
1722 if AutoGenEntryPoint != "":
1723 DriverModules.insert(0, " %-30s = %s\n" % ("ENTRY_POINT" , AutoGenEntryPoint))
1725 AutoGenSource = AutoGenDefinitionSource + AutoGenEntryPointSource + AutoGenUnloadSource
1728 DefinesComments.append("#\n")
1730 if (Flag and len(DefinesComments) > 0):
1731 DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n")
1733 if (options.debug and options.verbose > 2):
1734 if (len(DriverModules) > 0):
1736 if (len(LibraryModules) > 0):
1737 print LibraryModules
1738 if (len(DefinesComments) > 0):
1739 print DefinesComments
1747 for DxsFile, Archs in AutoGenDxsFiles:
1748 fileContents = openSourceFile(AutoGenModuleFolder, DxsFile)
1749 Contents, Unresolved = TranslateDpxSection(fileContents)
1751 print "[warning] Cannot read dxs expression"
1753 if (len(Unresolved) > 0):
1754 print "[warning] Guid Macro(s): %s cannot find corresponding cNames. Please resolve it in [depex] section in extened inf" % ",".join(Unresolved)
1756 if ("IA32" in Archs):
1757 DepexIa32.insert(0, Contents)
1758 if ("IPF" in Archs):
1759 DepexIpf.insert(0, Contents)
1760 if ("X64" in Archs):
1761 DepexX64.insert(0, Contents)
1762 if ("EBC" in Archs):
1763 DepexEbc.insert(0, Contents)
1764 if ("ALL" in Archs):
1765 Depex.insert(0, Contents)
1767 AutoGenSourceHeaderFormat = "/**@file\n %s\n\n %s\n %s\n %s\n**/\n\n%s"
1768 includeCommonHeaderFileStatement = "#include \"%s\"" % commonHeaderFilename
1770 AutoGenHeader += AddSystemIncludeStatement(ModType, AutoGenPackage)
1771 AutoGenHeader += AddGuidStatement(AutoGenGuid)
1772 AutoGenHeader += AddLibraryClassStatement(AutoGenLibClass)
1775 saveSourceFile(AutoGenModuleFolder, "CommonHeader.txt", AutoGenHeader)
1778 commonHeaderFilename2 = re.sub("(?=[^a-z])", "_", commonHeaderFilename)
1779 commonHeaderFilename2 = "_" + commonHeaderFilename2.replace(".", "").upper() + "_"
1780 briefDiscription = "Common header file shared by all source files."
1781 detailedDiscription = "This file includes package header files, library classes and protocol, PPI & GUID definitions.\n"
1782 AutoGenHeader += AutoGenDeclaration
1783 AutoGenHeader = "#ifndef %s\n#define %s\n\n\n%s\n#endif\n" % (commonHeaderFilename2, commonHeaderFilename2, AutoGenHeader)
1784 AutoGenHeader = AutoGenSourceHeaderFormat % (briefDiscription, detailedDiscription, CopyRight, License, AutoGenHeader)
1785 saveSourceFile(AutoGenModuleFolder, commonHeaderFilename, AutoGenHeader)
1786 SrcFilenames.append(commonHeaderFilename)
1788 for source in AutoGenSourceFiles:
1789 extension = os.path.splitext(source)[1]
1790 if extension == ".c":
1791 sourceContents = openSourceFile(AutoGenModuleFolder, source)
1792 sourceContents = AddCommonInclusionStatement(sourceContents, includeCommonHeaderFileStatement)
1793 saveSourceFile(AutoGenModuleFolder, source, sourceContents)
1796 if AutoGenSource != "":
1797 briefDiscription = "Entry Point Source file."
1798 detailedDiscription = "This file contains the user entry point \n"
1799 AutoGenSource = AutoGenSourceHeaderFormat % (briefDiscription, detailedDiscription, CopyRight, License, AutoGenSource)
1800 AutoGenSource = AddCommonInclusionStatement(AutoGenSource, includeCommonHeaderFileStatement)
1802 saveSourceFile(AutoGenModuleFolder, entryPointFilename, AutoGenSource)
1803 SrcFilenames.append(entryPointFilename)
1808 # DONE Getting data, now output it in INF format.
1813 """ Print the converted data format """
1814 head = "#/** @file\n"
1815 head += "# " + str(Abstract) + "\n#\n"
1816 head += "# " + str(Description).strip().replace("\n", "\n# ") + "\n"
1817 head += "# " + str(CopyRight) + "\n#\n"
1818 head += "# " + str(License).replace("\n", "\n# ").replace(" ", " ").strip() + "\n#\n"
1825 ## Defines = "\n" + "#"*80+ "\n#\n"
1826 ## if (BinModule != "false"):
1827 ## Defines += "# Defines Section - statements that will be processed to generate a binary image.\n"
1829 ## Defines += "# Defines Section - statements that will be processed to create a Makefile.\n"
1830 ## Defines += "#\n" + "#"*80 + "\n"
1833 Defines += "[Defines]\n"
1834 Defines += " %-30s = %s\n" % ("INF_VERSION", "0x00010005")
1835 Defines += " %-30s = %s\n" % ("BASE_NAME", BaseName)
1836 Defines += " %-30s = %s\n" % ("FILE_GUID", GuidValue)
1837 Defines += " %-30s = %s\n" % ("MODULE_TYPE", ModType)
1838 Defines += " %-30s = %s\n" % ("VERSION_STRING", VerString)
1840 if (len(PcdIsDriver) > 0):
1841 Defines += " %-30s = %s\n" % ("PCD_DRIVER", PcdIsDriver)
1843 if (len(IamLibrary) > 0):
1845 for lc in IamLibrary[:]:
1847 Defines += " %-30s = %s" % ("LIBRARY_CLASS", lcstr)
1850 if (len(SpecList) > 0):
1851 for spec in SpecList[:]:
1852 (specname, specval) = spec.split()
1853 Defines += " %-30s = %s\n" % (specname, specval)
1856 if (len(DriverModules) > 0):
1857 for line in DriverModules[:]:
1860 if (len(LibraryModules) > 0):
1861 for line in LibraryModules[:]:
1864 if (len(DefinesComments) > 0):
1865 for line in DefinesComments[:]:
1868 Output.append(Defines)
1873 if (BinModule != "false"):
1874 """ Binary Module, so sources are really binaries. """
1875 ## Sources = "\n" + "#"*80 + "\n#\n"
1876 ## Sources += "# Binaries Section - list of binary files that are required for the build\n# to succeed.\n"
1877 ## Sources += "#\n" + "#"*80 + "\n\n"
1879 if ModType == "UEFI_APPLICATION":
1880 FileType = "UEFI_APP"
1881 if options.verbose > 0:
1882 print "WARNING: Binary Module: %s is assuming UEFI_APPLICATION file type." % (options.filename)
1885 if options.verbose > 0:
1886 print "WARNING: Binary Module: %s is assuming FV file type." % (options.filename)
1888 if (len(SrcFilenames) > 0):
1889 Sources += "[Binaries.common]\n"
1890 for file in SrcFilenames[:]:
1891 file = file.replace("\\", "/")
1892 Sources += " " + FileType + "|" + file + "\n"
1895 if (len(SrcFilenamesIa32) > 0):
1896 Sources += "[Binaries.Ia32]\n"
1897 for file in SrcFilenamesIa32[:]:
1898 file = file.replace("\\", "/")
1899 Sources += " " + FileType + "|" + file + "\n"
1902 if (len(SrcFilenamesX64) > 0):
1903 Sources += "[Binaries.X64]\n"
1904 for file in SrcFilenamesX64[:]:
1905 file = file.replace("\\", "/")
1906 Sources += " " + FileType + "|" + file + "\n"
1909 if (len(SrcFilenamesIpf) > 0):
1910 Sources += "[Binaries.IPF]\n"
1911 for file in SrcFilenamesIpf[:]:
1912 file = file.replace("\\", "/")
1913 Sources += " " + FileType + "|" + file + "\n"
1916 if (len(SrcFilenamesEbc) > 0):
1917 Sources += "[Binaries.EBC]\n"
1918 for file in SrcFilenamesEbc[:]:
1919 file = file.replace("\\", "/")
1920 Sources += " " + FileType + "|" + file + "\n"
1923 Output.append(Sources)
1927 ## Sources = "\n" + "#"*80 + "\n#\n"
1928 ## Sources += "# Sources Section - list of files that are required for the build to succeed.\n"
1929 ## Sources += "#\n" + "#"*80 + "\n\n"
1931 if (len(SrcFilenames) > 0):
1932 Sources += "[Sources.common]\n"
1933 for file in SrcFilenames[:]:
1934 Sources += " " + file + "\n"
1937 if (len(SrcFilenamesIa32) > 0):
1938 Sources += "[Sources.Ia32]\n"
1939 for file in SrcFilenamesIa32[:]:
1940 Sources += " " + file + "\n"
1943 if (len(SrcFilenamesX64) > 0):
1944 Sources += "[Sources.X64]\n"
1945 for file in SrcFilenamesX64[:]:
1946 Sources += " " + file + "\n"
1949 if (len(SrcFilenamesIpf) > 0):
1950 Sources += "[Sources.IPF]\n"
1951 for file in SrcFilenamesIpf[:]:
1952 Sources += " " + file + "\n"
1955 if (len(SrcFilenamesEbc) > 0):
1956 Sources += "[Sources.EBC]\n"
1957 for file in SrcFilenamesEbc[:]:
1958 Sources += " " + file + "\n"
1961 Output.append(Sources)
1967 if ((len(HeaderLocations) > 0) or (len(Dirs) > 0)):
1968 allLcs = set(LibClassList + LibClassListIa32 + LibClassListX64 + LibClassListIpf + LibClassListEbc + Dirs)
1970 for line in HeaderLocations[:]:
1972 (keyword, header) = line.split("|")
1975 print "FOUND", Lc, "in", keyword, "header", header
1976 path = "$(WORKSPACE)/" + os.path.split(header)[0]
1977 Lines.insert(0, path.strip())
1979 ## Includes = "\n" + "#"*80 + "\n#\n"
1980 ## Includes += "# Includes Section - list of Include locations that are required for\n"
1981 ## Includes += "# this module.\n"
1982 ## Includes += "#\n" + "#"*80 + "\n\n"
1983 ## Includes += "[Includes]\n"
1984 ## includeLines = []
1985 ## includeLines = set(Lines)
1986 ## if (options.debug):
1987 ## print "There are", len(includeLines), "entries"
1988 ## for Line in includeLines:
1989 ## Includes += " " + str(Line).strip().replace("\\", "/") + "\n"
1991 Output.append(Includes)
1997 if ((len(PkgList) + len(PkgListIa32) + len(PkgListX64) + len(PkgListIpf) + len(PkgListEbc)) > 0):
1998 """ We do this if and only if we have Package Dependencies """
1999 ## PackageDepends = "\n" + "#"*80 + "\n#\n"
2000 ## PackageDepends += "# Package Dependency Section - list of Package files that are required for\n"
2001 ## PackageDepends += "# this module.\n"
2002 ## PackageDepends += "#\n" + "#"*80 + "\n\n"
2003 PackageDepends = "\n"
2004 if (len(PkgList) > 0):
2005 PackageDepends += "[Packages]\n"
2006 for lc in PkgList[:]:
2007 lc = lc.replace("\\", "/")
2008 PackageDepends += " " + lc + "\n"
2009 PackageDepends += "\n"
2011 if (len(PkgListIa32) > 0):
2012 PackageDepends += "[Packages.IA32]\n"
2013 for lc in PkgListIa32[:]:
2014 lc = lc.replace("\\", "/")
2015 PackageDepends += " " + lc + "\n"
2016 PackageDepends += "\n"
2018 if (len(PkgListX64) > 0):
2019 PackageDepends += "[Packages.X64]\n"
2020 for lc in PkgListX64[:]:
2021 lc = lc.replace("\\", "/")
2022 PackageDepends += " " + lc + "\n"
2023 PackageDepends += "\n"
2025 if (len(PkgListIpf) > 0):
2026 PackageDepends += "[Packages.IPF]\n"
2027 for lc in PkgListIpf[:]:
2028 lc = lc.replace("\\", "/")
2029 PackageDepends += " " + lc + "\n"
2030 PackageDepends += "\n"
2032 if (len(PkgListEbc) > 0):
2033 PackageDepends += "[Packages.EBC]\n"
2034 for lc in PkgListEbc[:]:
2035 lc = lc.replace("\\", "/")
2036 PackageDepends += " " + lc + "\n"
2037 PackageDepends += "\n"
2039 Output.append(PackageDepends)
2041 print PackageDepends
2043 if ((len(LibClassList) + len(LibClassListIa32) + len(LibClassListX64) + len(LibClassListIpf) + len(LibClassListEbc)) > 0):
2044 ## LibraryClasses = "\n" + "#"*80 + "\n#\n"
2045 ## LibraryClasses += "# Library Class Section - list of Library Classes that are required for\n"
2046 ## LibraryClasses += "# this module.\n"
2047 ## LibraryClasses += "#\n" + "#"*80 + "\n\n"
2049 LibraryClasses = "\n"
2050 if (len(LibClassList) > 0):
2051 LibraryClasses += "[LibraryClasses]\n"
2052 for lc in LibClassList[:]:
2053 LibraryClasses += " " + lc + "\n"
2054 LibraryClasses += "\n"
2056 if (len(LibClassListIa32) > 0):
2057 LibraryClasses += "[LibraryClasses.IA32]\n"
2058 for lc in LibClassListIa32[:]:
2059 LibraryClasses += " " + lc + "\n"
2060 LibraryClasses += "\n"
2062 if (len(LibClassListX64) > 0):
2063 LibraryClasses += "[LibraryClasses.X64]\n"
2064 for lc in LibClassListX64[:]:
2065 LibraryClasses += " " + lc + "\n"
2066 LibraryClasses += "\n"
2068 if (len(LibClassListIpf) > 0):
2069 LibraryClasses += "[LibraryClasses.IPF]\n"
2070 for lc in LibClassListIpf[:]:
2071 LibraryClasses += " " + lc + "\n"
2072 LibraryClasses += "\n"
2074 if (len(LibClassListEbc) > 0):
2075 LibraryClasses += "[LibraryClasses.EBC]\n"
2076 for lc in LibClassListEbc[:]:
2077 LibraryClasses += " " + lc + "\n"
2078 LibraryClasses += "\n"
2080 Output.append(LibraryClasses)
2082 print LibraryClasses
2084 # Print the Guids sections
2085 if (len(GuidCName) + len(GuidCNameIa32) + len(GuidCNameIPF) + len(GuidCNameX64) + len(GuidCNameEBC)) > 0:
2086 ## GuidSection = "\n" + "#"*80 + "\n#\n"
2087 ## GuidSection += "# Guid C Name Section - list of Guids that this module uses or produces.\n"
2088 ## GuidSection += "#\n" + "#"*80 + "\n\n"
2090 if (len(GuidCName) > 0):
2091 GuidSection += "[Guids]\n"
2092 for Guid in GuidCName[:]:
2093 GuidSection += Guid + "\n"
2096 if (len(GuidCNameIa32) > 0):
2097 GuidSection += "[Guids.IA32]\n"
2098 for Guid in GuidCNameIa32[:]:
2099 GuidSection += Guid + "\n"
2102 if (len(GuidCNameX64) > 0):
2103 GuidSection += "[Guids.X64]\n"
2104 for Guid in GuidCNameX64[:]:
2105 GuidSection += Guid + "\n"
2108 if (len(GuidCNameIPF) > 0):
2109 GuidSection += "[Guids.IPF]\n"
2110 for Guid in GuidCNameIPF[:]:
2111 GuidSection += Guid + "\n"
2114 if (len(GuidCNameEBC) > 0):
2115 GuidSection += "[Guids.EBC]\n"
2116 for Guid in GuidCNameEBC[:]:
2117 GuidSection += Guid + "\n"
2120 Output.append(GuidSection)
2121 if (options.debug and options.verbose > 1):
2124 # Print the Protocol sections
2125 if (len(ProtocolCName) + len(ProtocolCNameIa32) + len(ProtocolCNameIPF) + len(ProtocolCNameX64) + len(ProtocolCNameEBC)) > 0:
2126 ## ProtocolsSection = "\n" + "#"*80 + "\n#\n"
2127 ## ProtocolsSection += "# Protocol C Name Section - list of Protocol and Protocol Notify C Names\n"
2128 ## ProtocolsSection += "# that this module uses or produces.\n"
2129 ## ProtocolsSection += "#\n" + "#"*80 + "\n\n"
2131 ProtocolsSection = "\n"
2132 if (len(ProtocolCName) > 0):
2133 ProtocolsSection += "[Protocols]\n"
2134 for Guid in ProtocolCName[:]:
2135 ProtocolsSection += Guid + "\n"
2136 ProtocolsSection += "\n"
2138 if (len(ProtocolCNameIa32) > 0):
2139 ProtocolsSection += "[Protocols.IA32]\n"
2140 for Guid in ProtocolCNameIa32[:]:
2141 ProtocolsSection += Guid + "\n"
2142 ProtocolsSection += "\n"
2144 if (len(ProtocolCNameX64) > 0):
2145 ProtocolsSection += "[Protocols.X64]\n"
2146 for Guid in ProtocolCNameX64[:]:
2147 ProtocolsSection += Guid + "\n"
2148 ProtocolsSection += "\n"
2150 if (len(ProtocolCNameIPF) > 0):
2151 ProtocolsSection += "[Protocols.IPF]\n"
2152 for Guid in ProtocolCNameIPF[:]:
2153 ProtocolsSection += Guid + "\n"
2154 ProtocolsSection += "\n"
2156 if (len(ProtocolCNameEBC) > 0):
2157 ProtocolsSection += "[Protocols.EBC]\n"
2158 for Guid in ProtocolCNameEBC[:]:
2159 ProtocolsSection += Guid + "\n"
2160 ProtocolsSection += "\n"
2162 Output.append(ProtocolsSection)
2164 print ProtocolsSection
2166 # Print the PPI sections
2167 if (len(PpiCName) + len(PpiCNameIa32) + len(PpiCNameIPF) + len(PpiCNameX64) + len(PpiCNameEBC)) > 0:
2168 ## PpiSection = "\n" + "#"*80 + "\n#\n"
2169 ## PpiSection += "# PPI C Name Section - list of PPI and PPI Notify C Names that this module\n"
2170 ## PpiSection += "# uses or produces.\n"
2171 ## PpiSection += "#\n" + "#"*80 + "\n\n"
2174 if (len(PpiCName) > 0):
2175 PpiSection += "[Ppis]\n"
2176 for Guid in PpiCName[:]:
2177 PpiSection += Guid + "\n"
2180 if (len(PpiCNameIa32) > 0):
2181 PpiSection += "[Ppis.IA32]\n"
2182 for Guid in PpiCNameIa32[:]:
2183 PpiSection += Guid + "\n"
2186 if (len(PpiCNameX64) > 0):
2187 PpiSection += "[Ppis.X64]\n"
2188 for Guid in PpiCNameX64[:]:
2189 PpiSection += Guid + "\n"
2192 if (len(PpiCNameIPF) > 0):
2193 PpiSection += "[Ppis.IPF]\n"
2194 for Guid in PpiCNameIPF[:]:
2195 PpiSection += Guid + "\n"
2198 if (len(PpiCNameEBC) > 0):
2199 PpiSection += "[Ppis.EBC]\n"
2200 for Guid in PpiCNameEBC[:]:
2201 PpiSection += Guid + "\n"
2204 Output.append(PpiSection)
2208 # Print the PCD sections
2209 if ((len(PcdFF)+len(PcdFFIa32)+len(PcdFFX64)+len(PcdFFIpf)+len(PcdFFEbc)) > 0):
2210 ## FeatureFlagSection = "\n" + "#"*80 + "\n#\n"
2211 ## FeatureFlagSection += "# Pcd FEATURE_FLAG - list of PCDs that this module is coded for.\n"
2212 ## FeatureFlagSection += "#\n" + "#"*80 + "\n\n"
2214 FeatureFlagSection = "\n"
2215 if (len(PcdFF) > 0):
2216 FeatureFlagSection += "[FeaturePcd.common]\n"
2217 for Entry in PcdFF[:]:
2218 FeatureFlagSection += " " + Entry + "\n"
2219 FeatureFlagSection += "\n"
2220 if (len(PcdFFIa32) > 0):
2221 FeatureFlagSection += "[FeaturePcd.IA32]\n"
2222 for Entry in PcdFFIa32[:]:
2223 FeatureFlagSection += " " + Entry + "\n"
2224 FeatureFlagSection += "\n"
2225 if (len(PcdFFX64) > 0):
2226 FeatureFlagSection += "[FeaturePcd.X64]\n"
2227 for Entry in PcdFFX64[:]:
2228 FeatureFlagSection += " " + Entry + "\n"
2229 FeatureFlagSection += "\n"
2230 if (len(PcdFFIpf) > 0):
2231 FeatureFlagSection += "[PcdsFeatureFlag.IPF]\n"
2232 for Entry in PcdFFIpf[:]:
2233 FeatureFlagSection += " " + Entry + "\n"
2234 FeatureFlagSection += "\n"
2235 if (len(PcdFFEbc) > 0):
2236 FeatureFlagSection += "[FeaturePcd.EBC]\n"
2237 for Entry in PcdFFEbc[:]:
2238 FeatureFlagSection += " " + Entry + "\n"
2239 FeatureFlagSection += "\n"
2241 Output.append(FeatureFlagSection)
2243 print FeatureFlagSection
2245 if ((len(PcdFAB)+len(PcdFABIa32)+len(PcdFABX64)+len(PcdFABIpf)+len(PcdFABEbc)) > 0):
2246 ## FixedAtBuildSection = "\n" + "#"*80 + "\n#\n"
2247 ## FixedAtBuildSection += "# Pcd FIXED_AT_BUILD - list of PCDs that this module is coded for.\n"
2248 ## FixedAtBuildSection += "#\n" + "#"*80 + "\n\n"
2250 FixedAtBuildSection = "\n"
2251 if (len(PcdFAB) > 0):
2252 FixedAtBuildSection += "[FixedPcd.common]\n"
2253 for Entry in PcdFAB[:]:
2254 FixedAtBuildSection += " " + Entry + "\n"
2255 FixedAtBuildSection += "\n"
2256 if (len(PcdFABIa32) > 0):
2257 FixedAtBuildSection += "[FixedPcd.IA32]\n"
2258 for Entry in PcdFABIa32[:]:
2259 FixedAtBuildSection += " " + Entry + "\n"
2260 FixedAtBuildSection += "\n"
2261 if (len(PcdFABX64) > 0):
2262 FixedAtBuildSection += "[FixedPcd.X64]\n"
2263 for Entry in PcdFABX64[:]:
2264 FixedAtBuildSection += " " + Entry + "\n"
2265 FixedAtBuildSection += "\n"
2266 if (len(PcdFABIpf) > 0):
2267 FixedAtBuildSection += "[FixedPcd.IPF]\n"
2268 for Entry in PcdFABIpf[:]:
2269 FixedAtBuildSection += " " + Entry + "\n"
2270 FixedAtBuildSection += "\n"
2271 if (len(PcdFABEbc) > 0):
2272 FixedAtBuildSection += "[FixedPcd.EBC]\n"
2273 for Entry in PcdFABEbc[:]:
2274 FixedAtBuildSection += " " + Entry + "\n"
2275 FixedAtBuildSection += "\n"
2277 Output.append(FixedAtBuildSection)
2279 print FixedAtBuildSection
2281 if ((len(PcdPIM)+len(PcdPIMIa32)+len(PcdPIMX64)+len(PcdPIMIpf)+len(PcdPIMEbc)) > 0):
2282 ## PatchableInModuleSection = "\n" + "#"*80 + "\n#\n"
2283 ## PatchableInModuleSection += "# Pcd PATCHABLE_IN_MODULE - list of PCDs that this module is coded for.\n"
2284 ## PatchableInModuleSection += "#\n" + "#"*80 + "\n\n"
2286 PatchableInModuleSection = "\n"
2287 if (len(PcdPIM) > 0):
2288 PatchableInModuleSection += "[PatchPcd.common]\n"
2289 for Entry in PcdPIM[:]:
2290 PatchableInModuleSection += " " + Entry + "\n"
2291 PatchableInModuleSection += "\n"
2292 if (len(PcdPIMIa32) > 0):
2293 PatchableInModuleSection += "[PatchPcd.IA32]\n"
2294 for Entry in PcdPIMIa32[:]:
2295 PatchableInModuleSection += " " + Entry + "\n"
2296 PatchableInModuleSection += "\n"
2297 if (len(PcdPIMX64) > 0):
2298 PatchableInModuleSection += "[PatchPcd.X64]\n"
2299 for Entry in PcdPIMX64[:]:
2300 PatchableInModuleSection += " " + Entry + "\n"
2301 PatchableInModuleSection += "\n"
2302 if (len(PcdPIMIpf) > 0):
2303 PatchableInModuleSection += "[PatchPcd.IPF]\n"
2304 for Entry in PcdPIMIpf[:]:
2305 PatchableInModuleSection += " " + Entry + "\n"
2306 PatchableInModuleSection += "\n"
2307 if (len(PcdPIMEbc) > 0):
2308 PatchableInModuleSection += "[PatchPcd.EBC]\n"
2309 for Entry in PcdPIMEbc[:]:
2310 PatchableInModuleSection += " " + Entry + "\n"
2311 PatchableInModuleSection += "\n"
2313 Output.append(PatchableInModuleSection)
2315 print PatchableInModuleSection
2317 if ((len(PcdDYE)+len(PcdDYEIa32)+len(PcdDYEX64)+len(PcdDYEIpf)+len(PcdDYEEbc)) > 0):
2318 ## DynamicExSection = "\n" + "#"*80 + "\n#\n"
2319 ## DynamicExSection += "# Pcd DYNAMIC_EX - list of PCDs that this module is coded for.\n"
2320 ## DynamicExSection += "#\n" + "#"*80 + "\n\n"
2322 DynamicExSection = "\n"
2323 if (len(PcdDYE) > 0):
2324 DynamicExSection += "[PcdEx.common]\n"
2325 for Entry in PcdDYE[:]:
2326 DynamicExSection += " " + Entry + "\n"
2327 DynamicExSection += "\n"
2328 if (len(PcdDYEIa32) > 0):
2329 DynamicExSection += "[PcdEx.IA32]\n"
2330 for Entry in PcdDYEIa32[:]:
2331 DynamicExSection += " " + Entry + "\n"
2332 DynamicExSection += "\n"
2333 if (len(PcdDYEX64) > 0):
2334 DynamicExSection += "[PcdEx.X64]\n"
2335 for Entry in PcdDYEX64[:]:
2336 DynamicExSection += " " + Entry + "\n"
2337 DynamicExSection += "\n"
2338 if (len(PcdDYEIpf) > 0):
2339 DynamicExSection += "[PcdEx.IPF]\n"
2340 for Entry in PcdDYEIpf[:]:
2341 DynamicExSection += " " + Entry + "\n"
2342 DynamicExSection += "\n"
2343 if (len(PcdDYEEbc) > 0):
2344 DynamicExSection += "[PcdEx.EBC]\n"
2345 for Entry in PcdDYEEbc[:]:
2346 DynamicExSection += " " + Entry + "\n"
2347 DynamicExSection += "\n"
2349 Output.append(DynamicExSection)
2351 print DynamicExSection
2353 if ((len(PcdDY)+len(PcdDYIa32)+len(PcdDYX64)+len(PcdDYIpf)+len(PcdDYEbc)) > 0):
2354 ## DynamicSection = "\n" + "#"*80 + "\n#\n"
2355 ## DynamicSection += "# Pcd DYNAMIC - list of PCDs that this module is coded for.\n"
2356 ## DynamicSection += "#\n" + "#"*80 + "\n\n"
2358 DynamicSection = "\n"
2359 if (len(PcdDY) > 0):
2360 DynamicSection += "[Pcd.common]\n"
2361 for Entry in PcdDY[:]:
2362 DynamicSection += " " + Entry + "\n"
2363 DynamicSection += "\n"
2364 if (len(PcdDYIa32) > 0):
2365 DynamicSection += "[Pcd.IA32]\n"
2366 for Entry in PcdDYIa32[:]:
2367 DynamicSection += " " + Entry + "\n"
2368 DynamicSection += "\n"
2369 if (len(PcdDYX64) > 0):
2370 DynamicSection += "[Pcd.X64]\n"
2371 for Entry in PcdDYX64[:]:
2372 DynamicSection += " " + Entry + "\n"
2373 DynamicSection += "\n"
2374 if (len(PcdDYIpf) > 0):
2375 DynamicSection += "[Pcd.IPF]\n"
2376 for Entry in PcdDYIpf[:]:
2377 DynamicSection += " " + Entry + "\n"
2378 DynamicSection += "\n"
2379 if (len(PcdDYEbc) > 0):
2380 DynamicSection += "[Pcd.EBC]\n"
2381 for Entry in PcdDYEbc[:]:
2382 DynamicSection += " " + Entry + "\n"
2383 DynamicSection += "\n"
2385 Output.append(DynamicSection)
2387 print DynamicSection
2389 if ((len(Depex) + len(DepexIa32) + len(DepexX64) + len(DepexIpf) + len(DepexEbc)) > 0):
2390 """ We do this if and only if we have Package Dependencies """
2391 ## Dpx = "\n" + "#"*80 + "\n#\n"
2392 ## Dpx += "# Dependency Expression Section - list of Dependency expressions that are required for\n"
2393 ## Dpx += "# this module.\n"
2394 ## Dpx += "#\n" + "#"*80 + "\n\n"
2396 if (len(Depex) > 0):
2399 Dpx += " " + lc + "\n"
2402 if (len(DepexIa32) > 0):
2403 Dpx += "[Depex.IA32]\n"
2404 for lc in DepexIa32[:]:
2405 Dpx += " " + lc + "\n"
2408 if (len(DepexX64) > 0):
2409 Dpx += "[Depex.X64]\n"
2410 for lc in DepexX64[:]:
2411 Dpx += " " + lc + "\n"
2414 if (len(DepexIpf) > 0):
2415 Dpx += "[Depex.IPF]\n"
2416 for lc in DepexIpf[:]:
2417 Dpx += " " + lc + "\n"
2420 if (len(DepexEbc) > 0):
2421 Dpx += "[Depex.EBC]\n"
2422 for lc in DepexEbc[:]:
2423 Dpx += " " + lc + "\n"
2430 if (len(MBOlines) > 0):
2432 ## BuildSection = "\n" + "#"*80 + "\n#\n"
2433 ## BuildSection += "# Build Options - list of custom build options for this module.\n"
2434 ## BuildSection += "#\n" + "#"*80 + "\n\n"
2435 BuildSection += "\n[BuildOptions]\n"
2436 for mbo in MBOlines:
2437 tool, targs = mbo.split("=",2)
2438 BuildSection += " %-40s = %s\n" % (tool.strip(), targs.strip())
2440 Output.append(BuildSection)
2445 if (len(UEList) > 0):
2446 UserExtensionSection = ""
2447 for UE in UEList[:]:
2448 UserExtensionSection += "[UserExtensions." + UE[0] + '."' + UE[1] + '"]\n'
2449 if (len(UE[2]) > 0):
2450 UserExtensionSection += '"' + UE[2] + '"\n'
2452 UserExtensionSection += "\n"
2454 Output.append(UserExtensionSection)
2456 print UserExtensionSection
2458 print "write file", outputFile
2459 if (options.autowrite):
2460 fo = open(outputFile, "w")
2461 for Section in Output[:]:
2462 fo.writelines(Section)
2463 if (options.verbose > 1):
2466 elif (options.outfile):
2467 fo = open(outputFile, "w")
2468 for Section in Output[:]:
2469 fo.writelines(Section)
2472 for Section in Output[:]:
2476 if __name__ == '__main__':
2480 options,args = myOptionParser()