]>
Commit | Line | Data |
---|---|---|
30fdf114 LG |
1 | ## @file\r |
2 | # process compress section generation\r | |
3 | #\r | |
37de70b7 | 4 | # Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r |
30fdf114 | 5 | #\r |
40d841f6 | 6 | # This program and the accompanying materials\r |
30fdf114 LG |
7 | # are licensed and made available under the terms and conditions of the BSD License\r |
8 | # which accompanies this distribution. The full text of the license may be found at\r | |
9 | # http://opensource.org/licenses/bsd-license.php\r | |
10 | #\r | |
11 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | #\r | |
14 | \r | |
15 | ##\r | |
16 | # Import Modules\r | |
17 | #\r | |
bfa65b61 GL |
18 | from __future__ import absolute_import\r |
19 | from .Ffs import Ffs\r | |
20 | from . import Section\r | |
30fdf114 | 21 | import subprocess\r |
97fa0ee9 | 22 | import Common.LongFilePathOs as os\r |
bfa65b61 | 23 | from .GenFdsGlobalVariable import GenFdsGlobalVariable\r |
30fdf114 | 24 | from CommonDataClass.FdfClass import CompressSectionClassObject\r |
8bb63e37 | 25 | from Common.DataType import *\r |
30fdf114 LG |
26 | \r |
27 | ## generate compress section\r | |
28 | #\r | |
29 | #\r | |
30 | class CompressSection (CompressSectionClassObject) :\r | |
31 | \r | |
32 | ## compress types: PI standard and non PI standard\r | |
33 | CompTypeDict = {\r | |
52302d4d LG |
34 | 'PI_STD' : 'PI_STD',\r |
35 | 'PI_NONE' : 'PI_NONE'\r | |
30fdf114 LG |
36 | }\r |
37 | \r | |
38 | ## The constructor\r | |
39 | #\r | |
40 | # @param self The object pointer\r | |
41 | #\r | |
42 | def __init__(self):\r | |
43 | CompressSectionClassObject.__init__(self)\r | |
44 | \r | |
45 | ## GenSection() method\r | |
46 | #\r | |
47 | # Generate compressed section\r | |
48 | #\r | |
49 | # @param self The object pointer\r | |
50 | # @param OutputPath Where to place output file\r | |
51 | # @param ModuleName Which module this section belongs to\r | |
52 | # @param SecNum Index of section\r | |
53 | # @param KeyStringList Filter for inputs of section generation\r | |
54 | # @param FfsInf FfsInfStatement object that contains this section data\r | |
55 | # @param Dict dictionary contains macro and its value\r | |
56 | # @retval tuple (Generated file name, section alignment)\r | |
57 | #\r | |
37de70b7 | 58 | def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False):\r |
30fdf114 | 59 | \r |
4231a819 | 60 | if FfsInf is not None:\r |
30fdf114 LG |
61 | self.CompType = FfsInf.__ExtendMacro__(self.CompType)\r |
62 | self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)\r | |
63 | \r | |
64 | SectFiles = tuple()\r | |
ce2818e4 | 65 | SectAlign = []\r |
30fdf114 | 66 | Index = 0\r |
4f735fc8 | 67 | MaxAlign = None\r |
30fdf114 LG |
68 | for Sect in self.SectionList:\r |
69 | Index = Index + 1\r | |
70 | SecIndex = '%s.%d' %(SecNum, Index)\r | |
37de70b7 | 71 | ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=IsMakefile)\r |
4231a819 CJ |
72 | if AlignValue is not None:\r |
73 | if MaxAlign is None:\r | |
4f735fc8 FY |
74 | MaxAlign = AlignValue\r |
75 | if GenFdsGlobalVariable.GetAlignment (AlignValue) > GenFdsGlobalVariable.GetAlignment (MaxAlign):\r | |
76 | MaxAlign = AlignValue\r | |
30fdf114 | 77 | if ReturnSectList != []:\r |
4231a819 | 78 | if AlignValue is None:\r |
4f735fc8 | 79 | AlignValue = "1"\r |
30fdf114 | 80 | for FileData in ReturnSectList:\r |
37de70b7 | 81 | SectFiles += (FileData,)\r |
ce2818e4 | 82 | SectAlign.append(AlignValue)\r |
30fdf114 LG |
83 | \r |
84 | OutputFile = OutputPath + \\r | |
85 | os.sep + \\r | |
86 | ModuleName + \\r | |
8bb63e37 | 87 | SUP_MODULE_SEC + \\r |
30fdf114 LG |
88 | SecNum + \\r |
89 | Ffs.SectionSuffix['COMPRESS']\r | |
90 | OutputFile = os.path.normpath(OutputFile)\r | |
ce2818e4 FY |
91 | DummyFile = OutputFile + '.dummy'\r |
92 | GenFdsGlobalVariable.GenerateSection(DummyFile, SectFiles, InputAlign=SectAlign, IsMakefile=IsMakefile)\r | |
30fdf114 | 93 | \r |
ce2818e4 | 94 | GenFdsGlobalVariable.GenerateSection(OutputFile, [DummyFile], Section.Section.SectionType['COMPRESS'],\r |
37de70b7 | 95 | CompressionType=self.CompTypeDict[self.CompType], IsMakefile=IsMakefile)\r |
30fdf114 LG |
96 | OutputFileList = []\r |
97 | OutputFileList.append(OutputFile)\r | |
98 | return OutputFileList, self.Alignment\r | |
99 | \r | |
100 | \r |