]>
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 |
2e351cbe | 6 | # SPDX-License-Identifier: BSD-2-Clause-Patent\r |
30fdf114 LG |
7 | #\r |
8 | \r | |
9 | ##\r | |
10 | # Import Modules\r | |
11 | #\r | |
1ccc4d89 | 12 | from __future__ import absolute_import\r |
9e47e6f9 | 13 | from .Ffs import SectionSuffix\r |
bfa65b61 | 14 | from . import Section\r |
30fdf114 | 15 | import subprocess\r |
97fa0ee9 | 16 | import Common.LongFilePathOs as os\r |
bfa65b61 | 17 | from .GenFdsGlobalVariable import GenFdsGlobalVariable\r |
30fdf114 | 18 | from CommonDataClass.FdfClass import CompressSectionClassObject\r |
8bb63e37 | 19 | from Common.DataType import *\r |
30fdf114 LG |
20 | \r |
21 | ## generate compress section\r | |
22 | #\r | |
23 | #\r | |
24 | class CompressSection (CompressSectionClassObject) :\r | |
25 | \r | |
26 | ## compress types: PI standard and non PI standard\r | |
27 | CompTypeDict = {\r | |
52302d4d LG |
28 | 'PI_STD' : 'PI_STD',\r |
29 | 'PI_NONE' : 'PI_NONE'\r | |
30fdf114 LG |
30 | }\r |
31 | \r | |
32 | ## The constructor\r | |
33 | #\r | |
34 | # @param self The object pointer\r | |
35 | #\r | |
36 | def __init__(self):\r | |
37 | CompressSectionClassObject.__init__(self)\r | |
38 | \r | |
39 | ## GenSection() method\r | |
40 | #\r | |
41 | # Generate compressed section\r | |
42 | #\r | |
43 | # @param self The object pointer\r | |
44 | # @param OutputPath Where to place output file\r | |
45 | # @param ModuleName Which module this section belongs to\r | |
46 | # @param SecNum Index of section\r | |
47 | # @param KeyStringList Filter for inputs of section generation\r | |
48 | # @param FfsInf FfsInfStatement object that contains this section data\r | |
49 | # @param Dict dictionary contains macro and its value\r | |
50 | # @retval tuple (Generated file name, section alignment)\r | |
51 | #\r | |
e32f7bc9 | 52 | def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = None, IsMakefile = False):\r |
30fdf114 | 53 | \r |
4231a819 | 54 | if FfsInf is not None:\r |
30fdf114 LG |
55 | self.CompType = FfsInf.__ExtendMacro__(self.CompType)\r |
56 | self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)\r | |
57 | \r | |
58 | SectFiles = tuple()\r | |
ce2818e4 | 59 | SectAlign = []\r |
30fdf114 | 60 | Index = 0\r |
4f735fc8 | 61 | MaxAlign = None\r |
e32f7bc9 FZ |
62 | if Dict is None:\r |
63 | Dict = {}\r | |
30fdf114 LG |
64 | for Sect in self.SectionList:\r |
65 | Index = Index + 1\r | |
66 | SecIndex = '%s.%d' %(SecNum, Index)\r | |
37de70b7 | 67 | ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=IsMakefile)\r |
4231a819 CJ |
68 | if AlignValue is not None:\r |
69 | if MaxAlign is None:\r | |
4f735fc8 FY |
70 | MaxAlign = AlignValue\r |
71 | if GenFdsGlobalVariable.GetAlignment (AlignValue) > GenFdsGlobalVariable.GetAlignment (MaxAlign):\r | |
72 | MaxAlign = AlignValue\r | |
30fdf114 | 73 | if ReturnSectList != []:\r |
4231a819 | 74 | if AlignValue is None:\r |
4f735fc8 | 75 | AlignValue = "1"\r |
30fdf114 | 76 | for FileData in ReturnSectList:\r |
37de70b7 | 77 | SectFiles += (FileData,)\r |
ce2818e4 | 78 | SectAlign.append(AlignValue)\r |
30fdf114 LG |
79 | \r |
80 | OutputFile = OutputPath + \\r | |
81 | os.sep + \\r | |
82 | ModuleName + \\r | |
8bb63e37 | 83 | SUP_MODULE_SEC + \\r |
30fdf114 | 84 | SecNum + \\r |
9e47e6f9 | 85 | SectionSuffix['COMPRESS']\r |
30fdf114 | 86 | OutputFile = os.path.normpath(OutputFile)\r |
ce2818e4 FY |
87 | DummyFile = OutputFile + '.dummy'\r |
88 | GenFdsGlobalVariable.GenerateSection(DummyFile, SectFiles, InputAlign=SectAlign, IsMakefile=IsMakefile)\r | |
30fdf114 | 89 | \r |
ce2818e4 | 90 | GenFdsGlobalVariable.GenerateSection(OutputFile, [DummyFile], Section.Section.SectionType['COMPRESS'],\r |
37de70b7 | 91 | CompressionType=self.CompTypeDict[self.CompType], IsMakefile=IsMakefile)\r |
30fdf114 LG |
92 | OutputFileList = []\r |
93 | OutputFileList.append(OutputFile)\r | |
94 | return OutputFileList, self.Alignment\r | |
95 | \r | |
96 | \r |