]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/VerSection.py
2 # process Version section generation
4 # Copyright (c) 2007 - 2018, 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
14 import Common
.LongFilePathOs
as os
15 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
16 from CommonDataClass
.FdfClass
import VerSectionClassObject
17 from Common
.LongFilePathSupport
import OpenLongFilePath
as open
18 from Common
.DataType
import SUP_MODULE_SEC
20 ## generate version section
23 class VerSection (VerSectionClassObject
):
27 # @param self The object pointer
30 VerSectionClassObject
.__init
__(self
)
32 ## GenSection() method
34 # Generate version section
36 # @param self The object pointer
37 # @param OutputPath Where to place output file
38 # @param ModuleName Which module this section belongs to
39 # @param SecNum Index of section
40 # @param KeyStringList Filter for inputs of section generation
41 # @param FfsInf FfsInfStatement object that contains this section data
42 # @param Dict dictionary contains macro and its value
43 # @retval tuple (Generated file name, section alignment)
45 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, KeyStringList
, FfsInf
=None, Dict
={}, IsMakefile
= False):
47 # Prepare the parameter of GenSection
50 self
.Alignment
= FfsInf
.__ExtendMacro
__(self
.Alignment
)
51 self
.BuildNum
= FfsInf
.__ExtendMacro
__(self
.BuildNum
)
52 self
.StringData
= FfsInf
.__ExtendMacro
__(self
.StringData
)
53 self
.FileName
= FfsInf
.__ExtendMacro
__(self
.FileName
)
55 OutputFile
= os
.path
.join(OutputPath
,
56 ModuleName
+ SUP_MODULE_SEC
+ SecNum
+ SectionSuffix
.get('VERSION'))
57 OutputFile
= os
.path
.normpath(OutputFile
)
62 StringData
= self
.StringData
64 FileNameStr
= GenFdsGlobalVariable
.ReplaceWorkspaceMacro(self
.FileName
)
65 FileNameStr
= GenFdsGlobalVariable
.MacroExtend(FileNameStr
, Dict
)
66 FileObj
= open(FileNameStr
, 'r')
67 StringData
= FileObj
.read()
68 StringData
= '"' + StringData
+ '"'
70 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [], 'EFI_SECTION_VERSION',
71 Ver
=StringData
, BuildNumber
=self
.BuildNum
, IsMakefile
=IsMakefile
)
73 OutputFileList
.append(OutputFile
)
74 return OutputFileList
, self
.Alignment