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