]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/VerSection.py
456a430079bb2159b7269743c911c6c5b7e6108e
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / VerSection.py
1 ## @file
2 # process Version section generation
3 #
4 # Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
5 #
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
10 #
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.
13 #
14
15 ##
16 # Import Modules
17 #
18 from Ffs import Ffs
19 import Section
20 import Common.LongFilePathOs as os
21 import subprocess
22 from GenFdsGlobalVariable import GenFdsGlobalVariable
23 from CommonDataClass.FdfClass import VerSectionClassObject
24 from Common.LongFilePathSupport import OpenLongFilePath as open
25 from Common.DataType import SUP_MODULE_SEC
26
27 ## generate version section
28 #
29 #
30 class VerSection (VerSectionClassObject):
31
32 ## The constructor
33 #
34 # @param self The object pointer
35 #
36 def __init__(self):
37 VerSectionClassObject.__init__(self)
38
39 ## GenSection() method
40 #
41 # Generate version 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={}, IsMakefile = False):
53 #
54 # Prepare the parameter of GenSection
55 #
56 if FfsInf is not None:
57 self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)
58 self.BuildNum = FfsInf.__ExtendMacro__(self.BuildNum)
59 self.StringData = FfsInf.__ExtendMacro__(self.StringData)
60 self.FileName = FfsInf.__ExtendMacro__(self.FileName)
61
62 OutputFile = os.path.join(OutputPath,
63 ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get('VERSION'))
64 OutputFile = os.path.normpath(OutputFile)
65
66 # Get String Data
67 StringData = ''
68 if self.StringData is not None:
69 StringData = self.StringData
70 elif self.FileName is not None:
71 FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
72 FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)
73 FileObj = open(FileNameStr, 'r')
74 StringData = FileObj.read()
75 StringData = '"' + StringData + '"'
76 FileObj.close()
77 else:
78 StringData = ''
79 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',
80 Ver=StringData, BuildNumber=self.BuildNum, IsMakefile=IsMakefile)
81 OutputFileList = []
82 OutputFileList.append(OutputFile)
83 return OutputFileList, self.Alignment