Modify GenFds related files.
[people/mcb30/basetools.git] / Source / Python / GenFds / FvImageSection.py
1 import Section\r
2 import StringIO\r
3 from Ffs import Ffs\r
4 import subprocess\r
5 from GenFdsGlobalVariable import GenFdsGlobalVariable\r
6 import os\r
7 \r
8 class FvImageSection(Section.Section):\r
9     def __init__(self):\r
10         self.Aligenment = None\r
11         self.Fv = None\r
12         self.FvName = None\r
13     def GenSection(self, OutputPath, ModuleName, KeyStringList, FfsInf = None):\r
14         Buffer = StringIO.StringIO('')\r
15         #\r
16         # Generate Fv\r
17         #\r
18         if self.FvName != None:\r
19             Fv = GenFdsGlobalVariable.FdfParser.profile.FvDict.get(self.FvName)\r
20             if self.Fv == None:\r
21                 self.Fv = Fv\r
22             else:\r
23                 raise Exception("FvImageSection Failed! Can't describe the \\r
24                                  FvImageSection both in FvUiName and \\r
25                                  FvImageArg!")\r
26                                  \r
27         FvFileName = self.Fv.AddToBuffer(Buffer)\r
28         #\r
29         # Prepare the parameter of GenSection\r
30         #\r
31         OutputFile = os.path.join(OutputPath, ModuleName + Ffs.SectionSuffix.get("FV_IMAGE"))\r
32                      \r
33         GenSectionCmd = 'GenSec -o '                          + \\r
34                          OutputFile                           + \\r
35                          ' -s '                               + \\r
36                          'EFI_SECTION_FIRMWARE_VOLUME_IMAGE ' + \\r
37                          FvFileName\r
38                          \r
39         print GenSectionCmd\r
40         GenFdsGlobalVariable.CallExternalTool(GenSectionCmd, "GenSection Failed!")\r
41         return OutputFile, self.Aligenment\r