]>
Commit | Line | Data |
---|---|---|
30fdf114 LG |
1 | ## @file\r |
2 | # section base class\r | |
3 | #\r | |
23cc8adb | 4 | # Copyright (c) 2007-2015, 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 | |
18 | from CommonDataClass.FdfClass import SectionClassObject\r | |
19 | from GenFdsGlobalVariable import GenFdsGlobalVariable\r | |
1be2ed90 | 20 | import Common.LongFilePathOs as os, glob\r |
30fdf114 LG |
21 | from Common import EdkLogger\r |
22 | from Common.BuildToolError import *\r | |
23 | \r | |
24 | ## section base class\r | |
25 | #\r | |
26 | #\r | |
27 | class 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 | |
97fa0ee9 YL |
132 | if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A \\r |
133 | and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX') \\r | |
134 | or (FileType == 'TE'and File.Type == 'PE32'):\r | |
30fdf114 | 135 | if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []:\r |
97fa0ee9 | 136 | FileList.append(FfsInf.PatchEfiFile(File.Path, File.Type))\r |
30fdf114 LG |
137 | else:\r |
138 | 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 | |
139 | else:\r | |
140 | 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 | |
141 | else:\r | |
142 | 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 | |
143 | \r | |
b74d65ed LG |
144 | if Suffix != None and os.path.exists(FfsInf.EfiOutputPath):\r |
145 | #\r | |
146 | # Get Makefile path and time stamp\r | |
147 | #\r | |
148 | MakefileDir = FfsInf.EfiOutputPath[:-len('OUTPUT')]\r | |
149 | Makefile = os.path.join(MakefileDir, 'Makefile')\r | |
150 | if not os.path.exists(Makefile):\r | |
151 | Makefile = os.path.join(MakefileDir, 'GNUmakefile')\r | |
23cc8adb | 152 | if os.path.exists(Makefile):\r |
b74d65ed LG |
153 | # Update to search files with suffix in all sub-dirs.\r |
154 | Tuple = os.walk(FfsInf.EfiOutputPath)\r | |
155 | for Dirpath, Dirnames, Filenames in Tuple:\r | |
156 | for F in Filenames:\r | |
483b01d2 | 157 | if os.path.splitext(F)[1] == Suffix:\r |
b74d65ed LG |
158 | FullName = os.path.join(Dirpath, F)\r |
159 | if os.path.getmtime(FullName) > os.path.getmtime(Makefile):\r | |
160 | FileList.append(FullName)\r | |
23cc8adb LG |
161 | if not FileList:\r |
162 | SuffixMap = FfsInf.GetFinalTargetSuffixMap()\r | |
163 | if Suffix in SuffixMap:\r | |
164 | FileList.extend(SuffixMap[Suffix])\r | |
165 | \r | |
52302d4d LG |
166 | #Process the file lists is alphabetical for a same section type\r |
167 | if len (FileList) > 1:\r | |
168 | FileList.sort()\r | |
169 | \r | |
30fdf114 LG |
170 | return FileList, IsSect\r |
171 | GetFileList = staticmethod(GetFileList)\r |