2 # process compress section generation
4 # Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
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
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.
21 import Common
.LongFilePathOs
as os
22 from GenFdsGlobalVariable
import GenFdsGlobalVariable
23 from CommonDataClass
.FdfClass
import CompressSectionClassObject
24 from Common
.DataType
import *
26 ## generate compress section
29 class CompressSection (CompressSectionClassObject
) :
31 ## compress types: PI standard and non PI standard
39 # @param self The object pointer
42 CompressSectionClassObject
.__init
__(self
)
44 ## GenSection() method
46 # Generate compressed section
48 # @param self The object pointer
49 # @param OutputPath Where to place output file
50 # @param ModuleName Which module this section belongs to
51 # @param SecNum Index of section
52 # @param KeyStringList Filter for inputs of section generation
53 # @param FfsInf FfsInfStatement object that contains this section data
54 # @param Dict dictionary contains macro and its value
55 # @retval tuple (Generated file name, section alignment)
57 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, KeyStringList
, FfsInf
= None, Dict
= {}, IsMakefile
= False):
59 if FfsInf
is not None:
60 self
.CompType
= FfsInf
.__ExtendMacro
__(self
.CompType
)
61 self
.Alignment
= FfsInf
.__ExtendMacro
__(self
.Alignment
)
67 for Sect
in self
.SectionList
:
69 SecIndex
= '%s.%d' %(SecNum
, Index
)
70 ReturnSectList
, AlignValue
= Sect
.GenSection(OutputPath
, ModuleName
, SecIndex
, KeyStringList
, FfsInf
, Dict
, IsMakefile
=IsMakefile
)
71 if AlignValue
is not None:
74 if GenFdsGlobalVariable
.GetAlignment (AlignValue
) > GenFdsGlobalVariable
.GetAlignment (MaxAlign
):
76 if ReturnSectList
!= []:
77 if AlignValue
is None:
79 for FileData
in ReturnSectList
:
80 SectFiles
+= (FileData
,)
81 SectAlign
.append(AlignValue
)
83 OutputFile
= OutputPath
+ \
88 Ffs
.SectionSuffix
['COMPRESS']
89 OutputFile
= os
.path
.normpath(OutputFile
)
90 DummyFile
= OutputFile
+ '.dummy'
91 GenFdsGlobalVariable
.GenerateSection(DummyFile
, SectFiles
, InputAlign
=SectAlign
, IsMakefile
=IsMakefile
)
93 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [DummyFile
], Section
.Section
.SectionType
['COMPRESS'],
94 CompressionType
=self
.CompTypeDict
[self
.CompType
], IsMakefile
=IsMakefile
)
96 OutputFileList
.append(OutputFile
)
97 return OutputFileList
, self
.Alignment