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