2 # process compress section generation
4 # Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
6 # SPDX-License-Identifier: BSD-2-Clause-Patent
12 from __future__
import absolute_import
13 from .Ffs
import SectionSuffix
16 import Common
.LongFilePathOs
as os
17 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
18 from CommonDataClass
.FdfClass
import CompressSectionClassObject
19 from Common
.DataType
import *
21 ## generate compress section
24 class CompressSection (CompressSectionClassObject
) :
26 ## compress types: PI standard and non PI standard
34 # @param self The object pointer
37 CompressSectionClassObject
.__init
__(self
)
39 ## GenSection() method
41 # Generate compressed section
43 # @param self The object pointer
44 # @param OutputPath Where to place output file
45 # @param ModuleName Which module this section belongs to
46 # @param SecNum Index of section
47 # @param KeyStringList Filter for inputs of section generation
48 # @param FfsInf FfsInfStatement object that contains this section data
49 # @param Dict dictionary contains macro and its value
50 # @retval tuple (Generated file name, section alignment)
52 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, KeyStringList
, FfsInf
= None, Dict
= {}, IsMakefile
= False):
54 if FfsInf
is not None:
55 self
.CompType
= FfsInf
.__ExtendMacro
__(self
.CompType
)
56 self
.Alignment
= FfsInf
.__ExtendMacro
__(self
.Alignment
)
62 for Sect
in self
.SectionList
:
64 SecIndex
= '%s.%d' %(SecNum
, Index
)
65 ReturnSectList
, AlignValue
= Sect
.GenSection(OutputPath
, ModuleName
, SecIndex
, KeyStringList
, FfsInf
, Dict
, IsMakefile
=IsMakefile
)
66 if AlignValue
is not None:
69 if GenFdsGlobalVariable
.GetAlignment (AlignValue
) > GenFdsGlobalVariable
.GetAlignment (MaxAlign
):
71 if ReturnSectList
!= []:
72 if AlignValue
is None:
74 for FileData
in ReturnSectList
:
75 SectFiles
+= (FileData
,)
76 SectAlign
.append(AlignValue
)
78 OutputFile
= OutputPath
+ \
83 SectionSuffix
['COMPRESS']
84 OutputFile
= os
.path
.normpath(OutputFile
)
85 DummyFile
= OutputFile
+ '.dummy'
86 GenFdsGlobalVariable
.GenerateSection(DummyFile
, SectFiles
, InputAlign
=SectAlign
, IsMakefile
=IsMakefile
)
88 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [DummyFile
], Section
.Section
.SectionType
['COMPRESS'],
89 CompressionType
=self
.CompTypeDict
[self
.CompType
], IsMakefile
=IsMakefile
)
91 OutputFileList
.append(OutputFile
)
92 return OutputFileList
, self
.Alignment