1 from optparse import OptionParser
\r
5 from GenFdsGlobalVariable import GenFdsGlobalVariable
\r
6 import EdkIIWorkspaceBuild
\r
7 import RuleComplexFile
\r
8 from EfiSection import EfiSection
\r
11 versionNumber = "1.0"
\r
12 __version__ = "%prog Version " + versionNumber
\r
13 __copyright__ = "Copyright (c) 2007, Intel Corporation All rights reserved."
\r
18 options = myOptionParser()
\r
23 if (options.workspace == None):
\r
24 print "ERROR: E0000: WORKSPACE not defined.\n Please set the WORKSPACE environment variable to the location of the EDK II install directory."
\r
27 workspace = options.workspace
\r
29 print "Using Workspace:", workspace
\r
31 if (options.filename):
\r
32 fdfFilename = options.filename
\r
34 print "ERROR: E0001 - You must specify an input filename"
\r
37 if not os.path.exists(fdfFilename):
\r
38 print "ERROR: E1000: File %s not found" % (filename)
\r
41 if (options.activePlatform):
\r
42 activePlatform = options.activePlatform
\r
44 activePlatform = None
\r
46 if (options.outputDir):
\r
47 outputDir = options.outputDir
\r
49 print "ERROR: E0001 - You must specify an Output directory"
\r
52 if (options.archList) :
\r
53 archList = options.archList.split(',')
\r
57 """ Parse Fdf file """
\r
58 fdfParser = FdfParser.FdfParser(fdfFilename)
\r
59 fdfParser.ParseFile()
\r
61 """call workspace build create database"""
\r
62 os.environ["WORKSPACE"] = workspace
\r
63 buildWorkSpace = EdkIIWorkspaceBuild.WorkspaceBuild(activePlatform)
\r
66 GenFds.GenFd(outputDir, fdfParser, buildWorkSpace, archList)
\r
68 def myOptionParser():
\r
69 usage = "%prog [options] -f input_file"
\r
70 parser = OptionParser(usage=usage,description=__copyright__,version="%prog " + str(versionNumber))
\r
71 parser.add_option("-f", "--file", dest="filename", help="Name of FDF file to convert")
\r
72 parser.add_option("-a", "--arch", dest="archList", help="comma separated list containing one or more of: IA32, X64, IPF or EBC which should be built, overrides target.txt?s TARGET_ARCH")
\r
73 parser.add_option("-i", "--interactive", action="store_true", dest="interactive", default=False, help="Set Interactive mode, user must approve each change.")
\r
74 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")
\r
75 parser.add_option("-v", "--verbose", action="count", dest="verbose", default=0, help="Do not print any messages, just return either 0 for succes or 1 for failure")
\r
76 parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False, help="Enable printing of debug messages.")
\r
77 parser.add_option("-p", "--platform", dest="activePlatform", help="Set the Active platform")
\r
78 parser.add_option("-w", "--workspace", dest="workspace", default=str(os.environ.get('WORKSPACE')), help="Enable printing of debug messages.")
\r
79 parser.add_option("-o", "--outputDir", dest="outputDir", help="Name of Output directory")
\r
80 (options, args) = parser.parse_args()
\r
86 FvBinDict = {} # FvName in Fdf, FvBinFile
\r
88 def GenFd (OutputDir, FdfParser, WorkSpace, ArchList):
\r
89 GenFdsGlobalVariable.SetDir (OutputDir, FdfParser, WorkSpace, ArchList)
\r
90 """Set Default Rule! Hard code here will be move"""
\r
91 verSection1 = EfiSection()
\r
92 verSection1.BuildNum = "$(BUILD_NUMBER)"
\r
93 verSection1.SectionType = "VERSION"
\r
94 verSection1.Filename = "$(INF_VERSION)"
\r
95 verSection1.VersionNum = "$(INF_VERSION)"
\r
97 uiSection1 = EfiSection()
\r
98 uiSection1.SectionType = 'UI'
\r
99 uiSection1.Filename = "$(INF_VERSION)"
\r
100 uiSection1.VersionNum = "$(INF_VERSION)"
\r
102 dataSection = EfiSection()
\r
103 dataSection.SectionType = "PE32"
\r
104 dataSection.Filename = "$(INF_OUTPUT)/$(MODULE_NAME).efi"
\r
106 ruleComplexFile1 = RuleComplexFile.RuleComplexFile()
\r
107 ruleComplexFile1.Alignment = 16
\r
108 ruleComplexFile1.Arch = 'COMMON'
\r
109 ruleComplexFile1.CheckSum = True
\r
110 ruleComplexFile1.Fixed = True
\r
111 ruleComplexFile1.FvType = "APPLICATION"
\r
112 ruleComplexFile1.ModuleType = "UEFI_APPLICATION"
\r
113 ruleComplexFile1.NameGuid = "$(MODULE_NAME)"
\r
114 ruleComplexFile1.TemplateName = ''
\r
115 ruleComplexFile1.SectionList = [uiSection1, verSection1, dataSection]
\r
116 GenFdsGlobalVariable.SetDefaultRule(ruleComplexFile1)
\r
118 for item in GenFdsGlobalVariable.FdfParser.profile.FdDict.keys():
\r
119 fd = GenFdsGlobalVariable.FdfParser.profile.FdDict[item]
\r
120 fd.GenFd(GenFds.FvBinDict)
\r
121 for FvName in GenFdsGlobalVariable.FdfParser.profile.FvDict.keys():
\r
122 if not FvName in GenFds.FvBinDict.keys():
\r
123 Buffer = StringIO.StringIO()
\r
124 fv = GenFdsGlobalVariable.FdfParser.profile.FvDict[FvName]
\r
125 fv.AddToBuffer(Buffer)
\r
127 for capsule in GenFdsGlobalVariable.FdfParser.profile.CapsuleList:
\r
128 capsule.GenCapsule()
\r
130 for vtf in GenFdsGlobalVariable.FdfParser.profile.VtfList:
\r
136 # Define GenFd as static function
\r
138 GenFd = staticmethod(GenFd)
\r
140 if __name__ == '__main__':
\r