]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/GenFds/Section.py
Sync BaseTools Branch (version r2271) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / Section.py
CommitLineData
30fdf114
LG
1## @file\r
2# section base class\r
3#\r
da92f276 4# Copyright (c) 2007 - 2011, 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
18from CommonDataClass.FdfClass import SectionClassObject\r
19from GenFdsGlobalVariable import GenFdsGlobalVariable\r
20import os, glob\r
21from Common import EdkLogger\r
22from Common.BuildToolError import *\r
23\r
24## section base class\r
25#\r
26#\r
27class Section (SectionClassObject):\r
28 SectionType = {\r
29 'RAW' : 'EFI_SECTION_RAW',\r
30 'FREEFORM' : 'EFI_SECTION_FREEFORM_SUBTYPE_GUID',\r
31 'PE32' : 'EFI_SECTION_PE32',\r
32 'PIC' : 'EFI_SECTION_PIC',\r
33 'TE' : 'EFI_SECTION_TE',\r
34 'FV_IMAGE' : 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE',\r
35 'DXE_DEPEX' : 'EFI_SECTION_DXE_DEPEX',\r
36 'PEI_DEPEX' : 'EFI_SECTION_PEI_DEPEX',\r
37 'GUIDED' : 'EFI_SECTION_GUID_DEFINED',\r
38 'COMPRESS' : 'EFI_SECTION_COMPRESSION',\r
39 'UI' : 'EFI_SECTION_USER_INTERFACE',\r
40 'SMM_DEPEX' : 'EFI_SECTION_SMM_DEPEX'\r
41 }\r
42\r
43 BinFileType = {\r
44 'GUID' : '.guid',\r
45 'ACPI' : '.acpi',\r
46 'ASL' : '.asl' ,\r
47 'UEFI_APP' : '.app',\r
48 'LIB' : '.lib',\r
49 'PE32' : '.pe32',\r
50 'PIC' : '.pic',\r
51 'PEI_DEPEX' : '.depex',\r
52 'SEC_PEI_DEPEX' : '.depex',\r
53 'TE' : '.te',\r
54 'UNI_VER' : '.ver',\r
55 'VER' : '.ver',\r
56 'UNI_UI' : '.ui',\r
57 'UI' : '.ui',\r
58 'BIN' : '.bin',\r
59 'RAW' : '.raw',\r
60 'COMPAT16' : '.comp16',\r
61 'FV' : '.fv'\r
62 }\r
63\r
64 SectFileType = {\r
65 'SEC_GUID' : '.sec' ,\r
66 'SEC_PE32' : '.sec' ,\r
67 'SEC_PIC' : '.sec',\r
68 'SEC_TE' : '.sec',\r
69 'SEC_VER' : '.sec',\r
70 'SEC_UI' : '.sec',\r
71 'SEC_COMPAT16' : '.sec',\r
72 'SEC_BIN' : '.sec'\r
73 }\r
74\r
75 ToolGuid = {\r
76 '0xa31280ad-0x481e-0x41b6-0x95e8-0x127f-0x4c984779' : 'TianoCompress',\r
77 '0xee4e5898-0x3914-0x4259-0x9d6e-0xdc7b-0xd79403cf' : 'LzmaCompress'\r
78 }\r
79\r
80 ## The constructor\r
81 #\r
82 # @param self The object pointer\r
83 #\r
84 def __init__(self):\r
85 SectionClassObject.__init__(self)\r
86\r
87 ## GenSection() method\r
88 #\r
89 # virtual function\r
90 #\r
91 # @param self The object pointer\r
92 # @param OutputPath Where to place output file\r
93 # @param ModuleName Which module this section belongs to\r
94 # @param SecNum Index of section\r
95 # @param KeyStringList Filter for inputs of section generation\r
96 # @param FfsInf FfsInfStatement object that contains this section data\r
97 # @param Dict dictionary contains macro and its value\r
98 #\r
99 def GenSection(self, OutputPath, GuidName, SecNum, keyStringList, FfsInf = None, Dict = {}):\r
100 pass\r
101\r
102 ## GetFileList() method\r
103 #\r
104 # Generate compressed section\r
105 #\r
106 # @param self The object pointer\r
107 # @param FfsInf FfsInfStatement object that contains file list\r
108 # @param FileType File type to get\r
109 # @param FileExtension File extension to get\r
110 # @param Dict dictionary contains macro and its value\r
111 # @retval tuple (File list, boolean)\r
112 #\r
113 def GetFileList(FfsInf, FileType, FileExtension, Dict = {}):\r
114 if FileType in Section.SectFileType.keys() :\r
115 IsSect = True\r
116 else :\r
117 IsSect = False\r
118\r
119 if FileExtension != None:\r
120 Suffix = FileExtension\r
121 elif IsSect :\r
122 Suffix = Section.SectionType.get(FileType)\r
123 else:\r
124 Suffix = Section.BinFileType.get(FileType)\r
125 if FfsInf == None:\r
126 EdkLogger.error("GenFds", GENFDS_ERROR, 'Inf File does not exist!')\r
127\r
128 FileList = []\r
129 if FileType != None:\r
130 for File in FfsInf.BinFileList:\r
131 if File.Arch == "COMMON" or FfsInf.CurrentArch == File.Arch:\r
da92f276 132 if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX'):\r
30fdf114
LG
133 if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []:\r
134 FileList.append(File.Path)\r
135 else:\r
136 GenFdsGlobalVariable.InfLogger ("\nBuild Target \'%s\' of File %s is not in the Scope of %s specified by INF %s in FDF" %(File.Target, File.File, FfsInf.TargetOverrideList, FfsInf.InfFileName))\r
137 else:\r
138 GenFdsGlobalVariable.VerboseLogger ("\nFile Type \'%s\' of File %s in %s is not same with file type \'%s\' from Rule in FDF" %(File.Type, File.File, FfsInf.InfFileName, FileType))\r
139 else:\r
140 GenFdsGlobalVariable.InfLogger ("\nCurrent ARCH \'%s\' of File %s is not in the Support Arch Scope of %s specified by INF %s in FDF" %(FfsInf.CurrentArch, File.File, File.Arch, FfsInf.InfFileName))\r
141\r
4234283c
LG
142 if Suffix != None:\r
143 for File in FfsInf.GetFinalBuildTargetList():\r
144 if os.path.splitext(File)[1] in (Suffix):\r
145 FileList.append(File)\r
30fdf114 146\r
52302d4d
LG
147 #Process the file lists is alphabetical for a same section type\r
148 if len (FileList) > 1:\r
149 FileList.sort()\r
150\r
30fdf114
LG
151 return FileList, IsSect\r
152 GetFileList = staticmethod(GetFileList)\r