]>
Commit | Line | Data |
---|---|---|
30fdf114 LG |
1 | ## @file\r |
2 | # section base class\r | |
3 | #\r | |
55c84777 | 4 | # Copyright (c) 2007-2018, 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 | 18 | from __future__ import absolute_import\r |
30fdf114 | 19 | from CommonDataClass.FdfClass import SectionClassObject\r |
bfa65b61 | 20 | from .GenFdsGlobalVariable import GenFdsGlobalVariable\r |
1be2ed90 | 21 | import Common.LongFilePathOs as os, glob\r |
30fdf114 LG |
22 | from Common import EdkLogger\r |
23 | from Common.BuildToolError import *\r | |
91fa33ee | 24 | from Common.DataType import *\r |
30fdf114 LG |
25 | \r |
26 | ## section base class\r | |
27 | #\r | |
28 | #\r | |
29 | class Section (SectionClassObject):\r | |
30 | SectionType = {\r | |
31 | 'RAW' : 'EFI_SECTION_RAW',\r | |
32 | 'FREEFORM' : 'EFI_SECTION_FREEFORM_SUBTYPE_GUID',\r | |
91fa33ee CJ |
33 | BINARY_FILE_TYPE_PE32 : 'EFI_SECTION_PE32',\r |
34 | BINARY_FILE_TYPE_PIC : 'EFI_SECTION_PIC',\r | |
35 | BINARY_FILE_TYPE_TE : 'EFI_SECTION_TE',\r | |
30fdf114 | 36 | 'FV_IMAGE' : 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE',\r |
91fa33ee CJ |
37 | BINARY_FILE_TYPE_DXE_DEPEX : 'EFI_SECTION_DXE_DEPEX',\r |
38 | BINARY_FILE_TYPE_PEI_DEPEX : 'EFI_SECTION_PEI_DEPEX',\r | |
30fdf114 LG |
39 | 'GUIDED' : 'EFI_SECTION_GUID_DEFINED',\r |
40 | 'COMPRESS' : 'EFI_SECTION_COMPRESSION',\r | |
91fa33ee CJ |
41 | BINARY_FILE_TYPE_UI : 'EFI_SECTION_USER_INTERFACE',\r |
42 | BINARY_FILE_TYPE_SMM_DEPEX : 'EFI_SECTION_SMM_DEPEX'\r | |
30fdf114 LG |
43 | }\r |
44 | \r | |
45 | BinFileType = {\r | |
91fa33ee | 46 | BINARY_FILE_TYPE_GUID : '.guid',\r |
30fdf114 LG |
47 | 'ACPI' : '.acpi',\r |
48 | 'ASL' : '.asl' ,\r | |
91fa33ee CJ |
49 | BINARY_FILE_TYPE_UEFI_APP : '.app',\r |
50 | BINARY_FILE_TYPE_LIB : '.lib',\r | |
51 | BINARY_FILE_TYPE_PE32 : '.pe32',\r | |
52 | BINARY_FILE_TYPE_PIC : '.pic',\r | |
53 | BINARY_FILE_TYPE_PEI_DEPEX : '.depex',\r | |
30fdf114 | 54 | 'SEC_PEI_DEPEX' : '.depex',\r |
91fa33ee CJ |
55 | BINARY_FILE_TYPE_TE : '.te',\r |
56 | BINARY_FILE_TYPE_UNI_VER : '.ver',\r | |
57 | BINARY_FILE_TYPE_VER : '.ver',\r | |
58 | BINARY_FILE_TYPE_UNI_UI : '.ui',\r | |
59 | BINARY_FILE_TYPE_UI : '.ui',\r | |
60 | BINARY_FILE_TYPE_BIN : '.bin',\r | |
30fdf114 LG |
61 | 'RAW' : '.raw',\r |
62 | 'COMPAT16' : '.comp16',\r | |
91fa33ee | 63 | BINARY_FILE_TYPE_FV : '.fv'\r |
30fdf114 LG |
64 | }\r |
65 | \r | |
66 | SectFileType = {\r | |
67 | 'SEC_GUID' : '.sec' ,\r | |
68 | 'SEC_PE32' : '.sec' ,\r | |
69 | 'SEC_PIC' : '.sec',\r | |
70 | 'SEC_TE' : '.sec',\r | |
71 | 'SEC_VER' : '.sec',\r | |
72 | 'SEC_UI' : '.sec',\r | |
73 | 'SEC_COMPAT16' : '.sec',\r | |
74 | 'SEC_BIN' : '.sec'\r | |
75 | }\r | |
76 | \r | |
77 | ToolGuid = {\r | |
78 | '0xa31280ad-0x481e-0x41b6-0x95e8-0x127f-0x4c984779' : 'TianoCompress',\r | |
79 | '0xee4e5898-0x3914-0x4259-0x9d6e-0xdc7b-0xd79403cf' : 'LzmaCompress'\r | |
80 | }\r | |
81 | \r | |
82 | ## The constructor\r | |
83 | #\r | |
84 | # @param self The object pointer\r | |
85 | #\r | |
86 | def __init__(self):\r | |
87 | SectionClassObject.__init__(self)\r | |
88 | \r | |
89 | ## GenSection() method\r | |
90 | #\r | |
91 | # virtual function\r | |
92 | #\r | |
93 | # @param self The object pointer\r | |
94 | # @param OutputPath Where to place output file\r | |
95 | # @param ModuleName Which module this section belongs to\r | |
96 | # @param SecNum Index of section\r | |
97 | # @param KeyStringList Filter for inputs of section generation\r | |
98 | # @param FfsInf FfsInfStatement object that contains this section data\r | |
99 | # @param Dict dictionary contains macro and its value\r | |
100 | #\r | |
101 | def GenSection(self, OutputPath, GuidName, SecNum, keyStringList, FfsInf = None, Dict = {}):\r | |
102 | pass\r | |
103 | \r | |
104 | ## GetFileList() method\r | |
105 | #\r | |
106 | # Generate compressed section\r | |
107 | #\r | |
108 | # @param self The object pointer\r | |
109 | # @param FfsInf FfsInfStatement object that contains file list\r | |
110 | # @param FileType File type to get\r | |
111 | # @param FileExtension File extension to get\r | |
112 | # @param Dict dictionary contains macro and its value\r | |
113 | # @retval tuple (File list, boolean)\r | |
114 | #\r | |
cf245466 | 115 | def GetFileList(FfsInf, FileType, FileExtension, Dict = {}, IsMakefile=False):\r |
98120f5f | 116 | IsSect = FileType in Section.SectFileType\r |
30fdf114 | 117 | \r |
4231a819 | 118 | if FileExtension is not None:\r |
30fdf114 LG |
119 | Suffix = FileExtension\r |
120 | elif IsSect :\r | |
121 | Suffix = Section.SectionType.get(FileType)\r | |
122 | else:\r | |
123 | Suffix = Section.BinFileType.get(FileType)\r | |
4231a819 | 124 | if FfsInf is None:\r |
30fdf114 LG |
125 | EdkLogger.error("GenFds", GENFDS_ERROR, 'Inf File does not exist!')\r |
126 | \r | |
127 | FileList = []\r | |
4231a819 | 128 | if FileType is not None:\r |
30fdf114 | 129 | for File in FfsInf.BinFileList:\r |
55c84777 | 130 | if File.Arch == TAB_ARCH_COMMON or FfsInf.CurrentArch == File.Arch:\r |
97fa0ee9 | 131 | if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A \\r |
91fa33ee CJ |
132 | and FileType == 'DXE_DPEX' and File.Type == BINARY_FILE_TYPE_SMM_DEPEX) \\r |
133 | or (FileType == BINARY_FILE_TYPE_TE and File.Type == BINARY_FILE_TYPE_PE32):\r | |
30fdf114 | 134 | if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []:\r |
97fa0ee9 | 135 | FileList.append(FfsInf.PatchEfiFile(File.Path, File.Type))\r |
30fdf114 LG |
136 | else:\r |
137 | 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 | |
138 | else:\r | |
139 | 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 | |
140 | else:\r | |
141 | 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 | |
142 | \r | |
4231a819 | 143 | if (not IsMakefile and Suffix is not None and os.path.exists(FfsInf.EfiOutputPath)) or (IsMakefile and Suffix is not None):\r |
b74d65ed LG |
144 | #\r |
145 | # Get Makefile path and time stamp\r | |
146 | #\r | |
147 | MakefileDir = FfsInf.EfiOutputPath[:-len('OUTPUT')]\r | |
148 | Makefile = os.path.join(MakefileDir, 'Makefile')\r | |
149 | if not os.path.exists(Makefile):\r | |
150 | Makefile = os.path.join(MakefileDir, 'GNUmakefile')\r | |
23cc8adb | 151 | if os.path.exists(Makefile):\r |
b74d65ed LG |
152 | # Update to search files with suffix in all sub-dirs.\r |
153 | Tuple = os.walk(FfsInf.EfiOutputPath)\r | |
154 | for Dirpath, Dirnames, Filenames in Tuple:\r | |
155 | for F in Filenames:\r | |
483b01d2 | 156 | if os.path.splitext(F)[1] == Suffix:\r |
b74d65ed LG |
157 | FullName = os.path.join(Dirpath, F)\r |
158 | if os.path.getmtime(FullName) > os.path.getmtime(Makefile):\r | |
159 | FileList.append(FullName)\r | |
23cc8adb LG |
160 | if not FileList:\r |
161 | SuffixMap = FfsInf.GetFinalTargetSuffixMap()\r | |
162 | if Suffix in SuffixMap:\r | |
163 | FileList.extend(SuffixMap[Suffix])\r | |
f7496d71 | 164 | \r |
52302d4d LG |
165 | #Process the file lists is alphabetical for a same section type\r |
166 | if len (FileList) > 1:\r | |
167 | FileList.sort()\r | |
168 | \r | |
30fdf114 LG |
169 | return FileList, IsSect\r |
170 | GetFileList = staticmethod(GetFileList)\r |