85510168307954cef03949ee35afa082271c6dfe
[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 \r
30         OutputFile = OutputPath + \\r
31                      os.sep     + \\r
32                      ModuleName + \\r
33                      Ffs.SectionSuffix.get(self.SecType)\r
34         OutputFile = os.path.normpath(OutputFile)\r
35         print "DataSection SectionType: %s" %self.SecType\r
36         print "DataSection SectFileName: %s" %self.SectFileName\r
37         \r
38         GenSectionCmd = 'GenSec -o '                                     + \\r
39                          OutputFile                                      + \\r
40                          ' -s '                                          + \\r
41                          Section.Section.SectionType.get (self.SecType)  + \\r
42                          ' '                                             + \\r
43                          GenFdsGlobalVariable.ExtendMarco(self.SectFileName)\r
44 \r
45         #\r
46         # Call GenSection\r
47         #\r
48         \r
49         print GenSectionCmd\r
50         GenFdsGlobalVariable.CallExternalTool(GenSectionCmd, "GenSection Failed!")\r
51         return OutputFile, self.Alignment\r