2 from GenFdsGlobalVariable import GenFdsGlobalVariable
\r
7 class EfiSection (Section.Section):
\r
10 self.Alignment = None
\r
11 self.SectionType = None
\r
12 self.Optional = False
\r
13 # store file name composed of MACROs
\r
14 # Currently only support the String after UI section
\r
15 self.Filename = None
\r
16 self.BuildNum = None
\r
17 self.VersionNum = None
\r
19 def GenSection(self, OutputPath, ModuleName, KeyStringList, FfsInf = None) :
\r
21 # Prepare the parameter of GenSection
\r
24 InfFileName = FfsInf.InfFileName
\r
25 SectionType = FfsInf.__ExtendMarco__(self.SectionType)
\r
26 #print 'File Name : %s' %self.Filename
\r
27 Filename = FfsInf.__ExtendMarco__(self.Filename)
\r
28 #print 'After Extend File Name: %s' %self.Filename
\r
29 #print 'Buile Num: %s' %self.BuildNum
\r
30 BuildNum = FfsInf.__ExtendMarco__(self.BuildNum)
\r
31 #print 'After extend Build Num: %s' %self.BuildNum
\r
32 #print 'version Num: %s' %self.VersionNum
\r
33 VersionNum = FfsInf.__ExtendMarco__(self.VersionNum)
\r
34 #print 'After extend Version Num: %s' %self.VersionNum
\r
36 SectionType = self.SectionType
\r
37 Filename = self.Filename
\r
38 BuildNum = self.BuildNum
\r
39 VerstionNum = self.VersionNum
\r
42 if self.Optional == True :
\r
43 if Filename == None or Filename =='':
\r
44 print "Optional Section don't exist!"
\r
47 OutputFile = os.path.join( OutputPath, ModuleName + Ffs.SectionSuffix.get(SectionType))
\r
49 # If Section type is 'VERSION'
\r
51 if SectionType == 'VERSION':
\r
52 if Filename != None:
\r
53 VerString = ' -n ' + \
\r
60 if BuildNum != None and BuildNum != '':
\r
61 BuildNumString = ' -j ' + \
\r
65 if VerString == '' and BuildNumString == '':
\r
66 if self.Optional == True :
\r
67 print "Optional Section don't exist!"
\r
70 raise Exception ("File: %s miss Version Section value" %InfFileName)
\r
71 GenSectionCmd = 'GenSec -o ' + \
\r
73 ' -s EFI_SECTION_VERSION' + \
\r
77 # If Section Type is 'UI'
\r
79 elif SectionType == 'UI':
\r
80 #if self.Filename != None :
\r
81 # f = open (self.Filename, 'r')
\r
82 # UiString = f.read ()
\r
84 # UiString = ' -n ' + \
\r
88 if Filename != None:
\r
89 UiString = ' -n ' + \
\r
97 if self.Optional == True :
\r
98 print "Optional Section don't exist!"
\r
101 raise Exception ("File: %s miss UI Section value" %InfFileName)
\r
103 GenSectionCmd = 'GenSec -o ' + \
\r
105 ' -s EFI_SECTION_USER_INTERFACE' + \
\r
108 if Filename == None or not os.path.exists(Filename) :
\r
109 if self.Optional == True:
\r
110 print "Optional Section don't exist!"
\r
113 raise Exception(" %s does't exist" %Filename)
\r
115 # For TE Section call GenFw to generate TE image
\r
117 if SectionType == 'TE':
\r
118 TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
\r
119 GenTeCmd = 'GenFW -t ' + \
\r
123 GenFdsGlobalVariable.ExtendMarco(Filename)
\r
125 GenFdsGlobalVariable.CallExternalTool(GenTeCmd, "GenFw Failed !")
\r
129 GenSectionCmd = 'GenSec -o ' + \
\r
132 Section.Section.SectionType.get (SectionType) + \
\r
134 GenFdsGlobalVariable.ExtendMarco(Filename)
\r
138 print GenSectionCmd
\r
139 GenFdsGlobalVariable.CallExternalTool(GenSectionCmd, "GenSection Failed !")
\r
140 return OutputFile , self.Alignment
\r