]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/GenFds/UiSection.py
BaseTools: Use absolute import in GenFds
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / UiSection.py
CommitLineData
30fdf114
LG
1## @file\r
2# process UI section generation\r
3#\r
1e892df6 4# Copyright (c) 2007 - 2017, 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
bfa65b61
GL
18from __future__ import absolute_import\r
19from . import Section\r
20from .Ffs import Ffs\r
30fdf114 21import subprocess\r
1be2ed90 22import Common.LongFilePathOs as os\r
bfa65b61 23from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
30fdf114 24from CommonDataClass.FdfClass import UiSectionClassObject\r
1be2ed90 25from Common.LongFilePathSupport import OpenLongFilePath as open\r
91fa33ee 26from Common.DataType import *\r
30fdf114
LG
27\r
28## generate UI section\r
29#\r
30#\r
31class UiSection (UiSectionClassObject):\r
32\r
33 ## The constructor\r
34 #\r
35 # @param self The object pointer\r
36 #\r
37 def __init__(self):\r
38 UiSectionClassObject.__init__(self)\r
39\r
40 ## GenSection() method\r
41 #\r
42 # Generate UI section\r
43 #\r
44 # @param self The object pointer\r
45 # @param OutputPath Where to place output file\r
46 # @param ModuleName Which module this section belongs to\r
47 # @param SecNum Index of section\r
48 # @param KeyStringList Filter for inputs of section generation\r
49 # @param FfsInf FfsInfStatement object that contains this section data\r
50 # @param Dict dictionary contains macro and its value\r
51 # @retval tuple (Generated file name, section alignment)\r
52 #\r
37de70b7 53 def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}, IsMakefile = False):\r
30fdf114
LG
54 #\r
55 # Prepare the parameter of GenSection\r
56 #\r
4231a819 57 if FfsInf is not None:\r
30fdf114
LG
58 self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)\r
59 self.StringData = FfsInf.__ExtendMacro__(self.StringData)\r
60 self.FileName = FfsInf.__ExtendMacro__(self.FileName)\r
61\r
91fa33ee 62 OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get(BINARY_FILE_TYPE_UI))\r
30fdf114 63\r
4231a819 64 if self.StringData is not None :\r
30fdf114 65 NameString = self.StringData\r
4231a819 66 elif self.FileName is not None:\r
30fdf114
LG
67 FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)\r
68 FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)\r
69 FileObj = open(FileNameStr, 'r')\r
70 NameString = FileObj.read()\r
30fdf114
LG
71 FileObj.close()\r
72 else:\r
73 NameString = ''\r
37de70b7 74 GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTION_USER_INTERFACE', Ui=NameString, IsMakefile=IsMakefile)\r
30fdf114
LG
75\r
76 OutputFileList = []\r
77 OutputFileList.append(OutputFile)\r
78 return OutputFileList, self.Alignment\r