1 from optparse import OptionParser
\r
5 from GenFdsGlobalVariable import GenFdsGlobalVariable
\r
6 import Common.EdkIIWorkspaceBuild
\r
7 import RuleComplexFile
\r
8 from EfiSection import EfiSection
\r
10 import Common.TargetTxtClassObject
\r
12 versionNumber = "1.0"
\r
13 __version__ = "%prog Version " + versionNumber
\r
14 __copyright__ = "Copyright (c) 2007, Intel Corporation All rights reserved."
\r
19 options = myOptionParser()
\r
24 if (options.workspace == None):
\r
25 print "ERROR: E0000: WORKSPACE not defined.\n Please set the WORKSPACE environment variable to the location of the EDK II install directory."
\r
28 workspace = options.workspace
\r
29 GenFdsGlobalVariable.WorkSpaceDir = workspace
\r
31 print "Using Workspace:", workspace
\r
33 if (options.filename):
\r
34 fdfFilename = options.filename
\r
36 print "ERROR: E0001 - You must specify an input filename"
\r
39 if not os.path.exists(fdfFilename):
\r
40 print "ERROR: E1000: File %s not found" % (filename)
\r
43 if (options.activePlatform):
\r
44 activePlatform = options.activePlatform
\r
46 Target = Common.TargetTxtClassObject.TargetTxtDict(GenFdsGlobalVariable.WorkSpaceDir)
\r
47 activePlatform = Target.TargetTxtDictionary['ACTIVE_PLATFORM']
\r
49 GenFdsGlobalVariable.ActivePlatform = activePlatform
\r
52 if (options.outputDir):
\r
53 outputDir = options.outputDir
\r
55 print "ERROR: E0001 - You must specify an Output directory"
\r
58 if (options.archList) :
\r
59 archList = options.archList.split(',')
\r
63 """ Parse Fdf file """
\r
64 fdfParser = FdfParser.FdfParser(fdfFilename)
\r
65 fdfParser.ParseFile()
\r
67 """call workspace build create database"""
\r
68 os.environ["WORKSPACE"] = workspace
\r
69 buildWorkSpace = Common.EdkIIWorkspaceBuild.WorkspaceBuild(activePlatform, workspace)
\r
70 buildWorkSpace.GenBuildDatabase()
\r
73 GenFds.GenFd(outputDir, fdfParser, buildWorkSpace, archList)
\r
75 def myOptionParser():
\r
76 usage = "%prog [options] -f input_file"
\r
77 parser = OptionParser(usage=usage,description=__copyright__,version="%prog " + str(versionNumber))
\r
78 parser.add_option("-f", "--file", dest="filename", help="Name of FDF file to convert")
\r
79 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
80 parser.add_option("-i", "--interactive", action="store_true", dest="interactive", default=False, help="Set Interactive mode, user must approve each change.")
\r
81 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
82 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
83 parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False, help="Enable printing of debug messages.")
\r
84 parser.add_option("-p", "--platform", dest="activePlatform", help="Set the Active platform")
\r
85 parser.add_option("-w", "--workspace", dest="workspace", default=str(os.environ.get('WORKSPACE')), help="Enable printing of debug messages.")
\r
86 parser.add_option("-o", "--outputDir", dest="outputDir", help="Name of Output directory")
\r
87 (options, args) = parser.parse_args()
\r
93 FvBinDict = {} # FvName in Fdf, FvBinFile
\r
95 def GenFd (OutputDir, FdfParser, WorkSpace, ArchList):
\r
96 GenFdsGlobalVariable.SetDir (OutputDir, FdfParser, WorkSpace, ArchList)
\r
97 """Set Default Rule! Hard code here will be move"""
\r
98 verSection1 = EfiSection()
\r
99 verSection1.BuildNum = "$(BUILD_NUMBER)"
\r
100 verSection1.SectionType = "VERSION"
\r
101 verSection1.Filename = "$(INF_VERSION)"
\r
102 verSection1.VersionNum = "$(INF_VERSION)"
\r
104 uiSection1 = EfiSection()
\r
105 uiSection1.SectionType = 'UI'
\r
106 uiSection1.Filename = "$(INF_VERSION)"
\r
107 uiSection1.VersionNum = "$(INF_VERSION)"
\r
109 dataSection = EfiSection()
\r
110 dataSection.SectionType = "PE32"
\r
111 dataSection.Filename = "$(INF_OUTPUT)/$(MODULE_NAME).efi"
\r
113 ruleComplexFile1 = RuleComplexFile.RuleComplexFile()
\r
114 ruleComplexFile1.Alignment = 16
\r
115 ruleComplexFile1.Arch = 'COMMON'
\r
116 ruleComplexFile1.CheckSum = True
\r
117 ruleComplexFile1.Fixed = True
\r
118 ruleComplexFile1.FvType = "APPLICATION"
\r
119 ruleComplexFile1.ModuleType = "UEFI_APPLICATION"
\r
120 ruleComplexFile1.NameGuid = "$(MODULE_NAME)"
\r
121 ruleComplexFile1.TemplateName = ''
\r
122 ruleComplexFile1.SectionList = [uiSection1, verSection1, dataSection]
\r
123 GenFdsGlobalVariable.SetDefaultRule(ruleComplexFile1)
\r
125 for item in GenFdsGlobalVariable.FdfParser.profile.FdDict.keys():
\r
126 fd = GenFdsGlobalVariable.FdfParser.profile.FdDict[item]
\r
127 fd.GenFd(GenFds.FvBinDict)
\r
128 for FvName in GenFdsGlobalVariable.FdfParser.profile.FvDict.keys():
\r
129 if not FvName in GenFds.FvBinDict.keys():
\r
130 Buffer = StringIO.StringIO()
\r
131 fv = GenFdsGlobalVariable.FdfParser.profile.FvDict[FvName]
\r
132 fv.AddToBuffer(Buffer)
\r
135 #print "######### Gen Capsule ####################"
\r
136 for capsule in GenFdsGlobalVariable.FdfParser.profile.CapsuleList:
\r
137 capsule.GenCapsule()
\r
139 ## for vtf in GenFdsGlobalVariable.FdfParser.profile.VtfList:
\r
144 for item in GenFdsGlobalVariable.FdfParser.profile.VtfList:
\r
145 for comp in item.ComponentStatementList:
\r
146 if comp.CompLoc != None :
\r
147 compList.append(comp.Loc)
\r
148 GenFdsGlobalVariable.VtfDict[item.UiName] = compList
\r
150 # Define GenFd as static function
\r
152 GenFd = staticmethod(GenFd)
\r
154 if __name__ == '__main__':
\r