]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - BaseTools/Source/Python/GenFds/VerSection.py
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / VerSection.py
... / ...
CommitLineData
1## @file\r
2# process Version section generation\r
3#\r
4# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
5#\r
6# SPDX-License-Identifier: BSD-2-Clause-Patent\r
7#\r
8\r
9##\r
10# Import Modules\r
11#\r
12from __future__ import absolute_import\r
13from .Ffs import SectionSuffix\r
14import Common.LongFilePathOs as os\r
15from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
16from CommonDataClass.FdfClass import VerSectionClassObject\r
17from Common.LongFilePathSupport import OpenLongFilePath as open\r
18from Common.DataType import SUP_MODULE_SEC\r
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
45 def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict=None, IsMakefile = False):\r
46 #\r
47 # Prepare the parameter of GenSection\r
48 #\r
49 if FfsInf:\r
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
56 ModuleName + SUP_MODULE_SEC + SecNum + SectionSuffix.get('VERSION'))\r
57 OutputFile = os.path.normpath(OutputFile)\r
58\r
59 # Get String Data\r
60 StringData = ''\r
61 if self.StringData:\r
62 StringData = self.StringData\r
63 elif self.FileName:\r
64 if Dict is None:\r
65 Dict = {}\r
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
72 GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',\r
73 Ver=StringData, BuildNumber=self.BuildNum, IsMakefile=IsMakefile)\r
74 OutputFileList = []\r
75 OutputFileList.append(OutputFile)\r
76 return OutputFileList, self.Alignment\r