Modify GenFds related files.
[people/mcb30/basetools.git] / Source / Python / GenFds / DataSection.py
1 import Section\r
2 from GenFdsGlobalVariable import GenFdsGlobalVariable\r
3 import subprocess\r
4 from Ffs import Ffs\r
5 import os\r
6 \r
7 class DataSection (Section.Section):\r
8     def __init__(self):\r
9         self.Alignment = None\r
10         self.SecType = None\r
11         self.SectFileName = None\r
12         self.SectionList = []\r
13         \r
14     def GenSection(self, OutputPath, ModuleName, keyStringList, FfsInf = None):\r
15         #\r
16         # Prepare the parameter of GenSection\r
17         #\r
18         if FfsInf != None:\r
19             self.Alignment = FfsInf.__ExtendMarco__(self.Alignemnt)\r
20             self.SecType = FfsInf.__ExtendMarco__(self.SecType)\r
21             self.SectFileName = FfsInf.__ExtendMarco__(self.SectFileName)\r
22         else:\r
23             self.SectFileName = GenFdsGlobalVariable.ReplaceWorkspaceMarco(self.SectFileName)\r
24         """Check Section file exist or not !"""\r
25 \r
26         if not os.path.exists(self.SectFileName):\r
27             self.SectFileName = os.path.join (GenFdsGlobalVariable.WorkSpaceDir,\r
28                                               self.SectFileName)\r
29         if self.SecType == 'TE':\r
30             TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')\r
31             GenTeCmd = 'GenFW -t '    + \\r
32                        ' -o '         + \\r
33                         TeFile        + \\r
34                         ' '           + \\r
35                        GenFdsGlobalVariable.ExtendMarco(self.SectFileName)\r
36             print GenTeCmd\r
37             GenFdsGlobalVariable.CallExternalTool(GenTeCmd, "GenFw Failed !")\r
38             self.SectFileName = TeFile\r
39                  \r
40         OutputFile = os.path.join (OutputPath, ModuleName + Ffs.SectionSuffix.get(self.SecType))\r
41         OutputFile = os.path.normpath(OutputFile)\r
42         \r
43         GenSectionCmd = 'GenSec -o '                                     + \\r
44                          OutputFile                                      + \\r
45                          ' -s '                                          + \\r
46                          Section.Section.SectionType.get (self.SecType)  + \\r
47                          ' '                                             + \\r
48                          GenFdsGlobalVariable.ExtendMarco(self.SectFileName)\r
49 \r
50         #\r
51         # Call GenSection\r
52         #\r
53         \r
54         print GenSectionCmd\r
55         GenFdsGlobalVariable.CallExternalTool(GenSectionCmd, "GenSection Failed!")\r
56         return OutputFile, self.Alignment\r