]>
Commit | Line | Data |
---|---|---|
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 | 12 | from __future__ import absolute_import\r |
9e47e6f9 | 13 | from .Ffs import SectionSuffix\r |
1be2ed90 | 14 | import Common.LongFilePathOs as os\r |
bfa65b61 | 15 | from .GenFdsGlobalVariable import GenFdsGlobalVariable\r |
30fdf114 | 16 | from CommonDataClass.FdfClass import VerSectionClassObject\r |
1be2ed90 | 17 | from Common.LongFilePathSupport import OpenLongFilePath as open\r |
8bb63e37 | 18 | from Common.DataType import SUP_MODULE_SEC\r |
30fdf114 LG |
19 | \r |
20 | ## generate version section\r | |
21 | #\r | |
22 | #\r | |
23 | class 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 | |
37de70b7 | 45 | def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, 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 |
30fdf114 LG |
64 | FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)\r |
65 | FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)\r | |
66 | FileObj = open(FileNameStr, 'r')\r | |
67 | StringData = FileObj.read()\r | |
68 | StringData = '"' + StringData + '"'\r | |
69 | FileObj.close()\r | |
9979bab7 | 70 | GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',\r |
37de70b7 | 71 | Ver=StringData, BuildNumber=self.BuildNum, IsMakefile=IsMakefile)\r |
30fdf114 LG |
72 | OutputFileList = []\r |
73 | OutputFileList.append(OutputFile)\r | |
74 | return OutputFileList, self.Alignment\r |