]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/GenFds/VerSection.py
Revert BaseTools: PYTHON3 migration
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / VerSection.py
CommitLineData
30fdf114
LG
1## @file\r
2# process Version section generation\r
3#\r
37de70b7 4# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
30fdf114 5#\r
40d841f6 6# This program and the accompanying materials\r
30fdf114
LG
7# are licensed and made available under the terms and conditions of the BSD License\r
8# which accompanies this distribution. The full text of the license may be found at\r
9# http://opensource.org/licenses/bsd-license.php\r
10#\r
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13#\r
14\r
15##\r
16# Import Modules\r
17#\r
1ccc4d89 18from __future__ import absolute_import\r
bfa65b61
GL
19from .Ffs import Ffs\r
20from . import Section\r
1be2ed90 21import Common.LongFilePathOs as os\r
30fdf114 22import subprocess\r
bfa65b61 23from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
30fdf114 24from CommonDataClass.FdfClass import VerSectionClassObject\r
1be2ed90 25from Common.LongFilePathSupport import OpenLongFilePath as open\r
8bb63e37 26from Common.DataType import SUP_MODULE_SEC\r
30fdf114
LG
27\r
28## generate version section\r
29#\r
30#\r
31class VerSection (VerSectionClassObject):\r
32\r
33 ## The constructor\r
34 #\r
35 # @param self The object pointer\r
36 #\r
37 def __init__(self):\r
38 VerSectionClassObject.__init__(self)\r
39\r
40 ## GenSection() method\r
41 #\r
42 # Generate version section\r
43 #\r
44 # @param self The object pointer\r
45 # @param OutputPath Where to place output file\r
46 # @param ModuleName Which module this section belongs to\r
47 # @param SecNum Index of section\r
48 # @param KeyStringList Filter for inputs of section generation\r
49 # @param FfsInf FfsInfStatement object that contains this section data\r
50 # @param Dict dictionary contains macro and its value\r
51 # @retval tuple (Generated file name, section alignment)\r
52 #\r
37de70b7 53 def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile = False):\r
30fdf114
LG
54 #\r
55 # Prepare the parameter of GenSection\r
56 #\r
4231a819 57 if FfsInf is not None:\r
30fdf114
LG
58 self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)\r
59 self.BuildNum = FfsInf.__ExtendMacro__(self.BuildNum)\r
60 self.StringData = FfsInf.__ExtendMacro__(self.StringData)\r
61 self.FileName = FfsInf.__ExtendMacro__(self.FileName)\r
62\r
63 OutputFile = os.path.join(OutputPath,\r
8bb63e37 64 ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get('VERSION'))\r
30fdf114
LG
65 OutputFile = os.path.normpath(OutputFile)\r
66\r
67 # Get String Data\r
68 StringData = ''\r
4231a819 69 if self.StringData is not None:\r
37de70b7 70 StringData = self.StringData\r
4231a819 71 elif self.FileName is not None:\r
30fdf114
LG
72 FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)\r
73 FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)\r
74 FileObj = open(FileNameStr, 'r')\r
75 StringData = FileObj.read()\r
76 StringData = '"' + StringData + '"'\r
77 FileObj.close()\r
78 else:\r
79 StringData = ''\r
9979bab7 80 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',\r
37de70b7 81 Ver=StringData, BuildNumber=self.BuildNum, IsMakefile=IsMakefile)\r
30fdf114
LG
82 OutputFileList = []\r
83 OutputFileList.append(OutputFile)\r
84 return OutputFileList, self.Alignment\r