]>
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 # 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.
18 from __future__
import absolute_import
19 from .Ffs
import SectionSuffix
20 import Common
.LongFilePathOs
as os
21 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
22 from CommonDataClass
.FdfClass
import VerSectionClassObject
23 from Common
.LongFilePathSupport
import OpenLongFilePath
as open
24 from Common
.DataType
import SUP_MODULE_SEC
26 ## generate version section
29 class VerSection (VerSectionClassObject
):
33 # @param self The object pointer
36 VerSectionClassObject
.__init
__(self
)
38 ## GenSection() method
40 # Generate version section
42 # @param self The object pointer
43 # @param OutputPath Where to place output file
44 # @param ModuleName Which module this section belongs to
45 # @param SecNum Index of section
46 # @param KeyStringList Filter for inputs of section generation
47 # @param FfsInf FfsInfStatement object that contains this section data
48 # @param Dict dictionary contains macro and its value
49 # @retval tuple (Generated file name, section alignment)
51 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, KeyStringList
, FfsInf
=None, Dict
={}, IsMakefile
= False):
53 # Prepare the parameter of GenSection
56 self
.Alignment
= FfsInf
.__ExtendMacro
__(self
.Alignment
)
57 self
.BuildNum
= FfsInf
.__ExtendMacro
__(self
.BuildNum
)
58 self
.StringData
= FfsInf
.__ExtendMacro
__(self
.StringData
)
59 self
.FileName
= FfsInf
.__ExtendMacro
__(self
.FileName
)
61 OutputFile
= os
.path
.join(OutputPath
,
62 ModuleName
+ SUP_MODULE_SEC
+ SecNum
+ SectionSuffix
.get('VERSION'))
63 OutputFile
= os
.path
.normpath(OutputFile
)
68 StringData
= self
.StringData
70 FileNameStr
= GenFdsGlobalVariable
.ReplaceWorkspaceMacro(self
.FileName
)
71 FileNameStr
= GenFdsGlobalVariable
.MacroExtend(FileNameStr
, Dict
)
72 FileObj
= open(FileNameStr
, 'r')
73 StringData
= FileObj
.read()
74 StringData
= '"' + StringData
+ '"'
76 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [], 'EFI_SECTION_VERSION',
77 Ver
=StringData
, BuildNumber
=self
.BuildNum
, IsMakefile
=IsMakefile
)
79 OutputFileList
.append(OutputFile
)
80 return OutputFileList
, self
.Alignment