]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/CompressSection.py
BaseTools:change some incorrect parameter defaults
[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 # SPDX-License-Identifier: BSD-2-Clause-Patent
7 #
8
9 ##
10 # Import Modules
11 #
12 from __future__ import absolute_import
13 from .Ffs import SectionSuffix
14 from . import Section
15 import subprocess
16 import Common.LongFilePathOs as os
17 from .GenFdsGlobalVariable import GenFdsGlobalVariable
18 from CommonDataClass.FdfClass import CompressSectionClassObject
19 from Common.DataType import *
20
21 ## generate compress section
22 #
23 #
24 class CompressSection (CompressSectionClassObject) :
25
26 ## compress types: PI standard and non PI standard
27 CompTypeDict = {
28 'PI_STD' : 'PI_STD',
29 'PI_NONE' : 'PI_NONE'
30 }
31
32 ## The constructor
33 #
34 # @param self The object pointer
35 #
36 def __init__(self):
37 CompressSectionClassObject.__init__(self)
38
39 ## GenSection() method
40 #
41 # Generate compressed section
42 #
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)
51 #
52 def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = None, IsMakefile = False):
53
54 if FfsInf is not None:
55 self.CompType = FfsInf.__ExtendMacro__(self.CompType)
56 self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)
57
58 SectFiles = tuple()
59 SectAlign = []
60 Index = 0
61 MaxAlign = None
62 if Dict is None:
63 Dict = {}
64 for Sect in self.SectionList:
65 Index = Index + 1
66 SecIndex = '%s.%d' %(SecNum, Index)
67 ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=IsMakefile)
68 if AlignValue is not None:
69 if MaxAlign is None:
70 MaxAlign = AlignValue
71 if GenFdsGlobalVariable.GetAlignment (AlignValue) > GenFdsGlobalVariable.GetAlignment (MaxAlign):
72 MaxAlign = AlignValue
73 if ReturnSectList != []:
74 if AlignValue is None:
75 AlignValue = "1"
76 for FileData in ReturnSectList:
77 SectFiles += (FileData,)
78 SectAlign.append(AlignValue)
79
80 OutputFile = OutputPath + \
81 os.sep + \
82 ModuleName + \
83 SUP_MODULE_SEC + \
84 SecNum + \
85 SectionSuffix['COMPRESS']
86 OutputFile = os.path.normpath(OutputFile)
87 DummyFile = OutputFile + '.dummy'
88 GenFdsGlobalVariable.GenerateSection(DummyFile, SectFiles, InputAlign=SectAlign, IsMakefile=IsMakefile)
89
90 GenFdsGlobalVariable.GenerateSection(OutputFile, [DummyFile], Section.Section.SectionType['COMPRESS'],
91 CompressionType=self.CompTypeDict[self.CompType], IsMakefile=IsMakefile)
92 OutputFileList = []
93 OutputFileList.append(OutputFile)
94 return OutputFileList, self.Alignment
95
96