GenFds Tool: Add FdfClassObject.
[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 from CommonDataClass.FdfClassObject import FvImageSectionClassObject\r
8 \r
9 class FvImageSection(FvImageSectionClassObject):\r
10     def __init__(self):\r
11 ##        self.Aligenment = None\r
12 ##        self.Fv = None\r
13 ##        self.FvName = None\r
14         FvImageSectionClassObject.__init__(self)\r
15         \r
16     def GenSection(self, OutputPath, ModuleName, KeyStringList, FfsInf = None):\r
17         Buffer = StringIO.StringIO('')\r
18         #\r
19         # Generate Fv\r
20         #\r
21         if self.FvName != None:\r
22             Fv = GenFdsGlobalVariable.FdfParser.profile.FvDict.get(self.FvName)\r
23             if self.Fv == None:\r
24                 self.Fv = Fv\r
25             else:\r
26                 raise Exception("FvImageSection Failed! Can't describe the \\r
27                                  FvImageSection both in FvUiName and \\r
28                                  FvImageArg!")\r
29                                  \r
30         FvFileName = self.Fv.AddToBuffer(Buffer)\r
31         #\r
32         # Prepare the parameter of GenSection\r
33         #\r
34         OutputFile = os.path.join(OutputPath, ModuleName + Ffs.SectionSuffix.get("FV_IMAGE"))\r
35                      \r
36         GenSectionCmd = 'GenSec -o '                          + \\r
37                          OutputFile                           + \\r
38                          ' -s '                               + \\r
39                          'EFI_SECTION_FIRMWARE_VOLUME_IMAGE ' + \\r
40                          FvFileName\r
41                          \r
42         print GenSectionCmd\r
43         GenFdsGlobalVariable.CallExternalTool(GenSectionCmd, "GenSection Failed!")\r
44         return OutputFile, self.Alignment\r