]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/GenFds/VerSection.py
edk2: Replace BSD License with BSD+Patent License
[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
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
9e47e6f9 19from .Ffs import SectionSuffix\r
1be2ed90 20import Common.LongFilePathOs as os\r
bfa65b61 21from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
30fdf114 22from CommonDataClass.FdfClass import VerSectionClassObject\r
1be2ed90 23from Common.LongFilePathSupport import OpenLongFilePath as open\r
8bb63e37 24from Common.DataType import SUP_MODULE_SEC\r
30fdf114
LG
25\r
26## generate version section\r
27#\r
28#\r
29class VerSection (VerSectionClassObject):\r
30\r
31 ## The constructor\r
32 #\r
33 # @param self The object pointer\r
34 #\r
35 def __init__(self):\r
36 VerSectionClassObject.__init__(self)\r
37\r
38 ## GenSection() method\r
39 #\r
40 # Generate version section\r
41 #\r
42 # @param self The object pointer\r
43 # @param OutputPath Where to place output file\r
44 # @param ModuleName Which module this section belongs to\r
45 # @param SecNum Index of section\r
46 # @param KeyStringList Filter for inputs of section generation\r
47 # @param FfsInf FfsInfStatement object that contains this section data\r
48 # @param Dict dictionary contains macro and its value\r
49 # @retval tuple (Generated file name, section alignment)\r
50 #\r
37de70b7 51 def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile = False):\r
30fdf114
LG
52 #\r
53 # Prepare the parameter of GenSection\r
54 #\r
9e47e6f9 55 if FfsInf:\r
30fdf114
LG
56 self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)\r
57 self.BuildNum = FfsInf.__ExtendMacro__(self.BuildNum)\r
58 self.StringData = FfsInf.__ExtendMacro__(self.StringData)\r
59 self.FileName = FfsInf.__ExtendMacro__(self.FileName)\r
60\r
61 OutputFile = os.path.join(OutputPath,\r
9e47e6f9 62 ModuleName + SUP_MODULE_SEC + SecNum + SectionSuffix.get('VERSION'))\r
30fdf114
LG
63 OutputFile = os.path.normpath(OutputFile)\r
64\r
65 # Get String Data\r
66 StringData = ''\r
9e47e6f9 67 if self.StringData:\r
37de70b7 68 StringData = self.StringData\r
9e47e6f9 69 elif self.FileName:\r
30fdf114
LG
70 FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)\r
71 FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)\r
72 FileObj = open(FileNameStr, 'r')\r
73 StringData = FileObj.read()\r
74 StringData = '"' + StringData + '"'\r
75 FileObj.close()\r
9979bab7 76 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',\r
37de70b7 77 Ver=StringData, BuildNumber=self.BuildNum, IsMakefile=IsMakefile)\r
30fdf114
LG
78 OutputFileList = []\r
79 OutputFileList.append(OutputFile)\r
80 return OutputFileList, self.Alignment\r