]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/GenFds/VerSection.py
BaseTools:change some incorrect parameter defaults
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / VerSection.py
CommitLineData
30fdf114
LG
1## @file\r
2# process Version section generation\r
3#\r
9e47e6f9 4# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
30fdf114 5#\r
2e351cbe 6# SPDX-License-Identifier: BSD-2-Clause-Patent\r
30fdf114
LG
7#\r
8\r
9##\r
10# Import Modules\r
11#\r
1ccc4d89 12from __future__ import absolute_import\r
9e47e6f9 13from .Ffs import SectionSuffix\r
1be2ed90 14import Common.LongFilePathOs as os\r
bfa65b61 15from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
30fdf114 16from CommonDataClass.FdfClass import VerSectionClassObject\r
1be2ed90 17from Common.LongFilePathSupport import OpenLongFilePath as open\r
8bb63e37 18from Common.DataType import SUP_MODULE_SEC\r
30fdf114
LG
19\r
20## generate version section\r
21#\r
22#\r
23class VerSection (VerSectionClassObject):\r
24\r
25 ## The constructor\r
26 #\r
27 # @param self The object pointer\r
28 #\r
29 def __init__(self):\r
30 VerSectionClassObject.__init__(self)\r
31\r
32 ## GenSection() method\r
33 #\r
34 # Generate version section\r
35 #\r
36 # @param self The object pointer\r
37 # @param OutputPath Where to place output file\r
38 # @param ModuleName Which module this section belongs to\r
39 # @param SecNum Index of section\r
40 # @param KeyStringList Filter for inputs of section generation\r
41 # @param FfsInf FfsInfStatement object that contains this section data\r
42 # @param Dict dictionary contains macro and its value\r
43 # @retval tuple (Generated file name, section alignment)\r
44 #\r
e32f7bc9 45 def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict=None, IsMakefile = False):\r
30fdf114
LG
46 #\r
47 # Prepare the parameter of GenSection\r
48 #\r
9e47e6f9 49 if FfsInf:\r
30fdf114
LG
50 self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)\r
51 self.BuildNum = FfsInf.__ExtendMacro__(self.BuildNum)\r
52 self.StringData = FfsInf.__ExtendMacro__(self.StringData)\r
53 self.FileName = FfsInf.__ExtendMacro__(self.FileName)\r
54\r
55 OutputFile = os.path.join(OutputPath,\r
9e47e6f9 56 ModuleName + SUP_MODULE_SEC + SecNum + SectionSuffix.get('VERSION'))\r
30fdf114
LG
57 OutputFile = os.path.normpath(OutputFile)\r
58\r
59 # Get String Data\r
60 StringData = ''\r
9e47e6f9 61 if self.StringData:\r
37de70b7 62 StringData = self.StringData\r
9e47e6f9 63 elif self.FileName:\r
e32f7bc9
FZ
64 if Dict is None:\r
65 Dict = {}\r
30fdf114
LG
66 FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)\r
67 FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)\r
68 FileObj = open(FileNameStr, 'r')\r
69 StringData = FileObj.read()\r
70 StringData = '"' + StringData + '"'\r
71 FileObj.close()\r
9979bab7 72 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',\r
37de70b7 73 Ver=StringData, BuildNumber=self.BuildNum, IsMakefile=IsMakefile)\r
30fdf114
LG
74 OutputFileList = []\r
75 OutputFileList.append(OutputFile)\r
76 return OutputFileList, self.Alignment\r