GenFds Tool: Add FdfClassObject.
[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 from CommonDataClass.FdfClassObject import DataSectionClassObject\r
7 \r
8 class DataSection (DataSectionClassObject):\r
9     def __init__(self):\r
10         DataSectionClassObject.__init__(self)\r
11         \r
12     def GenSection(self, OutputPath, ModuleName, keyStringList, FfsInf = None):\r
13         #\r
14         # Prepare the parameter of GenSection\r
15         #\r
16         if FfsInf != None:\r
17             self.Alignment = FfsInf.__ExtendMarco__(self.Alignemnt)\r
18             self.SecType = FfsInf.__ExtendMarco__(self.SecType)\r
19             self.SectFileName = FfsInf.__ExtendMarco__(self.SectFileName)\r
20         else:\r
21             self.SectFileName = GenFdsGlobalVariable.ReplaceWorkspaceMarco(self.SectFileName)\r
22         """Check Section file exist or not !"""\r
23 \r
24         if not os.path.exists(self.SectFileName):\r
25             self.SectFileName = os.path.join (GenFdsGlobalVariable.WorkSpaceDir,\r
26                                               self.SectFileName)\r
27         if self.SecType == 'TE':\r
28             TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')\r
29             GenTeCmd = 'GenFW -t '    + \\r
30                        ' -o '         + \\r
31                         TeFile        + \\r
32                         ' '           + \\r
33                        GenFdsGlobalVariable.ExtendMarco(self.SectFileName)\r
34             print GenTeCmd\r
35             GenFdsGlobalVariable.CallExternalTool(GenTeCmd, "GenFw Failed !")\r
36             self.SectFileName = TeFile\r
37                  \r
38         OutputFile = os.path.join (OutputPath, ModuleName + Ffs.SectionSuffix.get(self.SecType))\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.get (self.SecType)  + \\r
45                          ' '                                             + \\r
46                          GenFdsGlobalVariable.ExtendMarco(self.SectFileName)\r
47 \r
48         #\r
49         # Call GenSection\r
50         #\r
51         \r
52         print GenSectionCmd\r
53         GenFdsGlobalVariable.CallExternalTool(GenSectionCmd, "GenSection Failed!")\r
54         return OutputFile, self.Alignment\r