]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/UiSection.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / UiSection.py
1 ## @file
2 # process UI section generation
3 #
4 # Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
5 #
6 # SPDX-License-Identifier: BSD-2-Clause-Patent
7 #
8
9 ##
10 # Import Modules
11 #
12 from __future__ import absolute_import
13 from . import Section
14 from .Ffs import SectionSuffix
15 import subprocess
16 import Common.LongFilePathOs as os
17 from .GenFdsGlobalVariable import GenFdsGlobalVariable
18 from CommonDataClass.FdfClass import UiSectionClassObject
19 from Common.LongFilePathSupport import OpenLongFilePath as open
20 from Common.DataType import *
21
22 ## generate UI section
23 #
24 #
25 class UiSection (UiSectionClassObject):
26
27 ## The constructor
28 #
29 # @param self The object pointer
30 #
31 def __init__(self):
32 UiSectionClassObject.__init__(self)
33
34 ## GenSection() method
35 #
36 # Generate UI section
37 #
38 # @param self The object pointer
39 # @param OutputPath Where to place output file
40 # @param ModuleName Which module this section belongs to
41 # @param SecNum Index of section
42 # @param KeyStringList Filter for inputs of section generation
43 # @param FfsInf FfsInfStatement object that contains this section data
44 # @param Dict dictionary contains macro and its value
45 # @retval tuple (Generated file name, section alignment)
46 #
47 def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile = False):
48 #
49 # Prepare the parameter of GenSection
50 #
51 if FfsInf is not None:
52 self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)
53 self.StringData = FfsInf.__ExtendMacro__(self.StringData)
54 self.FileName = FfsInf.__ExtendMacro__(self.FileName)
55
56 OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + SectionSuffix.get(BINARY_FILE_TYPE_UI))
57
58 if self.StringData is not None :
59 NameString = self.StringData
60 elif self.FileName is not None:
61 FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
62 FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)
63 FileObj = open(FileNameStr, 'r')
64 NameString = FileObj.read()
65 FileObj.close()
66 else:
67 NameString = ''
68 GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTION_USER_INTERFACE', Ui=NameString, IsMakefile=IsMakefile)
69
70 OutputFileList = []
71 OutputFileList.append(OutputFile)
72 return OutputFileList, self.Alignment