GenFds Tool: Add FdfClassObject.
[efi/basetools/.git] / Source / Python / GenFds / CompressSection.py
1 from Ffs import Ffs\r
2 import Section\r
3 import subprocess\r
4 import os\r
5 from GenFdsGlobalVariable import GenFdsGlobalVariable\r
6 from CommonDataClass.FdfClassObject import CompressSectionClassObject\r
7 \r
8 class CompressSection (CompressSectionClassObject) :\r
9     CompTypeDict = {\r
10         'PI_STD'     : ' -c PI_STD ',\r
11         'NON_PI_STD' : ' -c NON_PI_STD '\r
12     }\r
13     \r
14     def __init__(self):\r
15         CompressSectionClassObject.__init__(self)\r
16         \r
17 \r
18     def GenSection(self, OutputPath, ModuleName,  KeyStringList, FfsInf = None):\r
19         #\r
20         # Generate all section\r
21         #\r
22         if FfsInf != None:\r
23             self.CompType = FfsInf.__ExtendMarco__(self.CompType)\r
24             self.Alignment = FfsInf.__ExtendMarco__(self.Alignment)\r
25             \r
26         SectFiles = ''\r
27         for Sect in self.SectionList:\r
28             sect, align = Sect.GenSection(OutputPath, ModuleName, KeyStringList, FfsInf)\r
29             if sect != None:\r
30                 SectFiles = SectFiles + \\r
31                             ' '       + \\r
32                             sect\r
33                         \r
34 \r
35         OutputFile = OutputPath + \\r
36                      os.sep     + \\r
37                      ModuleName + \\r
38                      Ffs.SectionSuffix['COMPRESS']\r
39         OutputFile = os.path.normpath(OutputFile)\r
40         \r
41         GenSectionCmd = 'GenSec -o '                                  + \\r
42                          OutputFile                                   + \\r
43                          ' -s '                                       + \\r
44                          Section.Section.SectionType['COMPRESS']      + \\r
45                          self.CompTypeDict[self.CompType]             + \\r
46                          SectFiles\r
47         #\r
48         # Call GenSection\r
49         #\r
50         print GenSectionCmd\r
51         GenFdsGlobalVariable.CallExternalTool(GenSectionCmd, "GenSection Failed!")\r
52         \r
53         return OutputFile, self.Alignment\r
54 \r
55         \r