Set the py files to executable
[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, SecNum, 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         Index = 0\r
28         for Sect in self.SectionList:\r
29             Index = Index + 1\r
30             SecIndex = '%s.%d' %(SecNum, Index)\r
31             sect, align = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf)\r
32             if sect != None:\r
33                 SectFiles = SectFiles + \\r
34                             ' '       + \\r
35                             sect\r
36                         \r
37 \r
38         OutputFile = OutputPath + \\r
39                      os.sep     + \\r
40                      ModuleName + \\r
41                      'SEC'      + \\r
42                      SecNum     + \\r
43                      Ffs.SectionSuffix['COMPRESS']\r
44         OutputFile = os.path.normpath(OutputFile)\r
45         \r
46         GenSectionCmd = 'GenSec -o '                                  + \\r
47                          OutputFile                                   + \\r
48                          ' -s '                                       + \\r
49                          Section.Section.SectionType['COMPRESS']      + \\r
50                          self.CompTypeDict[self.CompType]             + \\r
51                          SectFiles\r
52         #\r
53         # Call GenSection\r
54         #\r
55         GenFdsGlobalVariable.CallExternalTool(GenSectionCmd, "GenSection Failed!")\r
56         \r
57         return OutputFile, self.Alignment\r
58 \r
59         \r