]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/VerSection.py
Sync BaseTool trunk (version r2599) into EDKII BaseTools.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / VerSection.py
1 ## @file
2 # process Version section generation
3 #
4 # Copyright (c) 2007, 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 os
21 import subprocess
22 from GenFdsGlobalVariable import GenFdsGlobalVariable
23 from CommonDataClass.FdfClass import VerSectionClassObject
24
25 ## generate version section
26 #
27 #
28 class VerSection (VerSectionClassObject):
29
30 ## The constructor
31 #
32 # @param self The object pointer
33 #
34 def __init__(self):
35 VerSectionClassObject.__init__(self)
36
37 ## GenSection() method
38 #
39 # Generate version section
40 #
41 # @param self The object pointer
42 # @param OutputPath Where to place output file
43 # @param ModuleName Which module this section belongs to
44 # @param SecNum Index of section
45 # @param KeyStringList Filter for inputs of section generation
46 # @param FfsInf FfsInfStatement object that contains this section data
47 # @param Dict dictionary contains macro and its value
48 # @retval tuple (Generated file name, section alignment)
49 #
50 def GenSection(self,OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}):
51 #
52 # Prepare the parameter of GenSection
53 #
54 if FfsInf != None:
55 self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)
56 self.BuildNum = FfsInf.__ExtendMacro__(self.BuildNum)
57 self.StringData = FfsInf.__ExtendMacro__(self.StringData)
58 self.FileName = FfsInf.__ExtendMacro__(self.FileName)
59
60 OutputFile = os.path.join(OutputPath,
61 ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get('VERSION'))
62 OutputFile = os.path.normpath(OutputFile)
63
64 # Get String Data
65 StringData = ''
66 if self.StringData != None:
67 StringData = self.StringData
68 elif self.FileName != None:
69 FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
70 FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)
71 FileObj = open(FileNameStr, 'r')
72 StringData = FileObj.read()
73 StringData = '"' + StringData + '"'
74 FileObj.close()
75 else:
76 StringData = ''
77
78 GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTION_VERSION',
79 Ver=StringData, BuildNumber=self.BuildNum)
80 OutputFileList = []
81 OutputFileList.append(OutputFile)
82 return OutputFileList, self.Alignment