]>
Commit | Line | Data |
---|---|---|
4234283c LG |
1 | ## @file\r |
2 | # This file is used to define class objects of INF file [Depex] section. \r | |
3 | # It will consumed by InfParser. \r | |
4 | #\r | |
5 | # Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r | |
6 | #\r | |
7 | # This program and the accompanying materials are licensed and made available \r | |
8 | # under the terms and conditions of the BSD License which accompanies this \r | |
9 | # distribution. The full text of the license may be found at \r | |
10 | # http://opensource.org/licenses/bsd-license.php\r | |
11 | #\r | |
12 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | '''\r | |
16 | InfDepexObject\r | |
17 | '''\r | |
18 | \r | |
19 | from Library import DataType as DT\r | |
20 | from Library import GlobalData\r | |
21 | import Logger.Log as Logger\r | |
22 | from Logger import ToolError\r | |
23 | from Logger import StringTable as ST\r | |
24 | \r | |
25 | from Object.Parser.InfCommonObject import InfSectionCommonDef\r | |
26 | from Library.ParserValidate import IsValidArch\r | |
27 | \r | |
28 | class InfDepexContentItem():\r | |
29 | def __init__(self):\r | |
30 | self.SectionType = ''\r | |
31 | self.SectionString = ''\r | |
32 | \r | |
33 | def SetSectionType(self, SectionType):\r | |
34 | self.SectionType = SectionType\r | |
35 | def GetSectionType(self):\r | |
36 | return self.SectionType\r | |
37 | \r | |
38 | def SetSectionString(self, SectionString):\r | |
39 | self.SectionString = SectionString\r | |
40 | def GetSectionString(self):\r | |
41 | return self.SectionString\r | |
42 | \r | |
43 | \r | |
44 | class InfDepexItem():\r | |
45 | def __init__(self):\r | |
46 | self.DepexContent = ''\r | |
47 | self.ModuleType = ''\r | |
48 | self.SupArch = ''\r | |
49 | self.HelpString = ''\r | |
50 | self.FeatureFlagExp = ''\r | |
51 | self.InfDepexContentItemList = []\r | |
52 | \r | |
53 | def SetFeatureFlagExp(self, FeatureFlagExp):\r | |
54 | self.FeatureFlagExp = FeatureFlagExp\r | |
55 | def GetFeatureFlagExp(self):\r | |
56 | return self.FeatureFlagExp\r | |
57 | \r | |
58 | def SetSupArch(self, Arch):\r | |
59 | self.SupArch = Arch\r | |
60 | def GetSupArch(self):\r | |
61 | return self.SupArch\r | |
62 | \r | |
63 | def SetHelpString(self, HelpString):\r | |
64 | self.HelpString = HelpString\r | |
65 | def GetHelpString(self):\r | |
66 | return self.HelpString\r | |
67 | \r | |
68 | def SetModuleType(self, Type):\r | |
69 | self.ModuleType = Type\r | |
70 | def GetModuleType(self):\r | |
71 | return self.ModuleType\r | |
72 | \r | |
73 | def SetDepexConent(self, Content):\r | |
74 | self.DepexContent = Content\r | |
75 | def GetDepexContent(self):\r | |
76 | return self.DepexContent\r | |
77 | \r | |
78 | def SetInfDepexContentItemList(self, InfDepexContentItemList):\r | |
79 | self.InfDepexContentItemList = InfDepexContentItemList\r | |
80 | def GetInfDepexContentItemList(self):\r | |
81 | return self.InfDepexContentItemList\r | |
82 | \r | |
83 | ## InfDepexObject\r | |
84 | #\r | |
85 | #\r | |
86 | #\r | |
87 | class InfDepexObject(InfSectionCommonDef):\r | |
88 | def __init__(self):\r | |
89 | self.Depex = []\r | |
90 | self.AllContent = ''\r | |
91 | self.SectionContent = ''\r | |
92 | InfSectionCommonDef.__init__(self)\r | |
93 | \r | |
94 | def SetDepex(self, DepexContent, KeyList=None, CommentList=None):\r | |
95 | for KeyItem in KeyList:\r | |
96 | Arch = KeyItem[0]\r | |
97 | ModuleType = KeyItem[1]\r | |
98 | InfDepexItemIns = InfDepexItem()\r | |
99 | \r | |
100 | #\r | |
101 | # Validate Arch\r | |
102 | # \r | |
103 | if IsValidArch(Arch.strip().upper()):\r | |
104 | InfDepexItemIns.SetSupArch(Arch)\r | |
105 | else:\r | |
106 | Logger.Error("InfParser",\r | |
107 | ToolError.FORMAT_INVALID,\r | |
108 | ST.ERR_INF_PARSER_DEFINE_NAME_INVALID % (Arch),\r | |
109 | File=GlobalData.gINF_MODULE_NAME,\r | |
110 | Line=KeyItem[2])\r | |
111 | \r | |
112 | #\r | |
113 | # Validate Module Type\r | |
114 | #\r | |
115 | if ModuleType and ModuleType != 'COMMON':\r | |
116 | if ModuleType in DT.VALID_DEPEX_MODULE_TYPE_LIST:\r | |
117 | InfDepexItemIns.SetModuleType(ModuleType)\r | |
118 | else:\r | |
119 | Logger.Error("InfParser",\r | |
120 | ToolError.FORMAT_INVALID,\r | |
121 | ST.ERR_INF_PARSER_DEPEX_SECTION_MODULE_TYPE_ERROR % (ModuleType),\r | |
122 | File=GlobalData.gINF_MODULE_NAME,\r | |
123 | Line=KeyItem[2])\r | |
124 | \r | |
125 | #\r | |
126 | # Parser content in [Depex] section.\r | |
127 | #\r | |
128 | DepexString = ''\r | |
129 | HelpString = ''\r | |
130 | #\r | |
131 | # Get Depex Expression\r | |
132 | #\r | |
133 | for Line in DepexContent:\r | |
134 | LineContent = Line[0].strip()\r | |
135 | if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1:\r | |
136 | LineContent = LineContent[:LineContent.find(DT.TAB_COMMENT_SPLIT)]\r | |
137 | if LineContent:\r | |
138 | DepexString = DepexString + LineContent + DT.END_OF_LINE\r | |
139 | continue\r | |
140 | \r | |
141 | if DepexString.endswith(DT.END_OF_LINE):\r | |
142 | DepexString = DepexString[:-1]\r | |
143 | \r | |
144 | if not DepexString.strip():\r | |
145 | continue\r | |
146 | \r | |
147 | #\r | |
148 | # Get Help Text\r | |
149 | #\r | |
150 | for HelpLine in CommentList:\r | |
151 | HelpString = HelpString + HelpLine + DT.END_OF_LINE\r | |
152 | if HelpString.endswith(DT.END_OF_LINE):\r | |
153 | HelpString = HelpString[:-1]\r | |
154 | \r | |
155 | InfDepexItemIns.SetDepexConent(DepexString)\r | |
156 | InfDepexItemIns.SetHelpString(HelpString)\r | |
157 | \r | |
158 | self.Depex.append(InfDepexItemIns)\r | |
159 | \r | |
160 | return True\r | |
161 | \r | |
162 | def GetDepex(self):\r | |
163 | return self.Depex\r | |
164 | \r | |
165 | def GetAllContent(self):\r | |
166 | return self.AllContent\r |