• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## @file
2# process UI section generation
3#
4#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
5#
6#  This program and the accompanying materials
7#  are licensed and made available under the terms and conditions of the BSD License
8#  which accompanies this distribution.  The full text of the license may be found at
9#  http://opensource.org/licenses/bsd-license.php
10#
11#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13#
14
15##
16# Import Modules
17#
18import Section
19from Ffs import Ffs
20import subprocess
21import Common.LongFilePathOs as os
22from GenFdsGlobalVariable import GenFdsGlobalVariable
23from CommonDataClass.FdfClass import UiSectionClassObject
24from Common.LongFilePathSupport import OpenLongFilePath as open
25
26## generate UI section
27#
28#
29class UiSection (UiSectionClassObject):
30
31    ## The constructor
32    #
33    #   @param  self        The object pointer
34    #
35    def __init__(self):
36        UiSectionClassObject.__init__(self)
37
38    ## GenSection() method
39    #
40    #   Generate UI section
41    #
42    #   @param  self        The object pointer
43    #   @param  OutputPath  Where to place output file
44    #   @param  ModuleName  Which module this section belongs to
45    #   @param  SecNum      Index of section
46    #   @param  KeyStringList  Filter for inputs of section generation
47    #   @param  FfsInf      FfsInfStatement object that contains this section data
48    #   @param  Dict        dictionary contains macro and its value
49    #   @retval tuple       (Generated file name, section alignment)
50    #
51    def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf=None, Dict={}):
52        #
53        # Prepare the parameter of GenSection
54        #
55        if FfsInf != None:
56            self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)
57            self.StringData = FfsInf.__ExtendMacro__(self.StringData)
58            self.FileName = FfsInf.__ExtendMacro__(self.FileName)
59
60        OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get('UI'))
61
62        if self.StringData != None :
63            NameString = self.StringData
64        elif self.FileName != None:
65            FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
66            FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)
67            FileObj = open(FileNameStr, 'r')
68            NameString = FileObj.read()
69            NameString = '\"' + NameString + "\""
70            FileObj.close()
71        else:
72            NameString = ''
73
74        GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTION_USER_INTERFACE', Ui=NameString)
75
76        OutputFileList = []
77        OutputFileList.append(OutputFile)
78        return OutputFileList, self.Alignment
79