]>
Commit | Line | Data |
---|---|---|
4234283c LG |
1 | ## @file InfPomAlignmentMisc.py\r |
2 | # This file contained the routines for InfPomAlignment\r | |
3 | #\r | |
4 | # Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r | |
5 | #\r | |
6 | # This program and the accompanying materials are licensed and made available \r | |
7 | # under the terms and conditions of the BSD License which accompanies this \r | |
8 | # 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 | InfPomAlignmentMisc\r | |
17 | '''\r | |
18 | \r | |
19 | ##\r | |
20 | # Import modules\r | |
21 | #\r | |
22 | import Logger.Log as Logger\r | |
23 | from Library import DataType as DT\r | |
24 | from Library.Misc import ConvertArchList\r | |
25 | from Object.POM.ModuleObject import BinaryFileObject\r | |
26 | from Object.POM import CommonObject\r | |
27 | \r | |
28 | ## GenModuleHeaderUserExt\r | |
29 | #\r | |
30 | #\r | |
31 | def GenModuleHeaderUserExt(DefineObj, ArchString):\r | |
32 | DefinesDictNew = {}\r | |
33 | EdkReleaseVersion = DefineObj.GetEdkReleaseVersion()\r | |
34 | Shadow = DefineObj.GetShadow()\r | |
35 | DpxSource = DefineObj.GetDpxSource()\r | |
36 | PciVendorId = DefineObj.GetPciVendorId()\r | |
37 | PciDeviceId = DefineObj.GetPciDeviceId()\r | |
38 | PciClassCode = DefineObj.GetPciClassCode()\r | |
39 | PciRevision = DefineObj.GetPciRevision()\r | |
40 | PciCompress = DefineObj.GetPciCompress()\r | |
41 | CustomMakefile = DefineObj.GetCustomMakefile()\r | |
42 | UefiHiiResourceSection = DefineObj.GetUefiHiiResourceSection()\r | |
43 | \r | |
44 | if EdkReleaseVersion != None:\r | |
45 | Name = DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION\r | |
46 | Value = EdkReleaseVersion.GetValue()\r | |
47 | Statement = _GenInfDefineStateMent(EdkReleaseVersion.Comments.GetHeaderComments(),\r | |
48 | Name,\r | |
49 | Value,\r | |
50 | EdkReleaseVersion.Comments.GetTailComments())\r | |
51 | DefinesDictNew[Statement] = ArchString\r | |
52 | \r | |
53 | if Shadow != None:\r | |
54 | Name = DT.TAB_INF_DEFINES_SHADOW\r | |
55 | Value = Shadow.GetValue()\r | |
56 | Statement = _GenInfDefineStateMent(Shadow.Comments.GetHeaderComments(),\r | |
57 | Name,\r | |
58 | Value,\r | |
59 | Shadow.Comments.GetTailComments())\r | |
60 | DefinesDictNew[Statement] = ArchString\r | |
61 | \r | |
62 | if DpxSource != None:\r | |
63 | Name = DT.TAB_INF_DEFINES_DPX_SOURCE\r | |
64 | for DpxSourceItem in DpxSource:\r | |
65 | Value = DpxSourceItem[0]\r | |
66 | Statement = _GenInfDefineStateMent(DpxSourceItem[1].GetHeaderComments(),\r | |
67 | Name,\r | |
68 | Value,\r | |
69 | DpxSourceItem[1].GetTailComments())\r | |
70 | DefinesDictNew[Statement] = ArchString\r | |
71 | \r | |
72 | if PciVendorId != None:\r | |
73 | Name = DT.TAB_INF_DEFINES_PCI_VENDOR_ID\r | |
74 | Value = PciVendorId.GetValue()\r | |
75 | Statement = _GenInfDefineStateMent(PciVendorId.Comments.GetHeaderComments(),\r | |
76 | Name,\r | |
77 | Value,\r | |
78 | PciVendorId.Comments.GetTailComments())\r | |
79 | DefinesDictNew[Statement] = ArchString\r | |
80 | \r | |
81 | if PciDeviceId != None:\r | |
82 | Name = DT.TAB_INF_DEFINES_PCI_DEVICE_ID\r | |
83 | Value = PciDeviceId.GetValue()\r | |
84 | Statement = _GenInfDefineStateMent(PciDeviceId.Comments.GetHeaderComments(),\r | |
85 | Name,\r | |
86 | Value,\r | |
87 | PciDeviceId.Comments.GetTailComments())\r | |
88 | DefinesDictNew[Statement] = ArchString\r | |
89 | \r | |
90 | if PciClassCode != None:\r | |
91 | Name = DT.TAB_INF_DEFINES_PCI_CLASS_CODE\r | |
92 | Value = PciClassCode.GetValue()\r | |
93 | Statement = _GenInfDefineStateMent(PciClassCode.Comments.GetHeaderComments(),\r | |
94 | Name,\r | |
95 | Value,\r | |
96 | PciClassCode.Comments.GetTailComments())\r | |
97 | DefinesDictNew[Statement] = ArchString\r | |
98 | \r | |
99 | if PciRevision != None:\r | |
100 | Name = DT.TAB_INF_DEFINES_PCI_REVISION\r | |
101 | Value = PciRevision.GetValue()\r | |
102 | Statement = _GenInfDefineStateMent(PciRevision.Comments.GetHeaderComments(),\r | |
103 | Name,\r | |
104 | Value,\r | |
105 | PciRevision.Comments.GetTailComments())\r | |
106 | DefinesDictNew[Statement] = ArchString\r | |
107 | \r | |
108 | if PciCompress != None:\r | |
109 | Name = DT.TAB_INF_DEFINES_PCI_COMPRESS\r | |
110 | Value = PciCompress.GetValue()\r | |
111 | Statement = _GenInfDefineStateMent(PciCompress.Comments.GetHeaderComments(),\r | |
112 | Name,\r | |
113 | Value,\r | |
114 | PciCompress.Comments.GetTailComments())\r | |
115 | DefinesDictNew[Statement] = ArchString\r | |
116 | \r | |
117 | if len(CustomMakefile) >= 1:\r | |
118 | for CustomMakefileItem in CustomMakefile:\r | |
119 | Name = DT.TAB_INF_DEFINES_CUSTOM_MAKEFILE\r | |
120 | #\r | |
121 | # Not with Feature Flag Expression\r | |
122 | #\r | |
123 | if len(CustomMakefileItem) == 3:\r | |
124 | if CustomMakefileItem[0] != '':\r | |
125 | Value = CustomMakefileItem[0] + ' | ' + CustomMakefileItem[1]\r | |
126 | else:\r | |
127 | Value = CustomMakefileItem[1]\r | |
128 | \r | |
129 | Comments = CustomMakefileItem[2]\r | |
130 | Statement = _GenInfDefineStateMent(Comments.GetHeaderComments(),\r | |
131 | Name,\r | |
132 | Value,\r | |
133 | Comments.GetTailComments())\r | |
134 | \r | |
135 | DefinesDictNew[Statement] = ArchString\r | |
136 | \r | |
137 | if UefiHiiResourceSection != None:\r | |
138 | Name = DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION\r | |
139 | Value = UefiHiiResourceSection.GetValue()\r | |
140 | HeaderComment = UefiHiiResourceSection.Comments.GetHeaderComments()\r | |
141 | TailComment = UefiHiiResourceSection.Comments.GetTailComments()\r | |
142 | Statement = _GenInfDefineStateMent(HeaderComment,\r | |
143 | Name,\r | |
144 | Value,\r | |
145 | TailComment)\r | |
146 | DefinesDictNew[Statement] = ""\r | |
147 | \r | |
148 | return DefinesDictNew\r | |
149 | \r | |
150 | \r | |
151 | ## Generate the define statement that will be put into userextension\r | |
152 | # Not support comments.\r | |
153 | #\r | |
154 | # @param HeaderComment: the original header comment (# not remvoed)\r | |
155 | # @param Name: the definition keyword, should not be empty or none\r | |
156 | # @param Value: the definition keyword value\r | |
157 | # @param TailComment: the original Tail comment (# not remvoed)\r | |
158 | #\r | |
159 | # @return: the regenerated define statement\r | |
160 | #\r | |
161 | def _GenInfDefineStateMent(HeaderComment, Name, Value, TailComment):\r | |
162 | Logger.Debug(5, HeaderComment + TailComment)\r | |
163 | Statement = '%s = %s' % (Name, Value)\r | |
164 | \r | |
165 | return Statement\r | |
166 | \r | |
167 | ## GenBinaryData\r | |
168 | #\r | |
169 | #\r | |
170 | def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObjectList, SupArchList, BinaryModule):\r | |
171 | if BinaryModule:\r | |
172 | pass\r | |
173 | OriSupArchList = SupArchList\r | |
174 | for Item in BinaryData:\r | |
175 | ItemObj = BinaryObj[Item][0][0]\r | |
176 | if ItemObj.GetType() not in DT.BINARY_FILE_TYPE_UI_LIST + DT.BINARY_FILE_TYPE_VER_LIST:\r | |
177 | TagName = ItemObj.GetTagName()\r | |
178 | Family = ItemObj.GetFamily()\r | |
179 | else:\r | |
180 | TagName = ''\r | |
181 | Family = ''\r | |
182 | FFE = ItemObj.GetFeatureFlagExp()\r | |
183 | \r | |
184 | #\r | |
185 | # If have architecturie specified, then use the specified architecturie;\r | |
186 | # If the section tag does not have an architecture modifier or the modifier is "common" (case in-sensitive),\r | |
187 | # and the VALID_ARCHITECTURES comment exists, the list from the VALID_ARCHITECTURES comment \r | |
188 | # can be used for the attribute.\r | |
189 | # If both not have VALID_ARCHITECTURE comment and no architecturie specified, then keep it empty.\r | |
190 | # \r | |
191 | SupArchList = ConvertArchList(ItemObj.GetSupArchList())\r | |
192 | SupArchList.sort()\r | |
193 | if len(SupArchList) == 1 and SupArchList[0] == 'COMMON':\r | |
194 | if not (len(OriSupArchList) == 1 or OriSupArchList[0] == 'COMMON'):\r | |
195 | SupArchList = OriSupArchList\r | |
196 | else:\r | |
197 | SupArchList = ['COMMON']\r | |
198 | \r | |
199 | FileNameObj = CommonObject.FileNameObject()\r | |
200 | FileNameObj.SetFileType(ItemObj.GetType())\r | |
201 | FileNameObj.SetFilename(ItemObj.GetFileName())\r | |
202 | FileNameObj.SetFeatureFlag(FFE)\r | |
203 | FileNameObj.SetSupArchList(SupArchList)\r | |
204 | FileNameList = [FileNameObj]\r | |
205 | \r | |
206 | BinaryFile = BinaryFileObject()\r | |
207 | BinaryFile.SetFileNameList(FileNameList)\r | |
208 | BinaryFile.SetAsBuiltList(AsBuildIns)\r | |
209 | BinaryFileObjectList.append(BinaryFile)\r | |
210 | \r | |
211 | SupArchStr = ' '.join(SupArchList)\r | |
212 | Key = (ItemObj.GetFileName(), ItemObj.GetType(), FFE, SupArchStr)\r | |
213 | ValueItem = (ItemObj.GetTarget(), Family, TagName, '')\r | |
214 | if Key in BinariesDict:\r | |
215 | ValueList = BinariesDict[Key]\r | |
216 | ValueList.append(ValueItem)\r | |
217 | BinariesDict[Key] = ValueList\r | |
218 | else:\r | |
219 | BinariesDict[Key] = [ValueItem]\r | |
220 | \r | |
221 | return BinariesDict, AsBuildIns, BinaryFileObjectList\r |