GenFds Tool: Add FdfClassObject.
[people/mcb30/basetools.git] / Source / Python / GenFds / FfsFileStatement.py
1 import Ffs\r
2 import Rule\r
3 from GenFdsGlobalVariable import GenFdsGlobalVariable\r
4 import os\r
5 import subprocess\r
6 from CommonDataClass.FdfClassObject import FileStatementsClassObject\r
7 \r
8 class FileStatements (FileStatementsClassObject) :\r
9     def __init__(self):\r
10         FileStatementsClassObject.__init__(self)\r
11         \r
12     def GenFfs(self):\r
13         OutputDir = os.path.join(GenFdsGlobalVariable.FfsDir, self.NameGuid)\r
14         if not os.path.exists(OutputDir):\r
15              os.makedirs(OutputDir)\r
16 \r
17         if self.FileName != None :\r
18             SectionFiles = ' -i ' + \\r
19                           GenFdsGlobalVariable.ReplaceWorkspaceMarco(self.FileName)\r
20         else:\r
21             SectionFiles = ''\r
22             for section in self.SectionList :\r
23                 sect, align = section.GenSection(OutputDir, self.NameGuid, self.KeyStringList)\r
24                 if sect != None:\r
25                     SectionFiles = SectionFiles  + \\r
26                                    ' -i '        + \\r
27                                    sect\r
28                     if align != None:\r
29                         SectionFiles = SectionFiles  + \\r
30                                        ' -n '        + \\r
31                                        align\r
32                                \r
33         #\r
34         # Prepare the parameter\r
35         #\r
36         print "Fixe = ", self.Fixed\r
37         if self.Fixed != False:\r
38                 Fixed = ' -x '\r
39         else :\r
40                 Fixed = ''\r
41         print "CheckSum=", self.CheckSum\r
42         if self.CheckSum != False :\r
43                 CheckSum = ' -s '\r
44         else :\r
45                 CheckSum = ''\r
46                 \r
47         if self.Alignment != None and self.Alignment !='':\r
48                 Alignment = ' -a ' + '%s' %self.Alignment\r
49         else :\r
50                 Alignment = ''\r
51                 \r
52         if not (self.FvType == None):\r
53             FileType = ' -t ' + Ffs.Ffs.FvTypeToFileType.get(self.FvType)\r
54         else:\r
55             FileType = ''\r
56 \r
57         FfsFileOutput = os.path.join(OutputDir, self.NameGuid + '.ffs')\r
58                     \r
59   \r
60         GenFfsCmd = 'GenFfs' +  \\r
61                      FileType +     \\r
62                      Fixed +        \\r
63                      CheckSum +     \\r
64                      Alignment +    \\r
65                      ' -o ' +       \\r
66                      FfsFileOutput +    \\r
67                      ' -g ' +       \\r
68                      self.NameGuid +\\r
69                      SectionFiles\r
70      \r
71         print GenFfsCmd\r
72         GenFdsGlobalVariable.CallExternalTool(GenFfsCmd,"GenFfs Failed !")\r
73         return FfsFileOutput\r
74         \r
75 \r